Line data Source code
1 : /* THIS FILE IS AUTOGENERATED FROM InstallTrigger.webidl BY Codegen.py - DO NOT EDIT */
2 :
3 : #ifndef mozilla_dom_InstallTriggerBinding_h
4 : #define mozilla_dom_InstallTriggerBinding_h
5 :
6 : #include "js/RootingAPI.h"
7 : #include "jspubtd.h"
8 : #include "mozilla/ErrorResult.h"
9 : #include "mozilla/dom/BindingDeclarations.h"
10 : #include "mozilla/dom/CallbackFunction.h"
11 : #include "mozilla/dom/CallbackInterface.h"
12 : #include "mozilla/dom/FakeString.h"
13 : #include "mozilla/dom/Nullable.h"
14 : #include "mozilla/dom/Record.h"
15 : #include "mozilla/dom/ToJSValue.h"
16 : #include "mozilla/dom/UnionMember.h"
17 : #include "nsWeakReference.h"
18 :
19 : namespace mozilla {
20 : namespace dom {
21 :
22 : class InstallTriggerCallback;
23 : struct InstallTriggerDataAtoms;
24 : class InstallTriggerImpl;
25 : struct InstallTriggerImplAtoms;
26 : struct NativePropertyHooks;
27 : class OwningStringOrInstallTriggerData;
28 : class ProtoAndIfaceCache;
29 : class StringOrInstallTriggerData;
30 :
31 : } // namespace dom
32 : } // namespace mozilla
33 :
34 : namespace mozilla {
35 : namespace dom {
36 :
37 0 : struct InstallTriggerData : public DictionaryBase
38 : {
39 : MOZ_INIT_OUTSIDE_CTOR Optional<nsString> mHash;
40 : MOZ_INIT_OUTSIDE_CTOR Optional<nsString> mIconURL;
41 : MOZ_INIT_OUTSIDE_CTOR Optional<nsString> mURL;
42 :
43 : InstallTriggerData();
44 :
45 : explicit inline InstallTriggerData(const FastDictionaryInitializer& )
46 : {
47 : // Do nothing here; this is used by our "Fast" subclass
48 : }
49 :
50 : explicit inline InstallTriggerData(const InstallTriggerData& aOther)
51 : {
52 : *this = aOther;
53 : }
54 :
55 : bool
56 : Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false);
57 :
58 : bool
59 : Init(const nsAString& aJSON);
60 :
61 : bool
62 : ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const;
63 :
64 : bool
65 : ToJSON(nsAString& aJSON) const;
66 :
67 : void
68 : TraceDictionary(JSTracer* trc);
69 :
70 : InstallTriggerData&
71 : operator=(const InstallTriggerData& aOther);
72 :
73 : private:
74 : static bool
75 : InitIds(JSContext* cx, InstallTriggerDataAtoms* atomsCache);
76 : };
77 :
78 : namespace binding_detail {
79 : struct FastInstallTriggerData : public InstallTriggerData
80 : {
81 : inline FastInstallTriggerData()
82 : : InstallTriggerData(FastDictionaryInitializer())
83 : {
84 : // Doesn't matter what int we pass to the parent constructor
85 : }
86 : };
87 : } // namespace binding_detail
88 :
89 :
90 : class StringOrInstallTriggerData
91 : {
92 : friend class StringOrInstallTriggerDataArgument;
93 : enum Type
94 : {
95 : eUninitialized,
96 : eString,
97 : eInstallTriggerData
98 : };
99 :
100 : union Value
101 : {
102 : UnionMember<binding_detail::FakeString > mString;
103 : UnionMember<binding_detail::FastInstallTriggerData > mInstallTriggerData;
104 :
105 : };
106 :
107 : Type mType;
108 : Value mValue;
109 :
110 : StringOrInstallTriggerData(const StringOrInstallTriggerData&) = delete;
111 : StringOrInstallTriggerData& operator=(const StringOrInstallTriggerData&) = delete;
112 : public:
113 : explicit inline StringOrInstallTriggerData()
114 : : mType(eUninitialized)
115 : {
116 : }
117 :
118 : inline ~StringOrInstallTriggerData()
119 : {
120 : Uninit();
121 : }
122 :
123 : inline binding_detail::FakeString&
124 : RawSetAsString()
125 : {
126 : if (mType == eString) {
127 : return mValue.mString.Value();
128 : }
129 : MOZ_ASSERT(mType == eUninitialized);
130 : mType = eString;
131 : return mValue.mString.SetValue();
132 : }
133 :
134 : inline binding_detail::FakeString&
135 : SetAsString()
136 : {
137 : if (mType == eString) {
138 : return mValue.mString.Value();
139 : }
140 : Uninit();
141 : mType = eString;
142 : return mValue.mString.SetValue();
143 : }
144 :
145 : inline bool
146 : IsString() const
147 : {
148 : return mType == eString;
149 : }
150 :
151 : inline binding_detail::FakeString&
152 : GetAsString()
153 : {
154 : MOZ_ASSERT(IsString(), "Wrong type!");
155 : return mValue.mString.Value();
156 : }
157 :
158 : inline const nsAString&
159 : GetAsString() const
160 : {
161 : MOZ_ASSERT(IsString(), "Wrong type!");
162 : return mValue.mString.Value();
163 : }
164 :
165 : inline binding_detail::FastInstallTriggerData&
166 : RawSetAsInstallTriggerData()
167 : {
168 : if (mType == eInstallTriggerData) {
169 : return mValue.mInstallTriggerData.Value();
170 : }
171 : MOZ_ASSERT(mType == eUninitialized);
172 : mType = eInstallTriggerData;
173 : return mValue.mInstallTriggerData.SetValue();
174 : }
175 :
176 : inline binding_detail::FastInstallTriggerData&
177 : SetAsInstallTriggerData()
178 : {
179 : if (mType == eInstallTriggerData) {
180 : return mValue.mInstallTriggerData.Value();
181 : }
182 : Uninit();
183 : mType = eInstallTriggerData;
184 : return mValue.mInstallTriggerData.SetValue();
185 : }
186 :
187 : inline bool
188 : IsInstallTriggerData() const
189 : {
190 : return mType == eInstallTriggerData;
191 : }
192 :
193 : inline binding_detail::FastInstallTriggerData&
194 : GetAsInstallTriggerData()
195 : {
196 : MOZ_ASSERT(IsInstallTriggerData(), "Wrong type!");
197 : return mValue.mInstallTriggerData.Value();
198 : }
199 :
200 : inline const InstallTriggerData&
201 : GetAsInstallTriggerData() const
202 : {
203 : MOZ_ASSERT(IsInstallTriggerData(), "Wrong type!");
204 : return mValue.mInstallTriggerData.Value();
205 : }
206 :
207 : inline void
208 : Uninit()
209 : {
210 : switch (mType) {
211 : case eUninitialized: {
212 : break;
213 : }
214 : case eString: {
215 : DestroyString();
216 : break;
217 : }
218 : case eInstallTriggerData: {
219 : DestroyInstallTriggerData();
220 : break;
221 : }
222 : }
223 : }
224 :
225 : bool
226 : ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
227 :
228 : private:
229 : inline void
230 : DestroyString()
231 : {
232 : MOZ_ASSERT(IsString(), "Wrong type!");
233 : mValue.mString.Destroy();
234 : mType = eUninitialized;
235 : }
236 :
237 : inline void
238 : DestroyInstallTriggerData()
239 : {
240 : MOZ_ASSERT(IsInstallTriggerData(), "Wrong type!");
241 : mValue.mInstallTriggerData.Destroy();
242 : mType = eUninitialized;
243 : }
244 : };
245 :
246 :
247 : class OwningStringOrInstallTriggerData : public AllOwningUnionBase
248 : {
249 : friend void ImplCycleCollectionUnlink(OwningStringOrInstallTriggerData& aUnion);
250 : enum Type
251 : {
252 : eUninitialized,
253 : eString,
254 : eInstallTriggerData
255 : };
256 :
257 0 : union Value
258 : {
259 : UnionMember<nsString > mString;
260 : UnionMember<InstallTriggerData > mInstallTriggerData;
261 :
262 : };
263 :
264 : Type mType;
265 : Value mValue;
266 :
267 : public:
268 0 : explicit inline OwningStringOrInstallTriggerData()
269 0 : : mType(eUninitialized)
270 : {
271 0 : }
272 :
273 : explicit inline OwningStringOrInstallTriggerData(const OwningStringOrInstallTriggerData& aOther)
274 : : mType(eUninitialized)
275 : {
276 : *this = aOther;
277 : }
278 :
279 0 : inline ~OwningStringOrInstallTriggerData()
280 0 : {
281 0 : Uninit();
282 0 : }
283 :
284 : nsString&
285 : RawSetAsString();
286 :
287 : nsString&
288 : SetAsString();
289 :
290 : bool
291 : TrySetToString(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
292 :
293 : inline void
294 : SetStringData(const nsString::char_type* aData, nsString::size_type aLength)
295 : {
296 : RawSetAsString().Assign(aData, aLength);
297 : }
298 :
299 : inline bool
300 0 : IsString() const
301 : {
302 0 : return mType == eString;
303 : }
304 :
305 : inline nsString&
306 : GetAsString()
307 : {
308 : MOZ_ASSERT(IsString(), "Wrong type!");
309 : return mValue.mString.Value();
310 : }
311 :
312 : inline nsString const &
313 0 : GetAsString() const
314 : {
315 0 : MOZ_ASSERT(IsString(), "Wrong type!");
316 0 : return mValue.mString.Value();
317 : }
318 :
319 : InstallTriggerData&
320 : RawSetAsInstallTriggerData();
321 :
322 : InstallTriggerData&
323 : SetAsInstallTriggerData();
324 :
325 : bool
326 : TrySetToInstallTriggerData(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
327 :
328 : inline bool
329 0 : IsInstallTriggerData() const
330 : {
331 0 : return mType == eInstallTriggerData;
332 : }
333 :
334 : inline InstallTriggerData&
335 : GetAsInstallTriggerData()
336 : {
337 : MOZ_ASSERT(IsInstallTriggerData(), "Wrong type!");
338 : return mValue.mInstallTriggerData.Value();
339 : }
340 :
341 : inline InstallTriggerData const &
342 0 : GetAsInstallTriggerData() const
343 : {
344 0 : MOZ_ASSERT(IsInstallTriggerData(), "Wrong type!");
345 0 : return mValue.mInstallTriggerData.Value();
346 : }
347 :
348 : void
349 : Uninit();
350 :
351 : bool
352 : ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
353 :
354 : void
355 : TraceUnion(JSTracer* trc);
356 :
357 : OwningStringOrInstallTriggerData&
358 : operator=(const OwningStringOrInstallTriggerData& aOther);
359 :
360 : private:
361 : void
362 : DestroyString();
363 :
364 : void
365 : DestroyInstallTriggerData();
366 : };
367 :
368 :
369 0 : class InstallTriggerCallback : public CallbackFunction
370 : {
371 : public:
372 0 : explicit inline InstallTriggerCallback(JSContext* aCx, JS::Handle<JSObject*> aCallback, nsIGlobalObject* aIncumbentGlobal)
373 0 : : CallbackFunction(aCx, aCallback, aIncumbentGlobal)
374 : {
375 0 : MOZ_ASSERT(JS::IsCallable(mCallback));
376 0 : }
377 :
378 : explicit inline InstallTriggerCallback(JS::Handle<JSObject*> aCallback, const FastCallbackConstructor& )
379 : : CallbackFunction(aCallback, FastCallbackConstructor())
380 : {
381 : MOZ_ASSERT(JS::IsCallable(mCallback));
382 : }
383 :
384 : explicit inline InstallTriggerCallback(JS::Handle<JSObject*> aCallback, JS::Handle<JSObject*> aAsyncStack, nsIGlobalObject* aIncumbentGlobal)
385 : : CallbackFunction(aCallback, aAsyncStack, aIncumbentGlobal)
386 : {
387 : MOZ_ASSERT(JS::IsCallable(mCallback));
388 : }
389 :
390 : explicit inline InstallTriggerCallback(CallbackFunction* aOther)
391 : : CallbackFunction(aOther)
392 : {
393 : }
394 :
395 : template <typename T>
396 : inline void
397 : Call(const T& thisVal, const nsAString& url, int16_t status, ErrorResult& aRv, const char* aExecutionReason = nullptr, ExceptionHandling aExceptionHandling = eReportExceptions, JSCompartment* aCompartment = nullptr)
398 : {
399 : MOZ_ASSERT(!aRv.Failed(), "Don't pass an already-failed ErrorResult to a callback!");
400 : if (!aExecutionReason) {
401 : aExecutionReason = "InstallTriggerCallback";
402 : }
403 : CallSetup s(this, aRv, aExecutionReason, aExceptionHandling, aCompartment);
404 : if (!s.GetContext()) {
405 : MOZ_ASSERT(aRv.Failed());
406 : return;
407 : }
408 : JS::Rooted<JS::Value> thisValJS(s.GetContext());
409 : if (!ToJSValue(s.GetContext(), thisVal, &thisValJS)) {
410 : aRv.Throw(NS_ERROR_FAILURE);
411 : return;
412 : }
413 : return Call(s.GetContext(), thisValJS, url, status, aRv);
414 : }
415 :
416 : inline void
417 : Call(const nsAString& url, int16_t status, ErrorResult& aRv, const char* aExecutionReason = nullptr, ExceptionHandling aExceptionHandling = eReportExceptions, JSCompartment* aCompartment = nullptr)
418 : {
419 : MOZ_ASSERT(!aRv.Failed(), "Don't pass an already-failed ErrorResult to a callback!");
420 : if (!aExecutionReason) {
421 : aExecutionReason = "InstallTriggerCallback";
422 : }
423 : CallSetup s(this, aRv, aExecutionReason, aExceptionHandling, aCompartment);
424 : if (!s.GetContext()) {
425 : MOZ_ASSERT(aRv.Failed());
426 : return;
427 : }
428 : return Call(s.GetContext(), JS::UndefinedHandleValue, url, status, aRv);
429 : }
430 :
431 : template <typename T>
432 : inline void
433 : Call(const T& thisVal, const nsAString& url, int16_t status, const char* aExecutionReason = nullptr)
434 : {
435 : IgnoredErrorResult rv;
436 : return Call(thisVal, url, status, rv, aExecutionReason);
437 : }
438 :
439 : inline void
440 : Call(const nsAString& url, int16_t status, const char* aExecutionReason = nullptr)
441 : {
442 : IgnoredErrorResult rv;
443 : return Call(url, status, rv, aExecutionReason, eReportExceptions, nullptr);
444 : }
445 :
446 : inline bool
447 : operator==(const InstallTriggerCallback& aOther) const
448 : {
449 : return CallbackFunction::operator==(aOther);
450 : }
451 :
452 : private:
453 : void Call(JSContext* cx, JS::Handle<JS::Value> aThisVal, const nsAString& url, int16_t status, ErrorResult& aRv);
454 : };
455 :
456 :
457 : namespace binding_detail {
458 : class FastInstallTriggerCallback : public InstallTriggerCallback
459 : {
460 : public:
461 : explicit inline FastInstallTriggerCallback(JS::Handle<JSObject*> aCallback)
462 : : InstallTriggerCallback(aCallback, FastCallbackConstructor())
463 : {
464 : }
465 :
466 : inline void
467 : Trace(JSTracer* aTracer)
468 : {
469 : InstallTriggerCallback::Trace(aTracer);
470 : }
471 :
472 : inline void
473 : FinishSlowJSInitIfMoreThanOneOwner(JSContext* aCx)
474 : {
475 : InstallTriggerCallback::FinishSlowJSInitIfMoreThanOneOwner(aCx);
476 : }
477 : };
478 : } // namespace binding_detail
479 :
480 :
481 : namespace InstallTriggerImplBinding {
482 :
483 : typedef mozilla::dom::InstallTriggerImpl NativeType;
484 :
485 : bool
486 : ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj);
487 :
488 : JSObject*
489 : DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal);
490 :
491 : const JSClass*
492 : GetJSClass();
493 :
494 : bool
495 : Wrap(JSContext* aCx, mozilla::dom::InstallTriggerImpl* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector);
496 :
497 : template <class T>
498 0 : inline JSObject* Wrap(JSContext* aCx, T* aObject, JS::Handle<JSObject*> aGivenProto)
499 : {
500 0 : JS::Rooted<JSObject*> reflector(aCx);
501 0 : return Wrap(aCx, aObject, aObject, aGivenProto, &reflector) ? reflector.get() : nullptr;
502 : }
503 :
504 : // We declare this as an array so that retrieving a pointer to this
505 : // binding's property hooks only requires compile/link-time resolvable
506 : // address arithmetic. Declaring it as a pointer instead would require
507 : // doing a run-time load to fetch a pointer to this binding's property
508 : // hooks. And then structures which embedded a pointer to this structure
509 : // would require a run-time load for proper initialization, which would
510 : // then induce static constructors. Lots of static constructors.
511 : extern const NativePropertyHooks sNativePropertyHooks[];
512 :
513 : void
514 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal);
515 :
516 : JS::Handle<JSObject*>
517 : GetProtoObjectHandle(JSContext* aCx);
518 :
519 : JS::Handle<JSObject*>
520 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal = true);
521 :
522 : JSObject*
523 : GetConstructorObject(JSContext* aCx);
524 :
525 : } // namespace InstallTriggerImplBinding
526 :
527 :
528 :
529 0 : class InstallTriggerImplJSImpl : public CallbackInterface
530 : {
531 : public:
532 0 : explicit inline InstallTriggerImplJSImpl(JSContext* aCx, JS::Handle<JSObject*> aCallback, nsIGlobalObject* aIncumbentGlobal)
533 0 : : CallbackInterface(aCx, aCallback, aIncumbentGlobal)
534 : {
535 0 : }
536 :
537 : explicit inline InstallTriggerImplJSImpl(JS::Handle<JSObject*> aCallback, const FastCallbackConstructor& )
538 : : CallbackInterface(aCallback, FastCallbackConstructor())
539 : {
540 : }
541 :
542 : explicit inline InstallTriggerImplJSImpl(JS::Handle<JSObject*> aCallback, JS::Handle<JSObject*> aAsyncStack, nsIGlobalObject* aIncumbentGlobal)
543 : : CallbackInterface(aCallback, aAsyncStack, aIncumbentGlobal)
544 : {
545 : }
546 :
547 : bool Enabled(ErrorResult& aRv, JSCompartment* aCompartment = nullptr);
548 :
549 : bool UpdateEnabled(ErrorResult& aRv, JSCompartment* aCompartment = nullptr);
550 :
551 : bool Install(const Record<nsString, OwningStringOrInstallTriggerData>& installs, const Optional<OwningNonNull<InstallTriggerCallback>>& callback, ErrorResult& aRv, JSCompartment* aCompartment = nullptr);
552 :
553 : bool InstallChrome(uint16_t type, const nsAString& url, const nsAString& skin, ErrorResult& aRv, JSCompartment* aCompartment = nullptr);
554 :
555 : bool StartSoftwareUpdate(const nsAString& url, const Optional<uint16_t>& flags, ErrorResult& aRv, JSCompartment* aCompartment = nullptr);
556 :
557 : inline bool
558 : operator==(const InstallTriggerImplJSImpl& aOther) const
559 : {
560 : return CallbackInterface::operator==(aOther);
561 : }
562 :
563 : private:
564 : static bool
565 : InitIds(JSContext* cx, InstallTriggerImplAtoms* atomsCache);
566 : };
567 :
568 :
569 : class InstallTriggerImpl final : public nsSupportsWeakReference,
570 : public nsWrapperCache
571 : {
572 : public:
573 : NS_DECL_CYCLE_COLLECTING_ISUPPORTS
574 0 : NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(InstallTriggerImpl)
575 :
576 : private:
577 : RefPtr<InstallTriggerImplJSImpl> mImpl;
578 : nsCOMPtr<nsISupports> mParent;
579 :
580 : public:
581 : InstallTriggerImpl(JS::Handle<JSObject*> aJSImplObject, nsIGlobalObject* aParent);
582 :
583 : private:
584 : ~InstallTriggerImpl();
585 :
586 : public:
587 : nsISupports* GetParentObject() const;
588 :
589 : virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
590 :
591 : bool Enabled(ErrorResult& aRv, JSCompartment* aCompartment = nullptr);
592 :
593 : bool UpdateEnabled(ErrorResult& aRv, JSCompartment* aCompartment = nullptr);
594 :
595 : bool Install(const Record<nsString, OwningStringOrInstallTriggerData>& installs, const Optional<OwningNonNull<InstallTriggerCallback>>& callback, ErrorResult& aRv, JSCompartment* aCompartment = nullptr);
596 :
597 : bool InstallChrome(uint16_t type, const nsAString& url, const nsAString& skin, ErrorResult& aRv, JSCompartment* aCompartment = nullptr);
598 :
599 : bool StartSoftwareUpdate(const nsAString& url, const Optional<uint16_t>& flags, ErrorResult& aRv, JSCompartment* aCompartment = nullptr);
600 :
601 : static bool
602 : _Create(JSContext* cx, unsigned argc, JS::Value* vp);
603 : };
604 :
605 :
606 : } // namespace dom
607 : } // namespace mozilla
608 :
609 : #endif // mozilla_dom_InstallTriggerBinding_h
|