/work/obj-fuzz/dist/include/mozilla/dom/U2FBinding.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* THIS FILE IS AUTOGENERATED FROM U2F.webidl BY Codegen.py - DO NOT EDIT */ |
2 | | |
3 | | #ifndef mozilla_dom_U2FBinding_h |
4 | | #define mozilla_dom_U2FBinding_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 NativePropertyHooks; |
20 | | class ProtoAndIfaceCache; |
21 | | struct RegisterRequestAtoms; |
22 | | struct RegisterResponse; |
23 | | struct RegisterResponseAtoms; |
24 | | struct RegisteredKeyAtoms; |
25 | | struct SignResponse; |
26 | | struct SignResponseAtoms; |
27 | | class U2F; |
28 | | struct U2FAtoms; |
29 | | struct U2FClientDataAtoms; |
30 | | class U2FRegisterCallback; |
31 | | class U2FSignCallback; |
32 | | |
33 | | } // namespace dom |
34 | | } // namespace mozilla |
35 | | |
36 | | namespace mozilla { |
37 | | namespace dom { |
38 | | |
39 | | enum class Transport : uint8_t { |
40 | | Bt, |
41 | | Ble, |
42 | | Nfc, |
43 | | Usb, |
44 | | EndGuard_ |
45 | | }; |
46 | | |
47 | | namespace TransportValues { |
48 | | extern const EnumEntry strings[5]; |
49 | | } // namespace TransportValues |
50 | | |
51 | | bool |
52 | | ToJSValue(JSContext* aCx, Transport aArgument, JS::MutableHandle<JS::Value> aValue); |
53 | | |
54 | | |
55 | | struct RegisterRequest : public DictionaryBase |
56 | | { |
57 | | MOZ_INIT_OUTSIDE_CTOR Optional<nsString> mChallenge; |
58 | | MOZ_INIT_OUTSIDE_CTOR Optional<nsString> mVersion; |
59 | | |
60 | | RegisterRequest(); |
61 | | |
62 | | explicit inline RegisterRequest(const FastDictionaryInitializer& ) |
63 | 0 | { |
64 | 0 | // Do nothing here; this is used by our "Fast" subclass |
65 | 0 | } |
66 | | |
67 | | explicit inline RegisterRequest(const RegisterRequest& aOther) |
68 | 0 | { |
69 | 0 | *this = aOther; |
70 | 0 | } |
71 | | |
72 | | bool |
73 | | Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false); |
74 | | |
75 | | bool |
76 | | Init(const nsAString& aJSON); |
77 | | |
78 | | bool |
79 | | ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const; |
80 | | |
81 | | bool |
82 | | ToJSON(nsAString& aJSON) const; |
83 | | |
84 | | void |
85 | | TraceDictionary(JSTracer* trc); |
86 | | |
87 | | RegisterRequest& |
88 | | operator=(const RegisterRequest& aOther); |
89 | | |
90 | | private: |
91 | | static bool |
92 | | InitIds(JSContext* cx, RegisterRequestAtoms* atomsCache); |
93 | | }; |
94 | | |
95 | | namespace binding_detail { |
96 | | struct FastRegisterRequest : public RegisterRequest |
97 | | { |
98 | | inline FastRegisterRequest() |
99 | | : RegisterRequest(FastDictionaryInitializer()) |
100 | 0 | { |
101 | 0 | // Doesn't matter what int we pass to the parent constructor |
102 | 0 | } |
103 | | }; |
104 | | } // namespace binding_detail |
105 | | |
106 | | |
107 | | struct RegisterResponse : public DictionaryBase |
108 | | { |
109 | | MOZ_INIT_OUTSIDE_CTOR Optional<nsString> mClientData; |
110 | | MOZ_INIT_OUTSIDE_CTOR Optional<Nullable<uint16_t>> mErrorCode; |
111 | | MOZ_INIT_OUTSIDE_CTOR Optional<nsString> mErrorMessage; |
112 | | MOZ_INIT_OUTSIDE_CTOR Optional<nsString> mRegistrationData; |
113 | | MOZ_INIT_OUTSIDE_CTOR Optional<nsString> mVersion; |
114 | | |
115 | | RegisterResponse(); |
116 | | |
117 | | explicit inline RegisterResponse(const FastDictionaryInitializer& ) |
118 | 0 | { |
119 | 0 | // Do nothing here; this is used by our "Fast" subclass |
120 | 0 | } |
121 | | |
122 | | explicit inline RegisterResponse(const RegisterResponse& aOther) |
123 | 0 | { |
124 | 0 | *this = aOther; |
125 | 0 | } |
126 | | |
127 | | bool |
128 | | Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false); |
129 | | |
130 | | bool |
131 | | Init(const nsAString& aJSON); |
132 | | |
133 | | bool |
134 | | ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const; |
135 | | |
136 | | bool |
137 | | ToJSON(nsAString& aJSON) const; |
138 | | |
139 | | void |
140 | | TraceDictionary(JSTracer* trc); |
141 | | |
142 | | RegisterResponse& |
143 | | operator=(const RegisterResponse& aOther); |
144 | | |
145 | | private: |
146 | | static bool |
147 | | InitIds(JSContext* cx, RegisterResponseAtoms* atomsCache); |
148 | | }; |
149 | | |
150 | | namespace binding_detail { |
151 | | struct FastRegisterResponse : public RegisterResponse |
152 | | { |
153 | | inline FastRegisterResponse() |
154 | | : RegisterResponse(FastDictionaryInitializer()) |
155 | 0 | { |
156 | 0 | // Doesn't matter what int we pass to the parent constructor |
157 | 0 | } |
158 | | }; |
159 | | } // namespace binding_detail |
160 | | |
161 | | |
162 | | struct RegisteredKey : public DictionaryBase |
163 | | { |
164 | | MOZ_INIT_OUTSIDE_CTOR Optional<nsString> mAppId; |
165 | | MOZ_INIT_OUTSIDE_CTOR Optional<nsString> mKeyHandle; |
166 | | MOZ_INIT_OUTSIDE_CTOR Optional<Nullable<Sequence<Transport>>> mTransports; |
167 | | MOZ_INIT_OUTSIDE_CTOR Optional<nsString> mVersion; |
168 | | |
169 | | RegisteredKey(); |
170 | | |
171 | | explicit inline RegisteredKey(const FastDictionaryInitializer& ) |
172 | 0 | { |
173 | 0 | // Do nothing here; this is used by our "Fast" subclass |
174 | 0 | } |
175 | | |
176 | | explicit inline RegisteredKey(const RegisteredKey& aOther) |
177 | 0 | { |
178 | 0 | *this = aOther; |
179 | 0 | } |
180 | | |
181 | | bool |
182 | | Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false); |
183 | | |
184 | | bool |
185 | | Init(const nsAString& aJSON); |
186 | | |
187 | | bool |
188 | | ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const; |
189 | | |
190 | | bool |
191 | | ToJSON(nsAString& aJSON) const; |
192 | | |
193 | | void |
194 | | TraceDictionary(JSTracer* trc); |
195 | | |
196 | | RegisteredKey& |
197 | | operator=(const RegisteredKey& aOther); |
198 | | |
199 | | private: |
200 | | static bool |
201 | | InitIds(JSContext* cx, RegisteredKeyAtoms* atomsCache); |
202 | | }; |
203 | | |
204 | | namespace binding_detail { |
205 | | struct FastRegisteredKey : public RegisteredKey |
206 | | { |
207 | | inline FastRegisteredKey() |
208 | | : RegisteredKey(FastDictionaryInitializer()) |
209 | 0 | { |
210 | 0 | // Doesn't matter what int we pass to the parent constructor |
211 | 0 | } |
212 | | }; |
213 | | } // namespace binding_detail |
214 | | |
215 | | |
216 | | struct SignResponse : public DictionaryBase |
217 | | { |
218 | | MOZ_INIT_OUTSIDE_CTOR Optional<nsString> mClientData; |
219 | | MOZ_INIT_OUTSIDE_CTOR Optional<Nullable<uint16_t>> mErrorCode; |
220 | | MOZ_INIT_OUTSIDE_CTOR Optional<nsString> mErrorMessage; |
221 | | MOZ_INIT_OUTSIDE_CTOR Optional<nsString> mKeyHandle; |
222 | | MOZ_INIT_OUTSIDE_CTOR Optional<nsString> mSignatureData; |
223 | | |
224 | | SignResponse(); |
225 | | |
226 | | explicit inline SignResponse(const FastDictionaryInitializer& ) |
227 | 0 | { |
228 | 0 | // Do nothing here; this is used by our "Fast" subclass |
229 | 0 | } |
230 | | |
231 | | explicit inline SignResponse(const SignResponse& aOther) |
232 | 0 | { |
233 | 0 | *this = aOther; |
234 | 0 | } |
235 | | |
236 | | bool |
237 | | Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false); |
238 | | |
239 | | bool |
240 | | Init(const nsAString& aJSON); |
241 | | |
242 | | bool |
243 | | ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const; |
244 | | |
245 | | bool |
246 | | ToJSON(nsAString& aJSON) const; |
247 | | |
248 | | void |
249 | | TraceDictionary(JSTracer* trc); |
250 | | |
251 | | SignResponse& |
252 | | operator=(const SignResponse& aOther); |
253 | | |
254 | | private: |
255 | | static bool |
256 | | InitIds(JSContext* cx, SignResponseAtoms* atomsCache); |
257 | | }; |
258 | | |
259 | | namespace binding_detail { |
260 | | struct FastSignResponse : public SignResponse |
261 | | { |
262 | | inline FastSignResponse() |
263 | | : SignResponse(FastDictionaryInitializer()) |
264 | 0 | { |
265 | 0 | // Doesn't matter what int we pass to the parent constructor |
266 | 0 | } |
267 | | }; |
268 | | } // namespace binding_detail |
269 | | |
270 | | |
271 | | struct U2FClientData : public DictionaryBase |
272 | | { |
273 | | MOZ_INIT_OUTSIDE_CTOR Optional<nsString> mChallenge; |
274 | | MOZ_INIT_OUTSIDE_CTOR Optional<nsString> mOrigin; |
275 | | MOZ_INIT_OUTSIDE_CTOR Optional<nsString> mTyp; |
276 | | |
277 | | U2FClientData(); |
278 | | |
279 | | explicit inline U2FClientData(const FastDictionaryInitializer& ) |
280 | 0 | { |
281 | 0 | // Do nothing here; this is used by our "Fast" subclass |
282 | 0 | } |
283 | | |
284 | | explicit inline U2FClientData(const U2FClientData& aOther) |
285 | 0 | { |
286 | 0 | *this = aOther; |
287 | 0 | } |
288 | | |
289 | | bool |
290 | | Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false); |
291 | | |
292 | | bool |
293 | | Init(const nsAString& aJSON); |
294 | | |
295 | | bool |
296 | | ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const; |
297 | | |
298 | | bool |
299 | | ToJSON(nsAString& aJSON) const; |
300 | | |
301 | | void |
302 | | TraceDictionary(JSTracer* trc); |
303 | | |
304 | | U2FClientData& |
305 | | operator=(const U2FClientData& aOther); |
306 | | |
307 | | private: |
308 | | static bool |
309 | | InitIds(JSContext* cx, U2FClientDataAtoms* atomsCache); |
310 | | }; |
311 | | |
312 | | namespace binding_detail { |
313 | | struct FastU2FClientData : public U2FClientData |
314 | | { |
315 | | inline FastU2FClientData() |
316 | | : U2FClientData(FastDictionaryInitializer()) |
317 | 0 | { |
318 | 0 | // Doesn't matter what int we pass to the parent constructor |
319 | 0 | } |
320 | | }; |
321 | | } // namespace binding_detail |
322 | | |
323 | | |
324 | | class U2FRegisterCallback : public CallbackFunction |
325 | | { |
326 | | public: |
327 | | explicit inline U2FRegisterCallback(JSContext* aCx, JS::Handle<JSObject*> aCallback, JS::Handle<JSObject*> aCallbackGlobal, nsIGlobalObject* aIncumbentGlobal) |
328 | | : CallbackFunction(aCx, aCallback, aCallbackGlobal, aIncumbentGlobal) |
329 | 0 | { |
330 | 0 | MOZ_ASSERT(JS::IsCallable(mCallback)); |
331 | 0 | } |
332 | | |
333 | | explicit inline U2FRegisterCallback(JSObject* aCallback, JSObject* aCallbackGlobal, const FastCallbackConstructor& ) |
334 | | : CallbackFunction(aCallback, aCallbackGlobal, FastCallbackConstructor()) |
335 | 0 | { |
336 | 0 | MOZ_ASSERT(JS::IsCallable(mCallback)); |
337 | 0 | } |
338 | | |
339 | | explicit inline U2FRegisterCallback(JSObject* aCallback, JSObject* aCallbackGlobal, JSObject* aAsyncStack, nsIGlobalObject* aIncumbentGlobal) |
340 | | : CallbackFunction(aCallback, aCallbackGlobal, aAsyncStack, aIncumbentGlobal) |
341 | 0 | { |
342 | 0 | MOZ_ASSERT(JS::IsCallable(mCallback)); |
343 | 0 | } |
344 | | |
345 | | explicit inline U2FRegisterCallback(CallbackFunction* aOther) |
346 | | : CallbackFunction(aOther) |
347 | 0 | { |
348 | 0 | } |
349 | | |
350 | | template <typename T> |
351 | | inline void |
352 | | Call(const T& thisVal, const RegisterResponse& response, ErrorResult& aRv, const char* aExecutionReason = nullptr, ExceptionHandling aExceptionHandling = eReportExceptions, JS::Realm* aRealm = nullptr) |
353 | | { |
354 | | MOZ_ASSERT(!aRv.Failed(), "Don't pass an already-failed ErrorResult to a callback!"); |
355 | | if (!aExecutionReason) { |
356 | | aExecutionReason = "U2FRegisterCallback"; |
357 | | } |
358 | | CallSetup s(this, aRv, aExecutionReason, aExceptionHandling, aRealm); |
359 | | if (!s.GetContext()) { |
360 | | MOZ_ASSERT(aRv.Failed()); |
361 | | return; |
362 | | } |
363 | | JS::Rooted<JS::Value> thisValJS(s.GetContext()); |
364 | | if (!ToJSValue(s.GetContext(), thisVal, &thisValJS)) { |
365 | | aRv.Throw(NS_ERROR_FAILURE); |
366 | | return; |
367 | | } |
368 | | return Call(s.GetContext(), thisValJS, response, aRv); |
369 | | } |
370 | | |
371 | | inline void |
372 | | Call(const RegisterResponse& response, ErrorResult& aRv, const char* aExecutionReason = nullptr, ExceptionHandling aExceptionHandling = eReportExceptions, JS::Realm* aRealm = nullptr) |
373 | 0 | { |
374 | 0 | MOZ_ASSERT(!aRv.Failed(), "Don't pass an already-failed ErrorResult to a callback!"); |
375 | 0 | if (!aExecutionReason) { |
376 | 0 | aExecutionReason = "U2FRegisterCallback"; |
377 | 0 | } |
378 | 0 | CallSetup s(this, aRv, aExecutionReason, aExceptionHandling, aRealm); |
379 | 0 | if (!s.GetContext()) { |
380 | 0 | MOZ_ASSERT(aRv.Failed()); |
381 | 0 | return; |
382 | 0 | } |
383 | 0 | return Call(s.GetContext(), JS::UndefinedHandleValue, response, aRv); |
384 | 0 | } |
385 | | |
386 | | template <typename T> |
387 | | inline void |
388 | | Call(const T& thisVal, const RegisterResponse& response, const char* aExecutionReason = nullptr) |
389 | | { |
390 | | return Call(thisVal, response, IgnoreErrors(), aExecutionReason); |
391 | | } |
392 | | |
393 | | inline void |
394 | | Call(const RegisterResponse& response, const char* aExecutionReason = nullptr) |
395 | 0 | { |
396 | 0 | return Call(response, IgnoreErrors(), aExecutionReason, eReportExceptions, nullptr); |
397 | 0 | } |
398 | | |
399 | | inline bool |
400 | | operator==(const U2FRegisterCallback& aOther) const |
401 | 0 | { |
402 | 0 | return CallbackFunction::operator==(aOther); |
403 | 0 | } |
404 | | |
405 | | private: |
406 | | void Call(JSContext* cx, JS::Handle<JS::Value> aThisVal, const RegisterResponse& response, ErrorResult& aRv); |
407 | | }; |
408 | | |
409 | | |
410 | | class U2FSignCallback : public CallbackFunction |
411 | | { |
412 | | public: |
413 | | explicit inline U2FSignCallback(JSContext* aCx, JS::Handle<JSObject*> aCallback, JS::Handle<JSObject*> aCallbackGlobal, nsIGlobalObject* aIncumbentGlobal) |
414 | | : CallbackFunction(aCx, aCallback, aCallbackGlobal, aIncumbentGlobal) |
415 | 0 | { |
416 | 0 | MOZ_ASSERT(JS::IsCallable(mCallback)); |
417 | 0 | } |
418 | | |
419 | | explicit inline U2FSignCallback(JSObject* aCallback, JSObject* aCallbackGlobal, const FastCallbackConstructor& ) |
420 | | : CallbackFunction(aCallback, aCallbackGlobal, FastCallbackConstructor()) |
421 | 0 | { |
422 | 0 | MOZ_ASSERT(JS::IsCallable(mCallback)); |
423 | 0 | } |
424 | | |
425 | | explicit inline U2FSignCallback(JSObject* aCallback, JSObject* aCallbackGlobal, JSObject* aAsyncStack, nsIGlobalObject* aIncumbentGlobal) |
426 | | : CallbackFunction(aCallback, aCallbackGlobal, aAsyncStack, aIncumbentGlobal) |
427 | 0 | { |
428 | 0 | MOZ_ASSERT(JS::IsCallable(mCallback)); |
429 | 0 | } |
430 | | |
431 | | explicit inline U2FSignCallback(CallbackFunction* aOther) |
432 | | : CallbackFunction(aOther) |
433 | 0 | { |
434 | 0 | } |
435 | | |
436 | | template <typename T> |
437 | | inline void |
438 | | Call(const T& thisVal, const SignResponse& response, ErrorResult& aRv, const char* aExecutionReason = nullptr, ExceptionHandling aExceptionHandling = eReportExceptions, JS::Realm* aRealm = nullptr) |
439 | | { |
440 | | MOZ_ASSERT(!aRv.Failed(), "Don't pass an already-failed ErrorResult to a callback!"); |
441 | | if (!aExecutionReason) { |
442 | | aExecutionReason = "U2FSignCallback"; |
443 | | } |
444 | | CallSetup s(this, aRv, aExecutionReason, aExceptionHandling, aRealm); |
445 | | if (!s.GetContext()) { |
446 | | MOZ_ASSERT(aRv.Failed()); |
447 | | return; |
448 | | } |
449 | | JS::Rooted<JS::Value> thisValJS(s.GetContext()); |
450 | | if (!ToJSValue(s.GetContext(), thisVal, &thisValJS)) { |
451 | | aRv.Throw(NS_ERROR_FAILURE); |
452 | | return; |
453 | | } |
454 | | return Call(s.GetContext(), thisValJS, response, aRv); |
455 | | } |
456 | | |
457 | | inline void |
458 | | Call(const SignResponse& response, ErrorResult& aRv, const char* aExecutionReason = nullptr, ExceptionHandling aExceptionHandling = eReportExceptions, JS::Realm* aRealm = nullptr) |
459 | 0 | { |
460 | 0 | MOZ_ASSERT(!aRv.Failed(), "Don't pass an already-failed ErrorResult to a callback!"); |
461 | 0 | if (!aExecutionReason) { |
462 | 0 | aExecutionReason = "U2FSignCallback"; |
463 | 0 | } |
464 | 0 | CallSetup s(this, aRv, aExecutionReason, aExceptionHandling, aRealm); |
465 | 0 | if (!s.GetContext()) { |
466 | 0 | MOZ_ASSERT(aRv.Failed()); |
467 | 0 | return; |
468 | 0 | } |
469 | 0 | return Call(s.GetContext(), JS::UndefinedHandleValue, response, aRv); |
470 | 0 | } |
471 | | |
472 | | template <typename T> |
473 | | inline void |
474 | | Call(const T& thisVal, const SignResponse& response, const char* aExecutionReason = nullptr) |
475 | | { |
476 | | return Call(thisVal, response, IgnoreErrors(), aExecutionReason); |
477 | | } |
478 | | |
479 | | inline void |
480 | | Call(const SignResponse& response, const char* aExecutionReason = nullptr) |
481 | 0 | { |
482 | 0 | return Call(response, IgnoreErrors(), aExecutionReason, eReportExceptions, nullptr); |
483 | 0 | } |
484 | | |
485 | | inline bool |
486 | | operator==(const U2FSignCallback& aOther) const |
487 | 0 | { |
488 | 0 | return CallbackFunction::operator==(aOther); |
489 | 0 | } |
490 | | |
491 | | private: |
492 | | void Call(JSContext* cx, JS::Handle<JS::Value> aThisVal, const SignResponse& response, ErrorResult& aRv); |
493 | | }; |
494 | | |
495 | | |
496 | | namespace binding_detail { |
497 | | class FastU2FRegisterCallback : public U2FRegisterCallback |
498 | | { |
499 | | public: |
500 | | explicit inline FastU2FRegisterCallback(JSObject* aCallback, JSObject* aCallbackGlobal) |
501 | | : U2FRegisterCallback(aCallback, aCallbackGlobal, FastCallbackConstructor()) |
502 | 0 | { |
503 | 0 | } |
504 | | |
505 | | inline void |
506 | | Trace(JSTracer* aTracer) |
507 | 0 | { |
508 | 0 | U2FRegisterCallback::Trace(aTracer); |
509 | 0 | } |
510 | | |
511 | | inline void |
512 | | FinishSlowJSInitIfMoreThanOneOwner(JSContext* aCx) |
513 | 0 | { |
514 | 0 | U2FRegisterCallback::FinishSlowJSInitIfMoreThanOneOwner(aCx); |
515 | 0 | } |
516 | | }; |
517 | | } // namespace binding_detail |
518 | | |
519 | | |
520 | | namespace binding_detail { |
521 | | class FastU2FSignCallback : public U2FSignCallback |
522 | | { |
523 | | public: |
524 | | explicit inline FastU2FSignCallback(JSObject* aCallback, JSObject* aCallbackGlobal) |
525 | | : U2FSignCallback(aCallback, aCallbackGlobal, FastCallbackConstructor()) |
526 | 0 | { |
527 | 0 | } |
528 | | |
529 | | inline void |
530 | | Trace(JSTracer* aTracer) |
531 | 0 | { |
532 | 0 | U2FSignCallback::Trace(aTracer); |
533 | 0 | } |
534 | | |
535 | | inline void |
536 | | FinishSlowJSInitIfMoreThanOneOwner(JSContext* aCx) |
537 | 0 | { |
538 | 0 | U2FSignCallback::FinishSlowJSInitIfMoreThanOneOwner(aCx); |
539 | 0 | } |
540 | | }; |
541 | | } // namespace binding_detail |
542 | | |
543 | | |
544 | | namespace U2F_Binding { |
545 | | |
546 | | typedef mozilla::dom::U2F NativeType; |
547 | | |
548 | | static const uint16_t OK = 0; |
549 | | static const uint16_t OTHER_ERROR = 1; |
550 | | static const uint16_t BAD_REQUEST = 2; |
551 | | static const uint16_t CONFIGURATION_UNSUPPORTED = 3; |
552 | | static const uint16_t DEVICE_INELIGIBLE = 4; |
553 | | static const uint16_t TIMEOUT = 5; |
554 | | bool |
555 | | ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj); |
556 | | |
557 | | const JSClass* |
558 | | GetJSClass(); |
559 | | |
560 | | bool |
561 | | Wrap(JSContext* aCx, mozilla::dom::U2F* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector); |
562 | | |
563 | | template <class T> |
564 | | inline JSObject* Wrap(JSContext* aCx, T* aObject, JS::Handle<JSObject*> aGivenProto) |
565 | 0 | { |
566 | 0 | JS::Rooted<JSObject*> reflector(aCx); |
567 | 0 | return Wrap(aCx, aObject, aObject, aGivenProto, &reflector) ? reflector.get() : nullptr; |
568 | 0 | } |
569 | | |
570 | | // We declare this as an array so that retrieving a pointer to this |
571 | | // binding's property hooks only requires compile/link-time resolvable |
572 | | // address arithmetic. Declaring it as a pointer instead would require |
573 | | // doing a run-time load to fetch a pointer to this binding's property |
574 | | // hooks. And then structures which embedded a pointer to this structure |
575 | | // would require a run-time load for proper initialization, which would |
576 | | // then induce static constructors. Lots of static constructors. |
577 | | extern const NativePropertyHooks sNativePropertyHooks[]; |
578 | | |
579 | | void |
580 | | CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal); |
581 | | |
582 | | inline JS::Handle<JSObject*> GetProtoObjectHandle(JSContext* aCx) |
583 | 0 | { |
584 | 0 | /* Get the interface prototype object for this class. This will create the |
585 | 0 | object as needed. */ |
586 | 0 | return GetPerInterfaceObjectHandle(aCx, prototypes::id::U2F, |
587 | 0 | &CreateInterfaceObjects, |
588 | 0 | /* aDefineOnGlobal = */ true); |
589 | 0 |
|
590 | 0 | } |
591 | | |
592 | | inline JS::Handle<JSObject*> GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal = true) |
593 | 0 | { |
594 | 0 | /* Get the interface object for this class. This will create the object as |
595 | 0 | needed. */ |
596 | 0 |
|
597 | 0 | return GetPerInterfaceObjectHandle(aCx, constructors::id::U2F, |
598 | 0 | &CreateInterfaceObjects, |
599 | 0 | aDefineOnGlobal); |
600 | 0 | } |
601 | | |
602 | | JSObject* |
603 | | GetConstructorObject(JSContext* aCx); |
604 | | |
605 | | } // namespace U2F_Binding |
606 | | |
607 | | |
608 | | |
609 | | } // namespace dom |
610 | | } // namespace mozilla |
611 | | |
612 | | #endif // mozilla_dom_U2FBinding_h |