| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "components/webauth/authenticator.mojom-blink.h" | |
| 11 #include "core/dom/ContextLifecycleObserver.h" | 10 #include "core/dom/ContextLifecycleObserver.h" |
| 12 #include "core/dom/DOMArrayBuffer.h" | 11 #include "core/dom/DOMArrayBuffer.h" |
| 13 #include "modules/webauth/AuthenticationAssertionOptions.h" | 12 #include "modules/webauth/AuthenticationAssertionOptions.h" |
| 14 #include "modules/webauth/ScopedCredentialInfo.h" | 13 #include "modules/webauth/ScopedCredentialInfo.h" |
| 15 #include "platform/bindings/ScriptWrappable.h" | 14 #include "platform/bindings/ScriptWrappable.h" |
| 15 #include "public/platform/modules/webauth/authenticator.mojom-blink.h" |
| 16 | 16 |
| 17 namespace blink { | 17 namespace blink { |
| 18 | 18 |
| 19 class RelyingPartyAccount; | 19 class RelyingPartyAccount; |
| 20 class AuthenticationAssertionOptions; | 20 class AuthenticationAssertionOptions; |
| 21 class ScopedCredentialOptions; | 21 class ScopedCredentialOptions; |
| 22 class ScopedCredentialParameters; | 22 class ScopedCredentialParameters; |
| 23 class ScriptPromiseResolver; | 23 class ScriptPromiseResolver; |
| 24 | 24 |
| 25 typedef ArrayBufferOrArrayBufferView BufferSource; | 25 typedef ArrayBufferOrArrayBufferView BufferSource; |
| 26 | 26 |
| 27 class WebAuthentication final | 27 class WebAuthentication final |
| 28 : public GarbageCollectedFinalized<WebAuthentication>, | 28 : public GarbageCollectedFinalized<WebAuthentication>, |
| 29 public ScriptWrappable, | 29 public ScriptWrappable, |
| 30 public ContextLifecycleObserver { | 30 public ContextLifecycleObserver { |
| 31 DEFINE_WRAPPERTYPEINFO(); | 31 DEFINE_WRAPPERTYPEINFO(); |
| 32 USING_GARBAGE_COLLECTED_MIXIN(WebAuthentication); | 32 USING_GARBAGE_COLLECTED_MIXIN(WebAuthentication); |
| 33 | 33 |
| 34 public: | 34 public: |
| 35 static WebAuthentication* Create(LocalFrame& frame) { | 35 static WebAuthentication* Create(LocalFrame& frame) { |
| 36 return new WebAuthentication(frame); | 36 return new WebAuthentication(frame); |
| 37 } | 37 } |
| 38 | 38 |
| 39 virtual ~WebAuthentication(); | 39 virtual ~WebAuthentication(); |
| 40 | 40 |
| 41 void Dispose(); | |
| 42 | |
| 43 // WebAuthentication.idl | 41 // WebAuthentication.idl |
| 44 ScriptPromise makeCredential(ScriptState*, | 42 ScriptPromise makeCredential(ScriptState*, |
| 45 const RelyingPartyAccount&, | 43 const RelyingPartyAccount&, |
| 46 const HeapVector<ScopedCredentialParameters>, | 44 const HeapVector<ScopedCredentialParameters>, |
| 47 const BufferSource&, | 45 const BufferSource&, |
| 48 ScopedCredentialOptions&); | 46 ScopedCredentialOptions&); |
| 49 ScriptPromise getAssertion(ScriptState*, | 47 ScriptPromise getAssertion(ScriptState*, |
| 50 const BufferSource&, | 48 const BufferSource&, |
| 51 const AuthenticationAssertionOptions&); | 49 const AuthenticationAssertionOptions&); |
| 52 | 50 |
| 53 // ContextLifecycleObserver overrides. | |
| 54 void ContextDestroyed(ExecutionContext*) override; | |
| 55 | |
| 56 webauth::mojom::blink::Authenticator* Authenticator() const { | 51 webauth::mojom::blink::Authenticator* Authenticator() const { |
| 57 return authenticator_.get(); | 52 return authenticator_.get(); |
| 58 } | 53 } |
| 59 | 54 |
| 60 void OnMakeCredential(ScriptPromiseResolver*, | 55 // ContextLifecycleObserver overrides. |
| 61 Vector<webauth::mojom::blink::ScopedCredentialInfoPtr>); | 56 void ContextDestroyed(ExecutionContext*) override; |
| 62 bool MarkRequestComplete(ScriptPromiseResolver*); | |
| 63 | |
| 64 void OnAuthenticatorConnectionError(); | |
| 65 | 57 |
| 66 DECLARE_VIRTUAL_TRACE(); | 58 DECLARE_VIRTUAL_TRACE(); |
| 67 | 59 |
| 68 private: | 60 private: |
| 69 explicit WebAuthentication(LocalFrame&); | 61 explicit WebAuthentication(LocalFrame&); |
| 70 | 62 |
| 63 void OnMakeCredential(ScriptPromiseResolver*, |
| 64 webauth::mojom::blink::AuthenticatorStatus, |
| 65 webauth::mojom::blink::ScopedCredentialInfoPtr); |
| 66 ScriptPromise RejectIfNotSupported(ScriptState*); |
| 67 void OnAuthenticatorConnectionError(); |
| 68 bool MarkRequestComplete(ScriptPromiseResolver*); |
| 69 void Cleanup(); |
| 70 |
| 71 webauth::mojom::blink::AuthenticatorPtr authenticator_; | 71 webauth::mojom::blink::AuthenticatorPtr authenticator_; |
| 72 HeapHashSet<Member<ScriptPromiseResolver>> authenticator_requests_; | 72 HeapHashSet<Member<ScriptPromiseResolver>> authenticator_requests_; |
| 73 }; | 73 }; |
| 74 } // namespace blink | 74 } // namespace blink |
| 75 | 75 |
| 76 #endif // WebAuthentication_h | 76 #endif // WebAuthentication_h |
| OLD | NEW |