OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef COMPONENTS_WEBAUTH_AUTHENTICATOR_IMPL_H_ |
| 6 #define COMPONENTS_WEBAUTH_AUTHENTICATOR_IMPL_H_ |
| 7 |
| 8 #include <vector> |
| 9 |
| 10 #include "base/macros.h" |
| 11 #include "components/webauth/authenticator.mojom.h" |
| 12 #include "content/public/browser/web_contents.h" |
| 13 #include "mojo/public/cpp/bindings/binding.h" |
| 14 #include "mojo/public/cpp/bindings/interface_request.h" |
| 15 |
| 16 namespace content { |
| 17 class RenderFrameHost; |
| 18 } |
| 19 |
| 20 namespace webauth { |
| 21 |
| 22 // Implementation of the public Authenticator interface. |
| 23 class AuthenticatorImpl : public mojom::Authenticator { |
| 24 public: |
| 25 static void Create(content::RenderFrameHost* render_frame_host, |
| 26 mojo::InterfaceRequest<mojom::Authenticator> request); |
| 27 AuthenticatorImpl(content::RenderFrameHost* render_frame_host); |
| 28 ~AuthenticatorImpl() override; |
| 29 |
| 30 void set_connection_error_handler(const base::Closure& error_handler) { |
| 31 connection_error_handler_ = error_handler; |
| 32 } |
| 33 |
| 34 private: |
| 35 // mojom:Authenticator |
| 36 void MakeCredential( |
| 37 mojom::RelyingPartyAccountPtr account, |
| 38 std::vector<mojom::ScopedCredentialParametersPtr> parameters, |
| 39 const std::vector<uint8_t>& challenge, |
| 40 mojom::ScopedCredentialOptionsPtr options, |
| 41 const MakeCredentialCallback& callback) override; |
| 42 |
| 43 // Callback to handle the async response from a U2fDevice. |
| 44 void OnRegister(const MakeCredentialCallback& callback, |
| 45 std::string& clientDataJSON, |
| 46 uint8_t status_code, |
| 47 std::vector<uint8_t> data); |
| 48 |
| 49 void onTimeout(const MakeCredentialCallback& callback); |
| 50 |
| 51 // As a result of a browser-side error or renderer-initiated mojo channel |
| 52 // closure (e.g. there was an error on the renderer side, or payment was |
| 53 // successful), this method is called. It is responsible for cleaning up. |
| 54 void OnConnectionTerminated(); |
| 55 |
| 56 base::Closure connection_error_handler_; |
| 57 base::CancelableClosure timeout_callback_; |
| 58 url::Origin callerOrigin_; |
| 59 DISALLOW_COPY_AND_ASSIGN(AuthenticatorImpl); |
| 60 }; |
| 61 |
| 62 } // namespace webauth |
| 63 |
| 64 #endif // COMPONENTS_WEBAUTH_AUTHENTICATOR_IMPL_H_ |
OLD | NEW |