Line data Source code
1 : /* THIS FILE IS AUTOGENERATED FROM Navigator.webidl BY Codegen.py - DO NOT EDIT */
2 :
3 : #ifndef mozilla_dom_NavigatorBinding_h
4 : #define mozilla_dom_NavigatorBinding_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/Nullable.h"
13 : #include "mozilla/dom/ToJSValue.h"
14 :
15 : class nsIVariant;
16 :
17 : namespace mozilla {
18 :
19 : class DOMMediaStream;
20 :
21 : namespace dom {
22 :
23 : class MediaStreamError;
24 : class MozGetUserMediaDevicesSuccessCallback;
25 : class MozIdleObserver;
26 : struct MozIdleObserverAtoms;
27 : struct NativePropertyHooks;
28 : class Navigator;
29 : struct NavigatorAtoms;
30 : class NavigatorUserMediaErrorCallback;
31 : class NavigatorUserMediaSuccessCallback;
32 : class ProtoAndIfaceCache;
33 :
34 : } // namespace dom
35 :
36 : } // namespace mozilla
37 :
38 : namespace mozilla {
39 : namespace dom {
40 :
41 0 : class NavigatorUserMediaSuccessCallback : public CallbackFunction
42 : {
43 : public:
44 : explicit inline NavigatorUserMediaSuccessCallback(JSContext* aCx, JS::Handle<JSObject*> aCallback, nsIGlobalObject* aIncumbentGlobal)
45 : : CallbackFunction(aCx, aCallback, aIncumbentGlobal)
46 : {
47 : MOZ_ASSERT(JS::IsCallable(mCallback));
48 : }
49 :
50 0 : explicit inline NavigatorUserMediaSuccessCallback(JS::Handle<JSObject*> aCallback, const FastCallbackConstructor& )
51 0 : : CallbackFunction(aCallback, FastCallbackConstructor())
52 : {
53 0 : MOZ_ASSERT(JS::IsCallable(mCallback));
54 0 : }
55 :
56 : explicit inline NavigatorUserMediaSuccessCallback(JS::Handle<JSObject*> aCallback, JS::Handle<JSObject*> aAsyncStack, nsIGlobalObject* aIncumbentGlobal)
57 : : CallbackFunction(aCallback, aAsyncStack, aIncumbentGlobal)
58 : {
59 : MOZ_ASSERT(JS::IsCallable(mCallback));
60 : }
61 :
62 : explicit inline NavigatorUserMediaSuccessCallback(CallbackFunction* aOther)
63 : : CallbackFunction(aOther)
64 : {
65 : }
66 :
67 : template <typename T>
68 : inline void
69 : Call(const T& thisVal, DOMMediaStream& stream, ErrorResult& aRv, const char* aExecutionReason = nullptr, ExceptionHandling aExceptionHandling = eReportExceptions, JSCompartment* aCompartment = nullptr)
70 : {
71 : MOZ_ASSERT(!aRv.Failed(), "Don't pass an already-failed ErrorResult to a callback!");
72 : if (!aExecutionReason) {
73 : aExecutionReason = "NavigatorUserMediaSuccessCallback";
74 : }
75 : CallSetup s(this, aRv, aExecutionReason, aExceptionHandling, aCompartment);
76 : if (!s.GetContext()) {
77 : MOZ_ASSERT(aRv.Failed());
78 : return;
79 : }
80 : JS::Rooted<JS::Value> thisValJS(s.GetContext());
81 : if (!ToJSValue(s.GetContext(), thisVal, &thisValJS)) {
82 : aRv.Throw(NS_ERROR_FAILURE);
83 : return;
84 : }
85 : return Call(s.GetContext(), thisValJS, stream, aRv);
86 : }
87 :
88 : inline void
89 : Call(DOMMediaStream& stream, ErrorResult& aRv, const char* aExecutionReason = nullptr, ExceptionHandling aExceptionHandling = eReportExceptions, JSCompartment* aCompartment = nullptr)
90 : {
91 : MOZ_ASSERT(!aRv.Failed(), "Don't pass an already-failed ErrorResult to a callback!");
92 : if (!aExecutionReason) {
93 : aExecutionReason = "NavigatorUserMediaSuccessCallback";
94 : }
95 : CallSetup s(this, aRv, aExecutionReason, aExceptionHandling, aCompartment);
96 : if (!s.GetContext()) {
97 : MOZ_ASSERT(aRv.Failed());
98 : return;
99 : }
100 : return Call(s.GetContext(), JS::UndefinedHandleValue, stream, aRv);
101 : }
102 :
103 : template <typename T>
104 : inline void
105 : Call(const T& thisVal, DOMMediaStream& stream, const char* aExecutionReason = nullptr)
106 : {
107 : IgnoredErrorResult rv;
108 : return Call(thisVal, stream, rv, aExecutionReason);
109 : }
110 :
111 : inline void
112 : Call(DOMMediaStream& stream, const char* aExecutionReason = nullptr)
113 : {
114 : IgnoredErrorResult rv;
115 : return Call(stream, rv, aExecutionReason, eReportExceptions, nullptr);
116 : }
117 :
118 : inline bool
119 : operator==(const NavigatorUserMediaSuccessCallback& aOther) const
120 : {
121 : return CallbackFunction::operator==(aOther);
122 : }
123 :
124 : private:
125 : void Call(JSContext* cx, JS::Handle<JS::Value> aThisVal, DOMMediaStream& stream, ErrorResult& aRv);
126 : };
127 :
128 :
129 0 : class NavigatorUserMediaErrorCallback : public CallbackFunction
130 : {
131 : public:
132 : explicit inline NavigatorUserMediaErrorCallback(JSContext* aCx, JS::Handle<JSObject*> aCallback, nsIGlobalObject* aIncumbentGlobal)
133 : : CallbackFunction(aCx, aCallback, aIncumbentGlobal)
134 : {
135 : MOZ_ASSERT(JS::IsCallable(mCallback));
136 : }
137 :
138 0 : explicit inline NavigatorUserMediaErrorCallback(JS::Handle<JSObject*> aCallback, const FastCallbackConstructor& )
139 0 : : CallbackFunction(aCallback, FastCallbackConstructor())
140 : {
141 0 : MOZ_ASSERT(JS::IsCallable(mCallback));
142 0 : }
143 :
144 : explicit inline NavigatorUserMediaErrorCallback(JS::Handle<JSObject*> aCallback, JS::Handle<JSObject*> aAsyncStack, nsIGlobalObject* aIncumbentGlobal)
145 : : CallbackFunction(aCallback, aAsyncStack, aIncumbentGlobal)
146 : {
147 : MOZ_ASSERT(JS::IsCallable(mCallback));
148 : }
149 :
150 : explicit inline NavigatorUserMediaErrorCallback(CallbackFunction* aOther)
151 : : CallbackFunction(aOther)
152 : {
153 : }
154 :
155 : template <typename T>
156 : inline void
157 : Call(const T& thisVal, MediaStreamError& error, ErrorResult& aRv, const char* aExecutionReason = nullptr, ExceptionHandling aExceptionHandling = eReportExceptions, JSCompartment* aCompartment = nullptr)
158 : {
159 : MOZ_ASSERT(!aRv.Failed(), "Don't pass an already-failed ErrorResult to a callback!");
160 : if (!aExecutionReason) {
161 : aExecutionReason = "NavigatorUserMediaErrorCallback";
162 : }
163 : CallSetup s(this, aRv, aExecutionReason, aExceptionHandling, aCompartment);
164 : if (!s.GetContext()) {
165 : MOZ_ASSERT(aRv.Failed());
166 : return;
167 : }
168 : JS::Rooted<JS::Value> thisValJS(s.GetContext());
169 : if (!ToJSValue(s.GetContext(), thisVal, &thisValJS)) {
170 : aRv.Throw(NS_ERROR_FAILURE);
171 : return;
172 : }
173 : return Call(s.GetContext(), thisValJS, error, aRv);
174 : }
175 :
176 : inline void
177 : Call(MediaStreamError& error, ErrorResult& aRv, const char* aExecutionReason = nullptr, ExceptionHandling aExceptionHandling = eReportExceptions, JSCompartment* aCompartment = nullptr)
178 : {
179 : MOZ_ASSERT(!aRv.Failed(), "Don't pass an already-failed ErrorResult to a callback!");
180 : if (!aExecutionReason) {
181 : aExecutionReason = "NavigatorUserMediaErrorCallback";
182 : }
183 : CallSetup s(this, aRv, aExecutionReason, aExceptionHandling, aCompartment);
184 : if (!s.GetContext()) {
185 : MOZ_ASSERT(aRv.Failed());
186 : return;
187 : }
188 : return Call(s.GetContext(), JS::UndefinedHandleValue, error, aRv);
189 : }
190 :
191 : template <typename T>
192 : inline void
193 : Call(const T& thisVal, MediaStreamError& error, const char* aExecutionReason = nullptr)
194 : {
195 : IgnoredErrorResult rv;
196 : return Call(thisVal, error, rv, aExecutionReason);
197 : }
198 :
199 : inline void
200 : Call(MediaStreamError& error, const char* aExecutionReason = nullptr)
201 : {
202 : IgnoredErrorResult rv;
203 : return Call(error, rv, aExecutionReason, eReportExceptions, nullptr);
204 : }
205 :
206 : inline bool
207 : operator==(const NavigatorUserMediaErrorCallback& aOther) const
208 : {
209 : return CallbackFunction::operator==(aOther);
210 : }
211 :
212 : private:
213 : void Call(JSContext* cx, JS::Handle<JS::Value> aThisVal, MediaStreamError& error, ErrorResult& aRv);
214 : };
215 :
216 :
217 0 : class MozGetUserMediaDevicesSuccessCallback : public CallbackFunction
218 : {
219 : public:
220 : explicit inline MozGetUserMediaDevicesSuccessCallback(JSContext* aCx, JS::Handle<JSObject*> aCallback, nsIGlobalObject* aIncumbentGlobal)
221 : : CallbackFunction(aCx, aCallback, aIncumbentGlobal)
222 : {
223 : MOZ_ASSERT(JS::IsCallable(mCallback));
224 : }
225 :
226 0 : explicit inline MozGetUserMediaDevicesSuccessCallback(JS::Handle<JSObject*> aCallback, const FastCallbackConstructor& )
227 0 : : CallbackFunction(aCallback, FastCallbackConstructor())
228 : {
229 0 : MOZ_ASSERT(JS::IsCallable(mCallback));
230 0 : }
231 :
232 : explicit inline MozGetUserMediaDevicesSuccessCallback(JS::Handle<JSObject*> aCallback, JS::Handle<JSObject*> aAsyncStack, nsIGlobalObject* aIncumbentGlobal)
233 : : CallbackFunction(aCallback, aAsyncStack, aIncumbentGlobal)
234 : {
235 : MOZ_ASSERT(JS::IsCallable(mCallback));
236 : }
237 :
238 : explicit inline MozGetUserMediaDevicesSuccessCallback(CallbackFunction* aOther)
239 : : CallbackFunction(aOther)
240 : {
241 : }
242 :
243 : template <typename T>
244 : inline void
245 : Call(const T& thisVal, nsIVariant* devices, ErrorResult& aRv, const char* aExecutionReason = nullptr, ExceptionHandling aExceptionHandling = eReportExceptions, JSCompartment* aCompartment = nullptr)
246 : {
247 : MOZ_ASSERT(!aRv.Failed(), "Don't pass an already-failed ErrorResult to a callback!");
248 : if (!aExecutionReason) {
249 : aExecutionReason = "MozGetUserMediaDevicesSuccessCallback";
250 : }
251 : CallSetup s(this, aRv, aExecutionReason, aExceptionHandling, aCompartment);
252 : if (!s.GetContext()) {
253 : MOZ_ASSERT(aRv.Failed());
254 : return;
255 : }
256 : JS::Rooted<JS::Value> thisValJS(s.GetContext());
257 : if (!ToJSValue(s.GetContext(), thisVal, &thisValJS)) {
258 : aRv.Throw(NS_ERROR_FAILURE);
259 : return;
260 : }
261 : return Call(s.GetContext(), thisValJS, devices, aRv);
262 : }
263 :
264 : inline void
265 : Call(nsIVariant* devices, ErrorResult& aRv, const char* aExecutionReason = nullptr, ExceptionHandling aExceptionHandling = eReportExceptions, JSCompartment* aCompartment = nullptr)
266 : {
267 : MOZ_ASSERT(!aRv.Failed(), "Don't pass an already-failed ErrorResult to a callback!");
268 : if (!aExecutionReason) {
269 : aExecutionReason = "MozGetUserMediaDevicesSuccessCallback";
270 : }
271 : CallSetup s(this, aRv, aExecutionReason, aExceptionHandling, aCompartment);
272 : if (!s.GetContext()) {
273 : MOZ_ASSERT(aRv.Failed());
274 : return;
275 : }
276 : return Call(s.GetContext(), JS::UndefinedHandleValue, devices, aRv);
277 : }
278 :
279 : template <typename T>
280 : inline void
281 : Call(const T& thisVal, nsIVariant* devices, const char* aExecutionReason = nullptr)
282 : {
283 : IgnoredErrorResult rv;
284 : return Call(thisVal, devices, rv, aExecutionReason);
285 : }
286 :
287 : inline void
288 : Call(nsIVariant* devices, const char* aExecutionReason = nullptr)
289 : {
290 : IgnoredErrorResult rv;
291 : return Call(devices, rv, aExecutionReason, eReportExceptions, nullptr);
292 : }
293 :
294 : inline bool
295 : operator==(const MozGetUserMediaDevicesSuccessCallback& aOther) const
296 : {
297 : return CallbackFunction::operator==(aOther);
298 : }
299 :
300 : private:
301 : void Call(JSContext* cx, JS::Handle<JS::Value> aThisVal, nsIVariant* devices, ErrorResult& aRv);
302 : };
303 :
304 :
305 : namespace binding_detail {
306 0 : class FastNavigatorUserMediaSuccessCallback : public NavigatorUserMediaSuccessCallback
307 : {
308 : public:
309 0 : explicit inline FastNavigatorUserMediaSuccessCallback(JS::Handle<JSObject*> aCallback)
310 0 : : NavigatorUserMediaSuccessCallback(aCallback, FastCallbackConstructor())
311 : {
312 0 : }
313 :
314 : inline void
315 0 : Trace(JSTracer* aTracer)
316 : {
317 0 : NavigatorUserMediaSuccessCallback::Trace(aTracer);
318 0 : }
319 :
320 : inline void
321 0 : FinishSlowJSInitIfMoreThanOneOwner(JSContext* aCx)
322 : {
323 0 : NavigatorUserMediaSuccessCallback::FinishSlowJSInitIfMoreThanOneOwner(aCx);
324 0 : }
325 : };
326 : } // namespace binding_detail
327 :
328 :
329 : namespace binding_detail {
330 0 : class FastNavigatorUserMediaErrorCallback : public NavigatorUserMediaErrorCallback
331 : {
332 : public:
333 0 : explicit inline FastNavigatorUserMediaErrorCallback(JS::Handle<JSObject*> aCallback)
334 0 : : NavigatorUserMediaErrorCallback(aCallback, FastCallbackConstructor())
335 : {
336 0 : }
337 :
338 : inline void
339 0 : Trace(JSTracer* aTracer)
340 : {
341 0 : NavigatorUserMediaErrorCallback::Trace(aTracer);
342 0 : }
343 :
344 : inline void
345 0 : FinishSlowJSInitIfMoreThanOneOwner(JSContext* aCx)
346 : {
347 0 : NavigatorUserMediaErrorCallback::FinishSlowJSInitIfMoreThanOneOwner(aCx);
348 0 : }
349 : };
350 : } // namespace binding_detail
351 :
352 :
353 : namespace binding_detail {
354 0 : class FastMozGetUserMediaDevicesSuccessCallback : public MozGetUserMediaDevicesSuccessCallback
355 : {
356 : public:
357 0 : explicit inline FastMozGetUserMediaDevicesSuccessCallback(JS::Handle<JSObject*> aCallback)
358 0 : : MozGetUserMediaDevicesSuccessCallback(aCallback, FastCallbackConstructor())
359 : {
360 0 : }
361 :
362 : inline void
363 0 : Trace(JSTracer* aTracer)
364 : {
365 0 : MozGetUserMediaDevicesSuccessCallback::Trace(aTracer);
366 0 : }
367 :
368 : inline void
369 0 : FinishSlowJSInitIfMoreThanOneOwner(JSContext* aCx)
370 : {
371 0 : MozGetUserMediaDevicesSuccessCallback::FinishSlowJSInitIfMoreThanOneOwner(aCx);
372 0 : }
373 : };
374 : } // namespace binding_detail
375 :
376 :
377 : namespace NavigatorBinding {
378 :
379 : typedef mozilla::dom::Navigator NativeType;
380 :
381 : JSObject*
382 : DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal);
383 :
384 : const JSClass*
385 : GetJSClass();
386 :
387 : bool
388 : Wrap(JSContext* aCx, mozilla::dom::Navigator* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector);
389 :
390 : template <class T>
391 0 : inline JSObject* Wrap(JSContext* aCx, T* aObject, JS::Handle<JSObject*> aGivenProto)
392 : {
393 0 : JS::Rooted<JSObject*> reflector(aCx);
394 0 : return Wrap(aCx, aObject, aObject, aGivenProto, &reflector) ? reflector.get() : nullptr;
395 : }
396 :
397 : // We declare this as an array so that retrieving a pointer to this
398 : // binding's property hooks only requires compile/link-time resolvable
399 : // address arithmetic. Declaring it as a pointer instead would require
400 : // doing a run-time load to fetch a pointer to this binding's property
401 : // hooks. And then structures which embedded a pointer to this structure
402 : // would require a run-time load for proper initialization, which would
403 : // then induce static constructors. Lots of static constructors.
404 : extern const NativePropertyHooks sNativePropertyHooks[];
405 :
406 : void
407 : ClearCachedActiveVRDisplaysValue(mozilla::dom::Navigator* aObject);
408 :
409 : void
410 : ClearCachedUserAgentValue(mozilla::dom::Navigator* aObject);
411 :
412 : void
413 : ClearCachedLanguageValue(mozilla::dom::Navigator* aObject);
414 :
415 : void
416 : ClearCachedLanguagesValue(mozilla::dom::Navigator* aObject);
417 :
418 : void
419 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal);
420 :
421 : JS::Handle<JSObject*>
422 : GetProtoObjectHandle(JSContext* aCx);
423 :
424 : JS::Handle<JSObject*>
425 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal = true);
426 :
427 : JSObject*
428 : GetConstructorObject(JSContext* aCx);
429 :
430 : } // namespace NavigatorBinding
431 :
432 :
433 :
434 0 : class MozIdleObserver : public CallbackInterface
435 : {
436 : public:
437 : explicit inline MozIdleObserver(JSContext* aCx, JS::Handle<JSObject*> aCallback, nsIGlobalObject* aIncumbentGlobal)
438 : : CallbackInterface(aCx, aCallback, aIncumbentGlobal)
439 : {
440 : }
441 :
442 0 : explicit inline MozIdleObserver(JS::Handle<JSObject*> aCallback, const FastCallbackConstructor& )
443 0 : : CallbackInterface(aCallback, FastCallbackConstructor())
444 : {
445 0 : }
446 :
447 : explicit inline MozIdleObserver(JS::Handle<JSObject*> aCallback, JS::Handle<JSObject*> aAsyncStack, nsIGlobalObject* aIncumbentGlobal)
448 : : CallbackInterface(aCallback, aAsyncStack, aIncumbentGlobal)
449 : {
450 : }
451 :
452 : void Onidle(ErrorResult& aRv, const char* aExecutionReason = nullptr, ExceptionHandling aExceptionHandling = eReportExceptions, JSCompartment* aCompartment = nullptr);
453 :
454 : void Onactive(ErrorResult& aRv, const char* aExecutionReason = nullptr, ExceptionHandling aExceptionHandling = eReportExceptions, JSCompartment* aCompartment = nullptr);
455 :
456 : inline bool
457 : operator==(const MozIdleObserver& aOther) const
458 : {
459 : return CallbackInterface::operator==(aOther);
460 : }
461 :
462 : uint32_t GetTime(ErrorResult& aRv, const char* aExecutionReason = nullptr, ExceptionHandling aExceptionHandling = eReportExceptions, JSCompartment* aCompartment = nullptr);
463 :
464 : private:
465 : static bool
466 : InitIds(JSContext* cx, MozIdleObserverAtoms* atomsCache);
467 : };
468 :
469 :
470 : namespace binding_detail {
471 0 : class FastMozIdleObserver : public MozIdleObserver
472 : {
473 : public:
474 0 : explicit inline FastMozIdleObserver(JS::Handle<JSObject*> aCallback)
475 0 : : MozIdleObserver(aCallback, FastCallbackConstructor())
476 : {
477 0 : }
478 :
479 : inline void
480 0 : Trace(JSTracer* aTracer)
481 : {
482 0 : MozIdleObserver::Trace(aTracer);
483 0 : }
484 :
485 : inline void
486 0 : FinishSlowJSInitIfMoreThanOneOwner(JSContext* aCx)
487 : {
488 0 : MozIdleObserver::FinishSlowJSInitIfMoreThanOneOwner(aCx);
489 0 : }
490 : };
491 : } // namespace binding_detail
492 :
493 :
494 : } // namespace dom
495 : } // namespace mozilla
496 :
497 : #endif // mozilla_dom_NavigatorBinding_h
|