/work/obj-fuzz/dist/include/mozilla/dom/WebExtensionPolicyBinding.h
Line | Count | Source (jump to first uncovered line) |
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 "GeckoProfiler.h" |
7 | | #include "WebExtensionContentScriptBinding.h" |
8 | | #include "js/RootingAPI.h" |
9 | | #include "jspubtd.h" |
10 | | #include "mozilla/ErrorResult.h" |
11 | | #include "mozilla/dom/BindingDeclarations.h" |
12 | | #include "mozilla/dom/CallbackFunction.h" |
13 | | #include "mozilla/dom/Nullable.h" |
14 | | #include "mozilla/dom/PrototypeList.h" |
15 | | #include "mozilla/dom/ToJSValue.h" |
16 | | |
17 | | namespace mozilla { |
18 | | |
19 | | namespace dom { |
20 | | |
21 | | class MatchGlobOrString; |
22 | | class MatchPatternSetOrStringSequence; |
23 | | struct NativePropertyHooks; |
24 | | class OwningMatchGlobOrString; |
25 | | class OwningMatchPatternSetOrStringSequence; |
26 | | class ProtoAndIfaceCache; |
27 | | struct WebExtensionContentScriptInit; |
28 | | struct WebExtensionInitAtoms; |
29 | | class WebExtensionLocalizeCallback; |
30 | | |
31 | | } // namespace dom |
32 | | |
33 | | namespace extensions { |
34 | | |
35 | | class WebExtensionPolicy; |
36 | | struct WebExtensionPolicyAtoms; |
37 | | |
38 | | } // namespace extensions |
39 | | |
40 | | } // namespace mozilla |
41 | | |
42 | | namespace mozilla { |
43 | | namespace dom { |
44 | | |
45 | | struct WebExtensionInit : public DictionaryBase |
46 | | { |
47 | | MOZ_INIT_OUTSIDE_CTOR OwningMatchPatternSetOrStringSequence mAllowedOrigins; |
48 | | MOZ_INIT_OUTSIDE_CTOR Nullable<Sequence<nsString>> mBackgroundScripts; |
49 | | MOZ_INIT_OUTSIDE_CTOR nsString mBaseURL; |
50 | | MOZ_INIT_OUTSIDE_CTOR Sequence<WebExtensionContentScriptInit> mContentScripts; |
51 | | MOZ_INIT_OUTSIDE_CTOR nsString mContentSecurityPolicy; |
52 | | MOZ_INIT_OUTSIDE_CTOR nsString mId; |
53 | | MOZ_INIT_OUTSIDE_CTOR OwningNonNull<WebExtensionLocalizeCallback> mLocalizeCallback; |
54 | | MOZ_INIT_OUTSIDE_CTOR nsCString mMozExtensionHostname; |
55 | | MOZ_INIT_OUTSIDE_CTOR nsString mName; |
56 | | MOZ_INIT_OUTSIDE_CTOR Sequence<nsString> mPermissions; |
57 | | MOZ_INIT_OUTSIDE_CTOR Sequence<OwningMatchGlobOrString> mWebAccessibleResources; |
58 | | |
59 | | WebExtensionInit(); |
60 | | |
61 | | explicit inline WebExtensionInit(const FastDictionaryInitializer& ) |
62 | 0 | { |
63 | 0 | // Do nothing here; this is used by our "Fast" subclass |
64 | 0 | } |
65 | | |
66 | | private: |
67 | | WebExtensionInit(const WebExtensionInit&) = delete; |
68 | | WebExtensionInit& operator=(const WebExtensionInit&) = delete; |
69 | | |
70 | | static bool |
71 | | InitIds(JSContext* cx, WebExtensionInitAtoms* atomsCache); |
72 | | |
73 | | public: |
74 | | bool |
75 | | Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false); |
76 | | |
77 | | bool |
78 | | ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const; |
79 | | |
80 | | void |
81 | | TraceDictionary(JSTracer* trc); |
82 | | |
83 | | inline void |
84 | | TraverseForCC(nsCycleCollectionTraversalCallback& aCallback, uint32_t aFlags) |
85 | 0 | { |
86 | 0 | ImplCycleCollectionTraverse(aCallback, mAllowedOrigins, "mAllowedOrigins", aFlags); |
87 | 0 | ImplCycleCollectionTraverse(aCallback, mContentScripts, "mContentScripts", aFlags); |
88 | 0 | ImplCycleCollectionTraverse(aCallback, mLocalizeCallback, "mLocalizeCallback", aFlags); |
89 | 0 | ImplCycleCollectionTraverse(aCallback, mWebAccessibleResources, "mWebAccessibleResources", aFlags); |
90 | 0 | } |
91 | | |
92 | | inline void |
93 | | UnlinkForCC() |
94 | 0 | { |
95 | 0 | ImplCycleCollectionUnlink(mAllowedOrigins); |
96 | 0 | ImplCycleCollectionUnlink(mContentScripts); |
97 | 0 | ImplCycleCollectionUnlink(mLocalizeCallback); |
98 | 0 | ImplCycleCollectionUnlink(mWebAccessibleResources); |
99 | 0 | } |
100 | | }; |
101 | | |
102 | | namespace binding_detail { |
103 | | struct FastWebExtensionInit : public WebExtensionInit |
104 | | { |
105 | | inline FastWebExtensionInit() |
106 | | : WebExtensionInit(FastDictionaryInitializer()) |
107 | 0 | { |
108 | 0 | // Doesn't matter what int we pass to the parent constructor |
109 | 0 | } |
110 | | }; |
111 | | } // namespace binding_detail |
112 | | |
113 | | |
114 | | class WebExtensionLocalizeCallback : public CallbackFunction |
115 | | { |
116 | | public: |
117 | | explicit inline WebExtensionLocalizeCallback(JSContext* aCx, JS::Handle<JSObject*> aCallback, JS::Handle<JSObject*> aCallbackGlobal, nsIGlobalObject* aIncumbentGlobal) |
118 | | : CallbackFunction(aCx, aCallback, aCallbackGlobal, aIncumbentGlobal) |
119 | 0 | { |
120 | 0 | MOZ_ASSERT(JS::IsCallable(mCallback)); |
121 | 0 | } |
122 | | |
123 | | explicit inline WebExtensionLocalizeCallback(JSObject* aCallback, JSObject* aCallbackGlobal, const FastCallbackConstructor& ) |
124 | | : CallbackFunction(aCallback, aCallbackGlobal, FastCallbackConstructor()) |
125 | 0 | { |
126 | 0 | MOZ_ASSERT(JS::IsCallable(mCallback)); |
127 | 0 | } |
128 | | |
129 | | explicit inline WebExtensionLocalizeCallback(JSObject* aCallback, JSObject* aCallbackGlobal, JSObject* aAsyncStack, nsIGlobalObject* aIncumbentGlobal) |
130 | | : CallbackFunction(aCallback, aCallbackGlobal, aAsyncStack, aIncumbentGlobal) |
131 | 0 | { |
132 | 0 | MOZ_ASSERT(JS::IsCallable(mCallback)); |
133 | 0 | } |
134 | | |
135 | | explicit inline WebExtensionLocalizeCallback(CallbackFunction* aOther) |
136 | | : CallbackFunction(aOther) |
137 | 0 | { |
138 | 0 | } |
139 | | |
140 | | template <typename T> |
141 | | inline void |
142 | | Call(const T& thisVal, const nsAString& unlocalizedText, nsString& aRetVal, ErrorResult& aRv, const char* aExecutionReason = nullptr, ExceptionHandling aExceptionHandling = eReportExceptions, JS::Realm* aRealm = nullptr) |
143 | | { |
144 | | MOZ_ASSERT(!aRv.Failed(), "Don't pass an already-failed ErrorResult to a callback!"); |
145 | | if (!aExecutionReason) { |
146 | | aExecutionReason = "WebExtensionLocalizeCallback"; |
147 | | } |
148 | | CallSetup s(this, aRv, aExecutionReason, aExceptionHandling, aRealm); |
149 | | if (!s.GetContext()) { |
150 | | MOZ_ASSERT(aRv.Failed()); |
151 | | return; |
152 | | } |
153 | | JS::Rooted<JS::Value> thisValJS(s.GetContext()); |
154 | | if (!ToJSValue(s.GetContext(), thisVal, &thisValJS)) { |
155 | | aRv.Throw(NS_ERROR_FAILURE); |
156 | | return; |
157 | | } |
158 | | return Call(s.GetContext(), thisValJS, unlocalizedText, aRetVal, aRv); |
159 | | } |
160 | | |
161 | | inline void |
162 | | Call(const nsAString& unlocalizedText, nsString& aRetVal, ErrorResult& aRv, const char* aExecutionReason = nullptr, ExceptionHandling aExceptionHandling = eReportExceptions, JS::Realm* aRealm = nullptr) |
163 | 0 | { |
164 | 0 | MOZ_ASSERT(!aRv.Failed(), "Don't pass an already-failed ErrorResult to a callback!"); |
165 | 0 | if (!aExecutionReason) { |
166 | 0 | aExecutionReason = "WebExtensionLocalizeCallback"; |
167 | 0 | } |
168 | 0 | CallSetup s(this, aRv, aExecutionReason, aExceptionHandling, aRealm); |
169 | 0 | if (!s.GetContext()) { |
170 | 0 | MOZ_ASSERT(aRv.Failed()); |
171 | 0 | return; |
172 | 0 | } |
173 | 0 | return Call(s.GetContext(), JS::UndefinedHandleValue, unlocalizedText, aRetVal, aRv); |
174 | 0 | } |
175 | | |
176 | | template <typename T> |
177 | | inline void |
178 | | Call(const T& thisVal, const nsAString& unlocalizedText, nsString& aRetVal, const char* aExecutionReason = nullptr) |
179 | | { |
180 | | return Call(thisVal, unlocalizedText, aRetVal, IgnoreErrors(), aExecutionReason); |
181 | | } |
182 | | |
183 | | inline void |
184 | | Call(const nsAString& unlocalizedText, nsString& aRetVal, const char* aExecutionReason = nullptr) |
185 | 0 | { |
186 | 0 | return Call(unlocalizedText, aRetVal, IgnoreErrors(), aExecutionReason, eReportExceptions, nullptr); |
187 | 0 | } |
188 | | |
189 | | inline bool |
190 | | operator==(const WebExtensionLocalizeCallback& aOther) const |
191 | 0 | { |
192 | 0 | return CallbackFunction::operator==(aOther); |
193 | 0 | } |
194 | | |
195 | | private: |
196 | | void Call(JSContext* cx, JS::Handle<JS::Value> aThisVal, const nsAString& unlocalizedText, nsString& aRetVal, ErrorResult& aRv); |
197 | | }; |
198 | | |
199 | | |
200 | | namespace binding_detail { |
201 | | class FastWebExtensionLocalizeCallback : public WebExtensionLocalizeCallback |
202 | | { |
203 | | public: |
204 | | explicit inline FastWebExtensionLocalizeCallback(JSObject* aCallback, JSObject* aCallbackGlobal) |
205 | | : WebExtensionLocalizeCallback(aCallback, aCallbackGlobal, FastCallbackConstructor()) |
206 | 0 | { |
207 | 0 | } |
208 | | |
209 | | inline void |
210 | | Trace(JSTracer* aTracer) |
211 | 0 | { |
212 | 0 | WebExtensionLocalizeCallback::Trace(aTracer); |
213 | 0 | } |
214 | | |
215 | | inline void |
216 | | FinishSlowJSInitIfMoreThanOneOwner(JSContext* aCx) |
217 | 0 | { |
218 | 0 | WebExtensionLocalizeCallback::FinishSlowJSInitIfMoreThanOneOwner(aCx); |
219 | 0 | } |
220 | | }; |
221 | | } // namespace binding_detail |
222 | | |
223 | | |
224 | | namespace WebExtensionPolicy_Binding { |
225 | | |
226 | | typedef mozilla::extensions::WebExtensionPolicy NativeType; |
227 | | |
228 | | bool |
229 | | ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj); |
230 | | |
231 | | const JSClass* |
232 | | GetJSClass(); |
233 | | |
234 | | bool |
235 | | Wrap(JSContext* aCx, mozilla::extensions::WebExtensionPolicy* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector); |
236 | | |
237 | | template <class T> |
238 | | inline JSObject* Wrap(JSContext* aCx, T* aObject, JS::Handle<JSObject*> aGivenProto) |
239 | 0 | { |
240 | 0 | JS::Rooted<JSObject*> reflector(aCx); |
241 | 0 | return Wrap(aCx, aObject, aObject, aGivenProto, &reflector) ? reflector.get() : nullptr; |
242 | 0 | } |
243 | | |
244 | | void |
245 | | ClearCachedPermissionsValue(mozilla::extensions::WebExtensionPolicy* aObject); |
246 | | |
247 | | void |
248 | | ClearCachedContentScriptsValue(mozilla::extensions::WebExtensionPolicy* aObject); |
249 | | |
250 | | void |
251 | | CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal); |
252 | | |
253 | | inline JS::Handle<JSObject*> GetProtoObjectHandle(JSContext* aCx) |
254 | 0 | { |
255 | 0 | /* Get the interface prototype object for this class. This will create the |
256 | 0 | object as needed. */ |
257 | 0 | return GetPerInterfaceObjectHandle(aCx, prototypes::id::WebExtensionPolicy, |
258 | 0 | &CreateInterfaceObjects, |
259 | 0 | /* aDefineOnGlobal = */ true); |
260 | 0 |
|
261 | 0 | } |
262 | | |
263 | | inline JS::Handle<JSObject*> GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal = true) |
264 | 0 | { |
265 | 0 | /* Get the interface object for this class. This will create the object as |
266 | 0 | needed. */ |
267 | 0 |
|
268 | 0 | return GetPerInterfaceObjectHandle(aCx, constructors::id::WebExtensionPolicy, |
269 | 0 | &CreateInterfaceObjects, |
270 | 0 | aDefineOnGlobal); |
271 | 0 | } |
272 | | |
273 | | JSObject* |
274 | | GetConstructorObject(JSContext* aCx); |
275 | | |
276 | | } // namespace WebExtensionPolicy_Binding |
277 | | |
278 | | |
279 | | |
280 | | } // namespace dom |
281 | | } // namespace mozilla |
282 | | |
283 | | #endif // mozilla_dom_WebExtensionPolicyBinding_h |