| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef WebAuthentication_h | 5 #ifndef WebAuthentication_h |
| 6 #define WebAuthentication_h | 6 #define WebAuthentication_h |
| 7 | 7 |
| 8 #include "bindings/core/v8/ArrayBufferOrArrayBufferView.h" | 8 #include "bindings/core/v8/ArrayBufferOrArrayBufferView.h" |
| 9 #include "bindings/core/v8/ScriptPromise.h" | 9 #include "bindings/core/v8/ScriptPromise.h" |
| 10 #include "bindings/core/v8/ScriptWrappable.h" | 10 #include "bindings/core/v8/ScriptWrappable.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 class ScriptPromiseResolver; | 22 class ScriptPromiseResolver; |
| 23 | 23 |
| 24 typedef ArrayBufferOrArrayBufferView BufferSource; | 24 typedef ArrayBufferOrArrayBufferView BufferSource; |
| 25 | 25 |
| 26 class WebAuthentication final | 26 class WebAuthentication final |
| 27 : public GarbageCollectedFinalized<WebAuthentication>, | 27 : public GarbageCollectedFinalized<WebAuthentication>, |
| 28 public ScriptWrappable, | 28 public ScriptWrappable, |
| 29 public ContextLifecycleObserver { | 29 public ContextLifecycleObserver { |
| 30 DEFINE_WRAPPERTYPEINFO(); | 30 DEFINE_WRAPPERTYPEINFO(); |
| 31 USING_GARBAGE_COLLECTED_MIXIN(WebAuthentication); | 31 USING_GARBAGE_COLLECTED_MIXIN(WebAuthentication); |
| 32 USING_PRE_FINALIZER(WebAuthentication, Dispose); |
| 32 | 33 |
| 33 public: | 34 public: |
| 34 static WebAuthentication* Create(LocalFrame& frame) { | 35 static WebAuthentication* Create(LocalFrame& frame) { |
| 35 return new WebAuthentication(frame); | 36 return new WebAuthentication(frame); |
| 36 } | 37 } |
| 37 | 38 |
| 38 virtual ~WebAuthentication(); | 39 virtual ~WebAuthentication(); |
| 39 | 40 |
| 40 void Dispose(); | 41 void Dispose(); |
| 41 | 42 |
| 42 // WebAuthentication.idl | 43 // WebAuthentication.idl |
| 43 ScriptPromise makeCredential(ScriptState*, | 44 ScriptPromise makeCredential(ScriptState*, |
| 44 const RelyingPartyAccount&, | 45 const RelyingPartyAccount&, |
| 45 const HeapVector<ScopedCredentialParameters>, | 46 const HeapVector<ScopedCredentialParameters>, |
| 46 const BufferSource&, | 47 const BufferSource&, |
| 47 ScopedCredentialOptions&); | 48 ScopedCredentialOptions&); |
| 49 /* ScriptPromise makeCredential(ScriptState*, |
| 50 const RelyingPartyAccount&, |
| 51 const HeapVector<ScopedCredentialParameters>, |
| 52 const BufferSource&); */ |
| 48 ScriptPromise getAssertion(ScriptState*, | 53 ScriptPromise getAssertion(ScriptState*, |
| 49 const BufferSource&, | 54 const BufferSource&, |
| 50 const AuthenticationAssertionOptions&); | 55 const AuthenticationAssertionOptions&); |
| 51 | 56 |
| 52 // ContextLifecycleObserver overrides. | |
| 53 void contextDestroyed(ExecutionContext*) override; | |
| 54 | |
| 55 webauth::mojom::blink::Authenticator* authenticator() const { | 57 webauth::mojom::blink::Authenticator* authenticator() const { |
| 56 return m_authenticator.get(); | 58 return m_authenticator.get(); |
| 57 } | 59 } |
| 58 | 60 |
| 59 void onMakeCredential(ScriptPromiseResolver*, | 61 // ContextLifecycleObserver overrides. |
| 60 Vector<webauth::mojom::blink::ScopedCredentialInfoPtr>); | 62 void ContextDestroyed(ExecutionContext*) override; |
| 61 bool markRequestComplete(ScriptPromiseResolver*); | |
| 62 | |
| 63 void onAuthenticatorConnectionError(); | |
| 64 | 63 |
| 65 DECLARE_VIRTUAL_TRACE(); | 64 DECLARE_VIRTUAL_TRACE(); |
| 66 | 65 |
| 67 private: | 66 private: |
| 68 explicit WebAuthentication(LocalFrame&); | 67 explicit WebAuthentication(LocalFrame&); |
| 69 | 68 |
| 69 void onMakeCredential(ScriptPromiseResolver*, |
| 70 webauth::mojom::blink::AuthenticatorStatus, |
| 71 webauth::mojom::blink::ScopedCredentialInfoPtr); |
| 72 ScriptPromise rejectIfNotSupported(ScriptState*); |
| 73 void onAuthenticatorConnectionError(); |
| 74 bool markRequestComplete(ScriptPromiseResolver*); |
| 75 void cleanup(); |
| 76 |
| 70 webauth::mojom::blink::AuthenticatorPtr m_authenticator; | 77 webauth::mojom::blink::AuthenticatorPtr m_authenticator; |
| 71 HeapHashSet<Member<ScriptPromiseResolver>> m_authenticatorRequests; | 78 HeapHashSet<Member<ScriptPromiseResolver>> m_authenticatorRequests; |
| 72 }; | 79 }; |
| 73 | 80 |
| 74 } // namespace blink | 81 } // namespace blink |
| 75 | 82 |
| 76 #endif // WebAuthentication_h | 83 #endif // WebAuthentication_h |
| OLD | NEW |