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