Line data Source code
1 : /* THIS FILE IS AUTOGENERATED FROM WebExtensionPolicy.webidl BY Codegen.py - DO NOT EDIT */
2 :
3 : #ifndef mozilla_dom_WebExtensionPolicyBinding_h
4 : #define mozilla_dom_WebExtensionPolicyBinding_h
5 :
6 : #include "WebExtensionContentScriptBinding.h"
7 : #include "js/RootingAPI.h"
8 : #include "jspubtd.h"
9 : #include "mozilla/ErrorResult.h"
10 : #include "mozilla/dom/BindingDeclarations.h"
11 : #include "mozilla/dom/CallbackFunction.h"
12 : #include "mozilla/dom/Nullable.h"
13 : #include "mozilla/dom/ToJSValue.h"
14 : #include "mozilla/extensions/MatchGlob.h"
15 : #include "mozilla/extensions/MatchPattern.h"
16 :
17 : namespace mozilla {
18 :
19 : namespace dom {
20 :
21 : struct NativePropertyHooks;
22 : class ProtoAndIfaceCache;
23 : struct WebExtensionContentScriptInit;
24 : struct WebExtensionInitAtoms;
25 : class WebExtensionLocalizeCallback;
26 :
27 : } // namespace dom
28 :
29 : namespace extensions {
30 :
31 : class MatchGlob;
32 : class MatchPatternSet;
33 : class WebExtensionPolicy;
34 : struct WebExtensionPolicyAtoms;
35 :
36 : } // namespace extensions
37 :
38 : } // namespace mozilla
39 :
40 : namespace mozilla {
41 : namespace dom {
42 :
43 0 : struct WebExtensionInit : public DictionaryBase
44 : {
45 : MOZ_INIT_OUTSIDE_CTOR OwningNonNull<mozilla::extensions::MatchPatternSet> mAllowedOrigins;
46 : MOZ_INIT_OUTSIDE_CTOR Nullable<Sequence<nsString>> mBackgroundScripts;
47 : MOZ_INIT_OUTSIDE_CTOR nsString mBaseURL;
48 : MOZ_INIT_OUTSIDE_CTOR Sequence<WebExtensionContentScriptInit> mContentScripts;
49 : MOZ_INIT_OUTSIDE_CTOR nsString mContentSecurityPolicy;
50 : MOZ_INIT_OUTSIDE_CTOR nsString mId;
51 : MOZ_INIT_OUTSIDE_CTOR OwningNonNull<WebExtensionLocalizeCallback> mLocalizeCallback;
52 : MOZ_INIT_OUTSIDE_CTOR nsCString mMozExtensionHostname;
53 : MOZ_INIT_OUTSIDE_CTOR Sequence<nsString> mPermissions;
54 : MOZ_INIT_OUTSIDE_CTOR Sequence<OwningNonNull<mozilla::extensions::MatchGlob>> mWebAccessibleResources;
55 :
56 : WebExtensionInit();
57 :
58 0 : explicit inline WebExtensionInit(const FastDictionaryInitializer& )
59 0 : {
60 : // Do nothing here; this is used by our "Fast" subclass
61 0 : }
62 :
63 : private:
64 : WebExtensionInit(const WebExtensionInit&) = delete;
65 : WebExtensionInit& operator=(const WebExtensionInit&) = delete;
66 :
67 : static bool
68 : InitIds(JSContext* cx, WebExtensionInitAtoms* atomsCache);
69 :
70 : public:
71 : bool
72 : Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false);
73 :
74 : bool
75 : ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const;
76 :
77 : void
78 : TraceDictionary(JSTracer* trc);
79 : };
80 :
81 : namespace binding_detail {
82 0 : struct FastWebExtensionInit : public WebExtensionInit
83 : {
84 0 : inline FastWebExtensionInit()
85 0 : : WebExtensionInit(FastDictionaryInitializer())
86 : {
87 : // Doesn't matter what int we pass to the parent constructor
88 0 : }
89 : };
90 : } // namespace binding_detail
91 :
92 :
93 0 : class WebExtensionLocalizeCallback : public CallbackFunction
94 : {
95 : public:
96 0 : explicit inline WebExtensionLocalizeCallback(JSContext* aCx, JS::Handle<JSObject*> aCallback, nsIGlobalObject* aIncumbentGlobal)
97 0 : : CallbackFunction(aCx, aCallback, aIncumbentGlobal)
98 : {
99 0 : MOZ_ASSERT(JS::IsCallable(mCallback));
100 0 : }
101 :
102 : explicit inline WebExtensionLocalizeCallback(JS::Handle<JSObject*> aCallback, const FastCallbackConstructor& )
103 : : CallbackFunction(aCallback, FastCallbackConstructor())
104 : {
105 : MOZ_ASSERT(JS::IsCallable(mCallback));
106 : }
107 :
108 : explicit inline WebExtensionLocalizeCallback(JS::Handle<JSObject*> aCallback, JS::Handle<JSObject*> aAsyncStack, nsIGlobalObject* aIncumbentGlobal)
109 : : CallbackFunction(aCallback, aAsyncStack, aIncumbentGlobal)
110 : {
111 : MOZ_ASSERT(JS::IsCallable(mCallback));
112 : }
113 :
114 : explicit inline WebExtensionLocalizeCallback(CallbackFunction* aOther)
115 : : CallbackFunction(aOther)
116 : {
117 : }
118 :
119 : template <typename T>
120 : inline void
121 : Call(const T& thisVal, const nsAString& unlocalizedText, nsString& aRetVal, ErrorResult& aRv, const char* aExecutionReason = nullptr, ExceptionHandling aExceptionHandling = eReportExceptions, JSCompartment* aCompartment = nullptr)
122 : {
123 : MOZ_ASSERT(!aRv.Failed(), "Don't pass an already-failed ErrorResult to a callback!");
124 : if (!aExecutionReason) {
125 : aExecutionReason = "WebExtensionLocalizeCallback";
126 : }
127 : CallSetup s(this, aRv, aExecutionReason, aExceptionHandling, aCompartment);
128 : if (!s.GetContext()) {
129 : MOZ_ASSERT(aRv.Failed());
130 : return;
131 : }
132 : JS::Rooted<JS::Value> thisValJS(s.GetContext());
133 : if (!ToJSValue(s.GetContext(), thisVal, &thisValJS)) {
134 : aRv.Throw(NS_ERROR_FAILURE);
135 : return;
136 : }
137 : return Call(s.GetContext(), thisValJS, unlocalizedText, aRetVal, aRv);
138 : }
139 :
140 : inline void
141 0 : Call(const nsAString& unlocalizedText, nsString& aRetVal, ErrorResult& aRv, const char* aExecutionReason = nullptr, ExceptionHandling aExceptionHandling = eReportExceptions, JSCompartment* aCompartment = nullptr)
142 : {
143 0 : MOZ_ASSERT(!aRv.Failed(), "Don't pass an already-failed ErrorResult to a callback!");
144 0 : if (!aExecutionReason) {
145 0 : aExecutionReason = "WebExtensionLocalizeCallback";
146 : }
147 0 : CallSetup s(this, aRv, aExecutionReason, aExceptionHandling, aCompartment);
148 0 : if (!s.GetContext()) {
149 0 : MOZ_ASSERT(aRv.Failed());
150 0 : return;
151 : }
152 0 : return Call(s.GetContext(), JS::UndefinedHandleValue, unlocalizedText, aRetVal, aRv);
153 : }
154 :
155 : template <typename T>
156 : inline void
157 : Call(const T& thisVal, const nsAString& unlocalizedText, nsString& aRetVal, const char* aExecutionReason = nullptr)
158 : {
159 : IgnoredErrorResult rv;
160 : return Call(thisVal, unlocalizedText, aRetVal, rv, aExecutionReason);
161 : }
162 :
163 : inline void
164 0 : Call(const nsAString& unlocalizedText, nsString& aRetVal, const char* aExecutionReason = nullptr)
165 : {
166 0 : IgnoredErrorResult rv;
167 0 : return Call(unlocalizedText, aRetVal, rv, aExecutionReason, eReportExceptions, nullptr);
168 : }
169 :
170 : inline bool
171 : operator==(const WebExtensionLocalizeCallback& aOther) const
172 : {
173 : return CallbackFunction::operator==(aOther);
174 : }
175 :
176 : private:
177 : void Call(JSContext* cx, JS::Handle<JS::Value> aThisVal, const nsAString& unlocalizedText, nsString& aRetVal, ErrorResult& aRv);
178 : };
179 :
180 :
181 : namespace binding_detail {
182 : class FastWebExtensionLocalizeCallback : public WebExtensionLocalizeCallback
183 : {
184 : public:
185 : explicit inline FastWebExtensionLocalizeCallback(JS::Handle<JSObject*> aCallback)
186 : : WebExtensionLocalizeCallback(aCallback, FastCallbackConstructor())
187 : {
188 : }
189 :
190 : inline void
191 : Trace(JSTracer* aTracer)
192 : {
193 : WebExtensionLocalizeCallback::Trace(aTracer);
194 : }
195 :
196 : inline void
197 : FinishSlowJSInitIfMoreThanOneOwner(JSContext* aCx)
198 : {
199 : WebExtensionLocalizeCallback::FinishSlowJSInitIfMoreThanOneOwner(aCx);
200 : }
201 : };
202 : } // namespace binding_detail
203 :
204 :
205 : namespace WebExtensionPolicyBinding {
206 :
207 : typedef mozilla::extensions::WebExtensionPolicy NativeType;
208 :
209 : bool
210 : ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj);
211 :
212 : const JSClass*
213 : GetJSClass();
214 :
215 : bool
216 : Wrap(JSContext* aCx, mozilla::extensions::WebExtensionPolicy* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector);
217 :
218 : template <class T>
219 0 : inline JSObject* Wrap(JSContext* aCx, T* aObject, JS::Handle<JSObject*> aGivenProto)
220 : {
221 0 : JS::Rooted<JSObject*> reflector(aCx);
222 0 : return Wrap(aCx, aObject, aObject, aGivenProto, &reflector) ? reflector.get() : nullptr;
223 : }
224 :
225 : void
226 : ClearCachedPermissionsValue(mozilla::extensions::WebExtensionPolicy* aObject);
227 :
228 : void
229 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal);
230 :
231 : JS::Handle<JSObject*>
232 : GetProtoObjectHandle(JSContext* aCx);
233 :
234 : JS::Handle<JSObject*>
235 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal = true);
236 :
237 : JSObject*
238 : GetConstructorObject(JSContext* aCx);
239 :
240 : } // namespace WebExtensionPolicyBinding
241 :
242 :
243 :
244 : } // namespace dom
245 : } // namespace mozilla
246 :
247 : #endif // mozilla_dom_WebExtensionPolicyBinding_h
|