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