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