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