/work/obj-fuzz/dist/include/mozilla/dom/NotificationBinding.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* THIS FILE IS AUTOGENERATED FROM Notification.webidl BY Codegen.py - DO NOT EDIT */ |
2 | | |
3 | | #ifndef mozilla_dom_NotificationBinding_h |
4 | | #define mozilla_dom_NotificationBinding_h |
5 | | |
6 | | #include "GeckoProfiler.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/PrototypeList.h" |
14 | | #include "mozilla/dom/ToJSValue.h" |
15 | | |
16 | | namespace mozilla { |
17 | | namespace dom { |
18 | | |
19 | | struct GetNotificationOptionsAtoms; |
20 | | struct NativePropertyHooks; |
21 | | class Notification; |
22 | | struct NotificationAtoms; |
23 | | struct NotificationBehavior; |
24 | | struct NotificationBehaviorAtoms; |
25 | | struct NotificationOptionsAtoms; |
26 | | class NotificationPermissionCallback; |
27 | | class ProtoAndIfaceCache; |
28 | | |
29 | | } // namespace dom |
30 | | } // namespace mozilla |
31 | | |
32 | | namespace mozilla { |
33 | | namespace dom { |
34 | | |
35 | | enum class NotificationPermission : uint8_t { |
36 | | Default, |
37 | | Denied, |
38 | | Granted, |
39 | | EndGuard_ |
40 | | }; |
41 | | |
42 | | namespace NotificationPermissionValues { |
43 | | extern const EnumEntry strings[4]; |
44 | | } // namespace NotificationPermissionValues |
45 | | |
46 | | bool |
47 | | ToJSValue(JSContext* aCx, NotificationPermission aArgument, JS::MutableHandle<JS::Value> aValue); |
48 | | |
49 | | |
50 | | enum class NotificationDirection : uint8_t { |
51 | | Auto, |
52 | | Ltr, |
53 | | Rtl, |
54 | | EndGuard_ |
55 | | }; |
56 | | |
57 | | namespace NotificationDirectionValues { |
58 | | extern const EnumEntry strings[4]; |
59 | | } // namespace NotificationDirectionValues |
60 | | |
61 | | bool |
62 | | ToJSValue(JSContext* aCx, NotificationDirection aArgument, JS::MutableHandle<JS::Value> aValue); |
63 | | |
64 | | |
65 | | struct GetNotificationOptions : public DictionaryBase |
66 | | { |
67 | | MOZ_INIT_OUTSIDE_CTOR nsString mTag; |
68 | | |
69 | | GetNotificationOptions(); |
70 | | |
71 | | explicit inline GetNotificationOptions(const FastDictionaryInitializer& ) |
72 | 0 | { |
73 | 0 | // Do nothing here; this is used by our "Fast" subclass |
74 | 0 | } |
75 | | |
76 | | explicit inline GetNotificationOptions(const GetNotificationOptions& aOther) |
77 | 0 | { |
78 | 0 | *this = aOther; |
79 | 0 | } |
80 | | |
81 | | bool |
82 | | Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false); |
83 | | |
84 | | bool |
85 | | Init(const nsAString& aJSON); |
86 | | |
87 | | bool |
88 | | ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const; |
89 | | |
90 | | bool |
91 | | ToJSON(nsAString& aJSON) const; |
92 | | |
93 | | void |
94 | | TraceDictionary(JSTracer* trc); |
95 | | |
96 | | GetNotificationOptions& |
97 | | operator=(const GetNotificationOptions& aOther); |
98 | | |
99 | | private: |
100 | | static bool |
101 | | InitIds(JSContext* cx, GetNotificationOptionsAtoms* atomsCache); |
102 | | }; |
103 | | |
104 | | namespace binding_detail { |
105 | | struct FastGetNotificationOptions : public GetNotificationOptions |
106 | | { |
107 | | inline FastGetNotificationOptions() |
108 | | : GetNotificationOptions(FastDictionaryInitializer()) |
109 | 0 | { |
110 | 0 | // Doesn't matter what int we pass to the parent constructor |
111 | 0 | } |
112 | | }; |
113 | | } // namespace binding_detail |
114 | | |
115 | | |
116 | | struct NotificationBehavior : public DictionaryBase |
117 | | { |
118 | | MOZ_INIT_OUTSIDE_CTOR bool mNoclear; |
119 | | MOZ_INIT_OUTSIDE_CTOR bool mNoscreen; |
120 | | MOZ_INIT_OUTSIDE_CTOR bool mShowOnlyOnce; |
121 | | MOZ_INIT_OUTSIDE_CTOR nsString mSoundFile; |
122 | | MOZ_INIT_OUTSIDE_CTOR Optional<Sequence<uint32_t>> mVibrationPattern; |
123 | | |
124 | | NotificationBehavior(); |
125 | | |
126 | | explicit inline NotificationBehavior(const FastDictionaryInitializer& ) |
127 | 0 | { |
128 | 0 | // Do nothing here; this is used by our "Fast" subclass |
129 | 0 | } |
130 | | |
131 | | explicit inline NotificationBehavior(const NotificationBehavior& aOther) |
132 | 0 | { |
133 | 0 | *this = aOther; |
134 | 0 | } |
135 | | |
136 | | bool |
137 | | Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false); |
138 | | |
139 | | bool |
140 | | Init(const nsAString& aJSON); |
141 | | |
142 | | bool |
143 | | ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const; |
144 | | |
145 | | bool |
146 | | ToJSON(nsAString& aJSON) const; |
147 | | |
148 | | void |
149 | | TraceDictionary(JSTracer* trc); |
150 | | |
151 | | NotificationBehavior& |
152 | | operator=(const NotificationBehavior& aOther); |
153 | | |
154 | | private: |
155 | | static bool |
156 | | InitIds(JSContext* cx, NotificationBehaviorAtoms* atomsCache); |
157 | | }; |
158 | | |
159 | | namespace binding_detail { |
160 | | struct FastNotificationBehavior : public NotificationBehavior |
161 | | { |
162 | | inline FastNotificationBehavior() |
163 | | : NotificationBehavior(FastDictionaryInitializer()) |
164 | 0 | { |
165 | 0 | // Doesn't matter what int we pass to the parent constructor |
166 | 0 | } |
167 | | }; |
168 | | } // namespace binding_detail |
169 | | |
170 | | |
171 | | struct NotificationOptions : public DictionaryBase |
172 | | { |
173 | | MOZ_INIT_OUTSIDE_CTOR nsString mBody; |
174 | | MOZ_INIT_OUTSIDE_CTOR JS::Value mData; |
175 | | MOZ_INIT_OUTSIDE_CTOR NotificationDirection mDir; |
176 | | MOZ_INIT_OUTSIDE_CTOR nsString mIcon; |
177 | | MOZ_INIT_OUTSIDE_CTOR nsString mLang; |
178 | | MOZ_INIT_OUTSIDE_CTOR NotificationBehavior mMozbehavior; |
179 | | MOZ_INIT_OUTSIDE_CTOR bool mRequireInteraction; |
180 | | MOZ_INIT_OUTSIDE_CTOR nsString mTag; |
181 | | |
182 | | NotificationOptions(); |
183 | | |
184 | | explicit inline NotificationOptions(const FastDictionaryInitializer& ) |
185 | | : mData(JS::UndefinedValue()), |
186 | | mMozbehavior(FastDictionaryInitializer()) |
187 | 0 | { |
188 | 0 | // Do nothing here; this is used by our "Fast" subclass |
189 | 0 | } |
190 | | |
191 | | private: |
192 | | NotificationOptions(const NotificationOptions&) = delete; |
193 | | NotificationOptions& operator=(const NotificationOptions&) = delete; |
194 | | |
195 | | static bool |
196 | | InitIds(JSContext* cx, NotificationOptionsAtoms* atomsCache); |
197 | | |
198 | | public: |
199 | | bool |
200 | | Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false); |
201 | | |
202 | | bool |
203 | | ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const; |
204 | | |
205 | | void |
206 | | TraceDictionary(JSTracer* trc); |
207 | | }; |
208 | | |
209 | | namespace binding_detail { |
210 | | struct FastNotificationOptions : public NotificationOptions |
211 | | { |
212 | | inline FastNotificationOptions() |
213 | | : NotificationOptions(FastDictionaryInitializer()) |
214 | 0 | { |
215 | 0 | // Doesn't matter what int we pass to the parent constructor |
216 | 0 | } |
217 | | }; |
218 | | } // namespace binding_detail |
219 | | |
220 | | |
221 | | class NotificationPermissionCallback : public CallbackFunction |
222 | | { |
223 | | public: |
224 | | explicit inline NotificationPermissionCallback(JSContext* aCx, JS::Handle<JSObject*> aCallback, JS::Handle<JSObject*> aCallbackGlobal, nsIGlobalObject* aIncumbentGlobal) |
225 | | : CallbackFunction(aCx, aCallback, aCallbackGlobal, aIncumbentGlobal) |
226 | 0 | { |
227 | 0 | MOZ_ASSERT(JS::IsCallable(mCallback)); |
228 | 0 | } |
229 | | |
230 | | explicit inline NotificationPermissionCallback(JSObject* aCallback, JSObject* aCallbackGlobal, const FastCallbackConstructor& ) |
231 | | : CallbackFunction(aCallback, aCallbackGlobal, FastCallbackConstructor()) |
232 | 0 | { |
233 | 0 | MOZ_ASSERT(JS::IsCallable(mCallback)); |
234 | 0 | } |
235 | | |
236 | | explicit inline NotificationPermissionCallback(JSObject* aCallback, JSObject* aCallbackGlobal, JSObject* aAsyncStack, nsIGlobalObject* aIncumbentGlobal) |
237 | | : CallbackFunction(aCallback, aCallbackGlobal, aAsyncStack, aIncumbentGlobal) |
238 | 0 | { |
239 | 0 | MOZ_ASSERT(JS::IsCallable(mCallback)); |
240 | 0 | } |
241 | | |
242 | | explicit inline NotificationPermissionCallback(CallbackFunction* aOther) |
243 | | : CallbackFunction(aOther) |
244 | 0 | { |
245 | 0 | } |
246 | | |
247 | | template <typename T> |
248 | | inline void |
249 | | Call(const T& thisVal, NotificationPermission permission, ErrorResult& aRv, const char* aExecutionReason = nullptr, ExceptionHandling aExceptionHandling = eReportExceptions, JS::Realm* aRealm = nullptr) |
250 | | { |
251 | | MOZ_ASSERT(!aRv.Failed(), "Don't pass an already-failed ErrorResult to a callback!"); |
252 | | if (!aExecutionReason) { |
253 | | aExecutionReason = "NotificationPermissionCallback"; |
254 | | } |
255 | | CallSetup s(this, aRv, aExecutionReason, aExceptionHandling, aRealm); |
256 | | if (!s.GetContext()) { |
257 | | MOZ_ASSERT(aRv.Failed()); |
258 | | return; |
259 | | } |
260 | | JS::Rooted<JS::Value> thisValJS(s.GetContext()); |
261 | | if (!ToJSValue(s.GetContext(), thisVal, &thisValJS)) { |
262 | | aRv.Throw(NS_ERROR_FAILURE); |
263 | | return; |
264 | | } |
265 | | return Call(s.GetContext(), thisValJS, permission, aRv); |
266 | | } |
267 | | |
268 | | inline void |
269 | | Call(NotificationPermission permission, ErrorResult& aRv, const char* aExecutionReason = nullptr, ExceptionHandling aExceptionHandling = eReportExceptions, JS::Realm* aRealm = nullptr) |
270 | 0 | { |
271 | 0 | MOZ_ASSERT(!aRv.Failed(), "Don't pass an already-failed ErrorResult to a callback!"); |
272 | 0 | if (!aExecutionReason) { |
273 | 0 | aExecutionReason = "NotificationPermissionCallback"; |
274 | 0 | } |
275 | 0 | CallSetup s(this, aRv, aExecutionReason, aExceptionHandling, aRealm); |
276 | 0 | if (!s.GetContext()) { |
277 | 0 | MOZ_ASSERT(aRv.Failed()); |
278 | 0 | return; |
279 | 0 | } |
280 | 0 | return Call(s.GetContext(), JS::UndefinedHandleValue, permission, aRv); |
281 | 0 | } |
282 | | |
283 | | template <typename T> |
284 | | inline void |
285 | | Call(const T& thisVal, NotificationPermission permission, const char* aExecutionReason = nullptr) |
286 | | { |
287 | | return Call(thisVal, permission, IgnoreErrors(), aExecutionReason); |
288 | | } |
289 | | |
290 | | inline void |
291 | | Call(NotificationPermission permission, const char* aExecutionReason = nullptr) |
292 | 0 | { |
293 | 0 | return Call(permission, IgnoreErrors(), aExecutionReason, eReportExceptions, nullptr); |
294 | 0 | } |
295 | | |
296 | | inline bool |
297 | | operator==(const NotificationPermissionCallback& aOther) const |
298 | 0 | { |
299 | 0 | return CallbackFunction::operator==(aOther); |
300 | 0 | } |
301 | | |
302 | | private: |
303 | | void Call(JSContext* cx, JS::Handle<JS::Value> aThisVal, NotificationPermission permission, ErrorResult& aRv); |
304 | | }; |
305 | | |
306 | | |
307 | | namespace binding_detail { |
308 | | class FastNotificationPermissionCallback : public NotificationPermissionCallback |
309 | | { |
310 | | public: |
311 | | explicit inline FastNotificationPermissionCallback(JSObject* aCallback, JSObject* aCallbackGlobal) |
312 | | : NotificationPermissionCallback(aCallback, aCallbackGlobal, FastCallbackConstructor()) |
313 | 0 | { |
314 | 0 | } |
315 | | |
316 | | inline void |
317 | | Trace(JSTracer* aTracer) |
318 | 0 | { |
319 | 0 | NotificationPermissionCallback::Trace(aTracer); |
320 | 0 | } |
321 | | |
322 | | inline void |
323 | | FinishSlowJSInitIfMoreThanOneOwner(JSContext* aCx) |
324 | 0 | { |
325 | 0 | NotificationPermissionCallback::FinishSlowJSInitIfMoreThanOneOwner(aCx); |
326 | 0 | } |
327 | | }; |
328 | | } // namespace binding_detail |
329 | | |
330 | | |
331 | | namespace Notification_Binding { |
332 | | |
333 | | typedef mozilla::dom::Notification NativeType; |
334 | | |
335 | | bool |
336 | | ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj); |
337 | | |
338 | | const JSClass* |
339 | | GetJSClass(); |
340 | | |
341 | | bool |
342 | | Wrap(JSContext* aCx, mozilla::dom::Notification* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector); |
343 | | |
344 | | template <class T> |
345 | | inline JSObject* Wrap(JSContext* aCx, T* aObject, JS::Handle<JSObject*> aGivenProto) |
346 | 0 | { |
347 | 0 | JS::Rooted<JSObject*> reflector(aCx); |
348 | 0 | return Wrap(aCx, aObject, aObject, aGivenProto, &reflector) ? reflector.get() : nullptr; |
349 | 0 | } |
350 | | |
351 | | // We declare this as an array so that retrieving a pointer to this |
352 | | // binding's property hooks only requires compile/link-time resolvable |
353 | | // address arithmetic. Declaring it as a pointer instead would require |
354 | | // doing a run-time load to fetch a pointer to this binding's property |
355 | | // hooks. And then structures which embedded a pointer to this structure |
356 | | // would require a run-time load for proper initialization, which would |
357 | | // then induce static constructors. Lots of static constructors. |
358 | | extern const NativePropertyHooks sNativePropertyHooks[]; |
359 | | |
360 | | void |
361 | | CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal); |
362 | | |
363 | | inline JS::Handle<JSObject*> GetProtoObjectHandle(JSContext* aCx) |
364 | 0 | { |
365 | 0 | /* Get the interface prototype object for this class. This will create the |
366 | 0 | object as needed. */ |
367 | 0 | return GetPerInterfaceObjectHandle(aCx, prototypes::id::Notification, |
368 | 0 | &CreateInterfaceObjects, |
369 | 0 | /* aDefineOnGlobal = */ true); |
370 | 0 |
|
371 | 0 | } |
372 | | |
373 | | inline JS::Handle<JSObject*> GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal = true) |
374 | 0 | { |
375 | 0 | /* Get the interface object for this class. This will create the object as |
376 | 0 | needed. */ |
377 | 0 |
|
378 | 0 | return GetPerInterfaceObjectHandle(aCx, constructors::id::Notification, |
379 | 0 | &CreateInterfaceObjects, |
380 | 0 | aDefineOnGlobal); |
381 | 0 | } |
382 | | |
383 | | JSObject* |
384 | | GetConstructorObject(JSContext* aCx); |
385 | | |
386 | | } // namespace Notification_Binding |
387 | | |
388 | | |
389 | | |
390 | | } // namespace dom |
391 | | } // namespace mozilla |
392 | | |
393 | | #endif // mozilla_dom_NotificationBinding_h |