Line data Source code
1 : /* THIS FILE IS AUTOGENERATED FROM AddonManager.webidl BY Codegen.py - DO NOT EDIT */
2 :
3 : #ifndef mozilla_dom_AddonManagerBinding_h
4 : #define mozilla_dom_AddonManagerBinding_h
5 :
6 : #include "js/RootingAPI.h"
7 : #include "jspubtd.h"
8 : #include "mozilla/DOMEventTargetHelper.h"
9 : #include "mozilla/ErrorResult.h"
10 : #include "mozilla/dom/BindingDeclarations.h"
11 : #include "mozilla/dom/CallbackInterface.h"
12 : #include "mozilla/dom/Nullable.h"
13 : #include "mozilla/dom/ToJSValue.h"
14 : #include "nsWeakReference.h"
15 :
16 : namespace mozilla {
17 : namespace dom {
18 :
19 : class Addon;
20 : struct AddonAtoms;
21 : class AddonInstall;
22 : struct AddonInstallAtoms;
23 : class AddonManager;
24 : struct AddonManagerAtoms;
25 : class AddonManagerPermissions;
26 : struct AddonManagerPermissionsAtoms;
27 : struct NativePropertyHooks;
28 : class Promise;
29 : class ProtoAndIfaceCache;
30 : struct addonInstallOptions;
31 : struct addonInstallOptionsAtoms;
32 :
33 : } // namespace dom
34 : } // namespace mozilla
35 :
36 : namespace mozilla {
37 : namespace dom {
38 :
39 0 : struct addonInstallOptions : public DictionaryBase
40 : {
41 : MOZ_INIT_OUTSIDE_CTOR nsString mHash;
42 : MOZ_INIT_OUTSIDE_CTOR nsString mUrl;
43 :
44 : addonInstallOptions();
45 :
46 0 : explicit inline addonInstallOptions(const FastDictionaryInitializer& )
47 0 : {
48 : // Do nothing here; this is used by our "Fast" subclass
49 0 : }
50 :
51 : explicit inline addonInstallOptions(const addonInstallOptions& aOther)
52 : {
53 : *this = aOther;
54 : }
55 :
56 : bool
57 : Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false);
58 :
59 : bool
60 : Init(const nsAString& aJSON);
61 :
62 : bool
63 : ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const;
64 :
65 : bool
66 : ToJSON(nsAString& aJSON) const;
67 :
68 : void
69 : TraceDictionary(JSTracer* trc);
70 :
71 : addonInstallOptions&
72 : operator=(const addonInstallOptions& aOther);
73 :
74 : private:
75 : static bool
76 : InitIds(JSContext* cx, addonInstallOptionsAtoms* atomsCache);
77 : };
78 :
79 : namespace binding_detail {
80 0 : struct FastaddonInstallOptions : public addonInstallOptions
81 : {
82 0 : inline FastaddonInstallOptions()
83 0 : : addonInstallOptions(FastDictionaryInitializer())
84 : {
85 : // Doesn't matter what int we pass to the parent constructor
86 0 : }
87 : };
88 : } // namespace binding_detail
89 :
90 :
91 : namespace AddonBinding {
92 :
93 : typedef mozilla::dom::Addon NativeType;
94 :
95 : bool
96 : ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj);
97 :
98 : JSObject*
99 : DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal);
100 :
101 : const JSClass*
102 : GetJSClass();
103 :
104 : bool
105 : Wrap(JSContext* aCx, mozilla::dom::Addon* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector);
106 :
107 : template <class T>
108 0 : inline JSObject* Wrap(JSContext* aCx, T* aObject, JS::Handle<JSObject*> aGivenProto)
109 : {
110 0 : JS::Rooted<JSObject*> reflector(aCx);
111 0 : return Wrap(aCx, aObject, aObject, aGivenProto, &reflector) ? reflector.get() : nullptr;
112 : }
113 :
114 : // We declare this as an array so that retrieving a pointer to this
115 : // binding's property hooks only requires compile/link-time resolvable
116 : // address arithmetic. Declaring it as a pointer instead would require
117 : // doing a run-time load to fetch a pointer to this binding's property
118 : // hooks. And then structures which embedded a pointer to this structure
119 : // would require a run-time load for proper initialization, which would
120 : // then induce static constructors. Lots of static constructors.
121 : extern const NativePropertyHooks sNativePropertyHooks[];
122 :
123 : void
124 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal);
125 :
126 : JS::Handle<JSObject*>
127 : GetProtoObjectHandle(JSContext* aCx);
128 :
129 : JS::Handle<JSObject*>
130 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal = true);
131 :
132 : JSObject*
133 : GetConstructorObject(JSContext* aCx);
134 :
135 : } // namespace AddonBinding
136 :
137 :
138 :
139 : namespace AddonInstallBinding {
140 :
141 : typedef mozilla::dom::AddonInstall NativeType;
142 :
143 : bool
144 : ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj);
145 :
146 : JSObject*
147 : DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal);
148 :
149 : const JSClass*
150 : GetJSClass();
151 :
152 : bool
153 : Wrap(JSContext* aCx, mozilla::dom::AddonInstall* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector);
154 :
155 : template <class T>
156 0 : inline JSObject* Wrap(JSContext* aCx, T* aObject, JS::Handle<JSObject*> aGivenProto)
157 : {
158 0 : JS::Rooted<JSObject*> reflector(aCx);
159 0 : return Wrap(aCx, aObject, aObject, aGivenProto, &reflector) ? reflector.get() : nullptr;
160 : }
161 :
162 : // We declare this as an array so that retrieving a pointer to this
163 : // binding's property hooks only requires compile/link-time resolvable
164 : // address arithmetic. Declaring it as a pointer instead would require
165 : // doing a run-time load to fetch a pointer to this binding's property
166 : // hooks. And then structures which embedded a pointer to this structure
167 : // would require a run-time load for proper initialization, which would
168 : // then induce static constructors. Lots of static constructors.
169 : extern const NativePropertyHooks sNativePropertyHooks[];
170 :
171 : void
172 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal);
173 :
174 : JS::Handle<JSObject*>
175 : GetProtoObjectHandle(JSContext* aCx);
176 :
177 : JS::Handle<JSObject*>
178 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal = true);
179 :
180 : JSObject*
181 : GetConstructorObject(JSContext* aCx);
182 :
183 : } // namespace AddonInstallBinding
184 :
185 :
186 :
187 : namespace AddonManagerBinding {
188 :
189 : typedef mozilla::dom::AddonManager NativeType;
190 :
191 : already_AddRefed<AddonManager>
192 : ConstructNavigatorObject(JSContext* cx, JS::Handle<JSObject*> obj, ErrorResult& aRv);
193 :
194 : bool
195 : ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj);
196 :
197 : JSObject*
198 : DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal);
199 :
200 : const JSClass*
201 : GetJSClass();
202 :
203 : bool
204 : Wrap(JSContext* aCx, mozilla::dom::AddonManager* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector);
205 :
206 : template <class T>
207 0 : inline JSObject* Wrap(JSContext* aCx, T* aObject, JS::Handle<JSObject*> aGivenProto)
208 : {
209 0 : JS::Rooted<JSObject*> reflector(aCx);
210 0 : return Wrap(aCx, aObject, aObject, aGivenProto, &reflector) ? reflector.get() : nullptr;
211 : }
212 :
213 : // We declare this as an array so that retrieving a pointer to this
214 : // binding's property hooks only requires compile/link-time resolvable
215 : // address arithmetic. Declaring it as a pointer instead would require
216 : // doing a run-time load to fetch a pointer to this binding's property
217 : // hooks. And then structures which embedded a pointer to this structure
218 : // would require a run-time load for proper initialization, which would
219 : // then induce static constructors. Lots of static constructors.
220 : extern const NativePropertyHooks sNativePropertyHooks[];
221 :
222 : void
223 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal);
224 :
225 : JS::Handle<JSObject*>
226 : GetProtoObjectHandle(JSContext* aCx);
227 :
228 : JS::Handle<JSObject*>
229 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal = true);
230 :
231 : JSObject*
232 : GetConstructorObject(JSContext* aCx);
233 :
234 : } // namespace AddonManagerBinding
235 :
236 :
237 :
238 : namespace AddonManagerPermissionsBinding {
239 :
240 : typedef mozilla::dom::AddonManagerPermissions NativeType;
241 :
242 : bool
243 : ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj);
244 :
245 : void
246 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal);
247 :
248 : JS::Handle<JSObject*>
249 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal = true);
250 :
251 : JSObject*
252 : GetConstructorObject(JSContext* aCx);
253 :
254 : } // namespace AddonManagerPermissionsBinding
255 :
256 :
257 :
258 0 : class AddonJSImpl : public CallbackInterface
259 : {
260 : public:
261 0 : explicit inline AddonJSImpl(JSContext* aCx, JS::Handle<JSObject*> aCallback, nsIGlobalObject* aIncumbentGlobal)
262 0 : : CallbackInterface(aCx, aCallback, aIncumbentGlobal)
263 : {
264 0 : }
265 :
266 : explicit inline AddonJSImpl(JS::Handle<JSObject*> aCallback, const FastCallbackConstructor& )
267 : : CallbackInterface(aCallback, FastCallbackConstructor())
268 : {
269 : }
270 :
271 : explicit inline AddonJSImpl(JS::Handle<JSObject*> aCallback, JS::Handle<JSObject*> aAsyncStack, nsIGlobalObject* aIncumbentGlobal)
272 : : CallbackInterface(aCallback, aAsyncStack, aIncumbentGlobal)
273 : {
274 : }
275 :
276 : already_AddRefed<Promise> Uninstall(ErrorResult& aRv, JSCompartment* aCompartment = nullptr);
277 :
278 : already_AddRefed<Promise> SetEnabled(bool value, ErrorResult& aRv, JSCompartment* aCompartment = nullptr);
279 :
280 : inline bool
281 : operator==(const AddonJSImpl& aOther) const
282 : {
283 : return CallbackInterface::operator==(aOther);
284 : }
285 :
286 : void GetId(nsString& aRetVal, ErrorResult& aRv, JSCompartment* aCompartment = nullptr);
287 :
288 : void GetVersion(nsString& aRetVal, ErrorResult& aRv, JSCompartment* aCompartment = nullptr);
289 :
290 : void GetType(nsString& aRetVal, ErrorResult& aRv, JSCompartment* aCompartment = nullptr);
291 :
292 : void GetName(nsString& aRetVal, ErrorResult& aRv, JSCompartment* aCompartment = nullptr);
293 :
294 : void GetDescription(nsString& aRetVal, ErrorResult& aRv, JSCompartment* aCompartment = nullptr);
295 :
296 : bool GetIsEnabled(ErrorResult& aRv, JSCompartment* aCompartment = nullptr);
297 :
298 : bool GetIsActive(ErrorResult& aRv, JSCompartment* aCompartment = nullptr);
299 :
300 : bool GetCanUninstall(ErrorResult& aRv, JSCompartment* aCompartment = nullptr);
301 :
302 : private:
303 : static bool
304 : InitIds(JSContext* cx, AddonAtoms* atomsCache);
305 : };
306 :
307 :
308 : class Addon final : public nsSupportsWeakReference,
309 : public nsWrapperCache
310 : {
311 : public:
312 : NS_DECL_CYCLE_COLLECTING_ISUPPORTS
313 0 : NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(Addon)
314 :
315 : private:
316 : RefPtr<AddonJSImpl> mImpl;
317 : nsCOMPtr<nsISupports> mParent;
318 :
319 : public:
320 : Addon(JS::Handle<JSObject*> aJSImplObject, nsIGlobalObject* aParent);
321 :
322 : private:
323 : ~Addon();
324 :
325 : public:
326 : nsISupports* GetParentObject() const;
327 :
328 : virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
329 :
330 : void GetId(nsString& aRetVal, ErrorResult& aRv, JSCompartment* aCompartment = nullptr) const;
331 :
332 : void GetVersion(nsString& aRetVal, ErrorResult& aRv, JSCompartment* aCompartment = nullptr) const;
333 :
334 : void GetType(nsString& aRetVal, ErrorResult& aRv, JSCompartment* aCompartment = nullptr) const;
335 :
336 : void GetName(nsString& aRetVal, ErrorResult& aRv, JSCompartment* aCompartment = nullptr) const;
337 :
338 : void GetDescription(nsString& aRetVal, ErrorResult& aRv, JSCompartment* aCompartment = nullptr) const;
339 :
340 : bool GetIsEnabled(ErrorResult& aRv, JSCompartment* aCompartment = nullptr) const;
341 :
342 : bool GetIsActive(ErrorResult& aRv, JSCompartment* aCompartment = nullptr) const;
343 :
344 : bool GetCanUninstall(ErrorResult& aRv, JSCompartment* aCompartment = nullptr) const;
345 :
346 : // Return a raw pointer here to avoid refcounting, but make sure it's safe (the object should be kept alive by the callee).
347 : already_AddRefed<Promise> Uninstall(ErrorResult& aRv, JSCompartment* aCompartment = nullptr);
348 :
349 : // Return a raw pointer here to avoid refcounting, but make sure it's safe (the object should be kept alive by the callee).
350 : already_AddRefed<Promise> SetEnabled(bool value, ErrorResult& aRv, JSCompartment* aCompartment = nullptr);
351 :
352 : static bool
353 : _Create(JSContext* cx, unsigned argc, JS::Value* vp);
354 : };
355 :
356 :
357 0 : class AddonInstallJSImpl : public CallbackInterface
358 : {
359 : public:
360 0 : explicit inline AddonInstallJSImpl(JSContext* aCx, JS::Handle<JSObject*> aCallback, nsIGlobalObject* aIncumbentGlobal)
361 0 : : CallbackInterface(aCx, aCallback, aIncumbentGlobal)
362 : {
363 0 : }
364 :
365 : explicit inline AddonInstallJSImpl(JS::Handle<JSObject*> aCallback, const FastCallbackConstructor& )
366 : : CallbackInterface(aCallback, FastCallbackConstructor())
367 : {
368 : }
369 :
370 : explicit inline AddonInstallJSImpl(JS::Handle<JSObject*> aCallback, JS::Handle<JSObject*> aAsyncStack, nsIGlobalObject* aIncumbentGlobal)
371 : : CallbackInterface(aCallback, aAsyncStack, aIncumbentGlobal)
372 : {
373 : }
374 :
375 : already_AddRefed<Promise> Install(ErrorResult& aRv, JSCompartment* aCompartment = nullptr);
376 :
377 : already_AddRefed<Promise> Cancel(ErrorResult& aRv, JSCompartment* aCompartment = nullptr);
378 :
379 : inline bool
380 : operator==(const AddonInstallJSImpl& aOther) const
381 : {
382 : return CallbackInterface::operator==(aOther);
383 : }
384 :
385 : void GetState(nsString& aRetVal, ErrorResult& aRv, JSCompartment* aCompartment = nullptr);
386 :
387 : void GetError(nsString& aRetVal, ErrorResult& aRv, JSCompartment* aCompartment = nullptr);
388 :
389 : int64_t GetProgress(ErrorResult& aRv, JSCompartment* aCompartment = nullptr);
390 :
391 : int64_t GetMaxProgress(ErrorResult& aRv, JSCompartment* aCompartment = nullptr);
392 :
393 : private:
394 : static bool
395 : InitIds(JSContext* cx, AddonInstallAtoms* atomsCache);
396 : };
397 :
398 :
399 : class AddonInstall final : public mozilla::DOMEventTargetHelper
400 : {
401 : public:
402 : NS_DECL_ISUPPORTS_INHERITED
403 0 : NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(AddonInstall, mozilla::DOMEventTargetHelper)
404 :
405 : private:
406 : RefPtr<AddonInstallJSImpl> mImpl;
407 : nsCOMPtr<nsISupports> mParent;
408 :
409 : public:
410 : AddonInstall(JS::Handle<JSObject*> aJSImplObject, nsIGlobalObject* aParent);
411 :
412 : private:
413 : ~AddonInstall();
414 :
415 : public:
416 : nsISupports* GetParentObject() const;
417 :
418 : virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
419 :
420 : void GetState(nsString& aRetVal, ErrorResult& aRv, JSCompartment* aCompartment = nullptr) const;
421 :
422 : void GetError(nsString& aRetVal, ErrorResult& aRv, JSCompartment* aCompartment = nullptr) const;
423 :
424 : int64_t GetProgress(ErrorResult& aRv, JSCompartment* aCompartment = nullptr) const;
425 :
426 : int64_t GetMaxProgress(ErrorResult& aRv, JSCompartment* aCompartment = nullptr) const;
427 :
428 : // Return a raw pointer here to avoid refcounting, but make sure it's safe (the object should be kept alive by the callee).
429 : already_AddRefed<Promise> Install(ErrorResult& aRv, JSCompartment* aCompartment = nullptr);
430 :
431 : // Return a raw pointer here to avoid refcounting, but make sure it's safe (the object should be kept alive by the callee).
432 : already_AddRefed<Promise> Cancel(ErrorResult& aRv, JSCompartment* aCompartment = nullptr);
433 :
434 : static bool
435 : _Create(JSContext* cx, unsigned argc, JS::Value* vp);
436 : };
437 :
438 :
439 0 : class AddonManagerJSImpl : public CallbackInterface
440 : {
441 : public:
442 0 : explicit inline AddonManagerJSImpl(JSContext* aCx, JS::Handle<JSObject*> aCallback, nsIGlobalObject* aIncumbentGlobal)
443 0 : : CallbackInterface(aCx, aCallback, aIncumbentGlobal)
444 : {
445 0 : }
446 :
447 : explicit inline AddonManagerJSImpl(JS::Handle<JSObject*> aCallback, const FastCallbackConstructor& )
448 : : CallbackInterface(aCallback, FastCallbackConstructor())
449 : {
450 : }
451 :
452 : explicit inline AddonManagerJSImpl(JS::Handle<JSObject*> aCallback, JS::Handle<JSObject*> aAsyncStack, nsIGlobalObject* aIncumbentGlobal)
453 : : CallbackInterface(aCallback, aAsyncStack, aIncumbentGlobal)
454 : {
455 : }
456 :
457 : already_AddRefed<Promise> GetAddonByID(const nsAString& id, ErrorResult& aRv, JSCompartment* aCompartment = nullptr);
458 :
459 : already_AddRefed<Promise> CreateInstall(const addonInstallOptions& options, ErrorResult& aRv, JSCompartment* aCompartment = nullptr);
460 :
461 : void EventListenerWasAdded(const nsAString& type, ErrorResult& aRv, JSCompartment* aCompartment = nullptr);
462 :
463 : void EventListenerWasRemoved(const nsAString& type, ErrorResult& aRv, JSCompartment* aCompartment = nullptr);
464 :
465 : inline bool
466 : operator==(const AddonManagerJSImpl& aOther) const
467 : {
468 : return CallbackInterface::operator==(aOther);
469 : }
470 :
471 : bool GetPermissionPromptsEnabled(ErrorResult& aRv, JSCompartment* aCompartment = nullptr);
472 :
473 : private:
474 : static bool
475 : InitIds(JSContext* cx, AddonManagerAtoms* atomsCache);
476 : };
477 :
478 :
479 : class AddonManager final : public mozilla::DOMEventTargetHelper
480 : {
481 : public:
482 : NS_DECL_ISUPPORTS_INHERITED
483 0 : NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(AddonManager, mozilla::DOMEventTargetHelper)
484 :
485 : private:
486 : RefPtr<AddonManagerJSImpl> mImpl;
487 : nsCOMPtr<nsISupports> mParent;
488 :
489 : public:
490 : AddonManager(JS::Handle<JSObject*> aJSImplObject, nsIGlobalObject* aParent);
491 :
492 : private:
493 : ~AddonManager();
494 :
495 : public:
496 : nsISupports* GetParentObject() const;
497 :
498 : virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
499 :
500 : // Return a raw pointer here to avoid refcounting, but make sure it's safe (the object should be kept alive by the callee).
501 : already_AddRefed<Promise> GetAddonByID(const nsAString& id, ErrorResult& aRv, JSCompartment* aCompartment = nullptr);
502 :
503 : // Return a raw pointer here to avoid refcounting, but make sure it's safe (the object should be kept alive by the callee).
504 : already_AddRefed<Promise> CreateInstall(const addonInstallOptions& options, ErrorResult& aRv, JSCompartment* aCompartment = nullptr);
505 :
506 : bool GetPermissionPromptsEnabled(ErrorResult& aRv, JSCompartment* aCompartment = nullptr) const;
507 :
508 : virtual void EventListenerWasAdded(const nsAString& type, ErrorResult& aRv, JSCompartment* aCompartment = nullptr) override;
509 :
510 : virtual void EventListenerWasRemoved(const nsAString& type, ErrorResult& aRv, JSCompartment* aCompartment = nullptr) override;
511 :
512 : static bool
513 : _Create(JSContext* cx, unsigned argc, JS::Value* vp);
514 : };
515 :
516 :
517 : } // namespace dom
518 : } // namespace mozilla
519 :
520 : #endif // mozilla_dom_AddonManagerBinding_h
|