| Index: components/proximity_auth/webui/proximity_auth_webui_handler.h
|
| diff --git a/components/proximity_auth/webui/proximity_auth_webui_handler.h b/components/proximity_auth/webui/proximity_auth_webui_handler.h
|
| index 70e9894c50a4c2f3c22cbccfa065a2dcc93190c6..708a63a301c423771b7221d9bbceafbdffd46301 100644
|
| --- a/components/proximity_auth/webui/proximity_auth_webui_handler.h
|
| +++ b/components/proximity_auth/webui/proximity_auth_webui_handler.h
|
| @@ -7,6 +7,9 @@
|
|
|
| #include "base/memory/weak_ptr.h"
|
| #include "base/values.h"
|
| +#include "components/proximity_auth/authenticator.h"
|
| +#include "components/proximity_auth/client_observer.h"
|
| +#include "components/proximity_auth/connection_observer.h"
|
| #include "components/proximity_auth/cryptauth/cryptauth_client.h"
|
| #include "components/proximity_auth/cryptauth/cryptauth_device_manager.h"
|
| #include "components/proximity_auth/cryptauth/cryptauth_enrollment_manager.h"
|
| @@ -21,11 +24,19 @@ class ListValue;
|
|
|
| namespace proximity_auth {
|
|
|
| +class Authenticator;
|
| +class BluetoothConnection;
|
| +class ClientImpl;
|
| +struct RemoteStatusUpdate;
|
| +class SecureContext;
|
| +
|
| // Handles messages from the chrome://proximity-auth page.
|
| class ProximityAuthWebUIHandler : public content::WebUIMessageHandler,
|
| public LogBuffer::Observer,
|
| public CryptAuthEnrollmentManager::Observer,
|
| - public CryptAuthDeviceManager::Observer {
|
| + public CryptAuthDeviceManager::Observer,
|
| + public ConnectionObserver,
|
| + public ClientObserver {
|
| public:
|
| // |delegate| is not owned and must outlive this instance.
|
| explicit ProximityAuthWebUIHandler(ProximityAuthUIDelegate* delegate);
|
| @@ -53,9 +64,10 @@ class ProximityAuthWebUIHandler : public content::WebUIMessageHandler,
|
| void GetLogMessages(const base::ListValue* args);
|
| void ClearLogBuffer(const base::ListValue* args);
|
| void FindEligibleUnlockDevices(const base::ListValue* args);
|
| - void GetSyncStates(const base::ListValue* args);
|
| + void GetLocalState(const base::ListValue* args);
|
| void ForceEnrollment(const base::ListValue* args);
|
| void ForceDeviceSync(const base::ListValue* args);
|
| + void ToggleConnection(const base::ListValue* args);
|
|
|
| // Initializes CryptAuth managers, used for development purposes.
|
| void InitGCMManager();
|
| @@ -69,12 +81,49 @@ class ProximityAuthWebUIHandler : public content::WebUIMessageHandler,
|
| void OnFoundEligibleUnlockDevices(
|
| const cryptauth::FindEligibleUnlockDevicesResponse& response);
|
|
|
| + // Called when the key agreement of PSK of the remote device completes.
|
| + void OnPSKDerived(const cryptauth::ExternalDeviceInfo& unlock_key,
|
| + const std::string& persistent_symmetric_key);
|
| +
|
| + // Callbacks for bluetooth_util::SeekDeviceByAddress().
|
| + void OnSeekedDeviceByAddress();
|
| + void OnSeekedDeviceByAddressError(const std::string& error_message);
|
| +
|
| + // Callback when |authenticator_| completes authentication.
|
| + void OnAuthenticationResult(Authenticator::Result result,
|
| + scoped_ptr<SecureContext> secure_context);
|
| +
|
| + // Creates the client which parses status updates.
|
| + void CreateStatusUpdateClient();
|
| +
|
| + // Converts an ExternalDeviceInfo proto to a JSON dictionary used in
|
| + // JavaScript.
|
| + scoped_ptr<base::DictionaryValue> ExternalDeviceInfoToDictionary(
|
| + const cryptauth::ExternalDeviceInfo& device_info);
|
| +
|
| + // Converts an IneligibleDevice proto to a JSON dictionary used in JavaScript.
|
| + scoped_ptr<base::DictionaryValue> IneligibleDeviceToDictionary(
|
| + const cryptauth::IneligibleDevice& ineligible_device);
|
| +
|
| + // ConnectionObserver:
|
| + void OnConnectionStatusChanged(Connection* connection,
|
| + Connection::Status old_status,
|
| + Connection::Status new_status) override;
|
| + void OnMessageReceived(const Connection& connection,
|
| + const WireMessage& message) override;
|
| +
|
| + // ClientObserver:
|
| + void OnRemoteStatusUpdate(const RemoteStatusUpdate& status_update) override;
|
| +
|
| // Returns the current enrollment state that can be used as a JSON object.
|
| scoped_ptr<base::DictionaryValue> GetEnrollmentStateDictionary();
|
|
|
| // Returns the current device sync state that can be used as a JSON object.
|
| scoped_ptr<base::DictionaryValue> GetDeviceSyncStateDictionary();
|
|
|
| + // Returns the current unlock keys that can be used as a JSON object.
|
| + scoped_ptr<base::ListValue> GetUnlockKeysList();
|
| +
|
| // The delegate used to fetch dependencies. Must outlive this instance.
|
| ProximityAuthUIDelegate* delegate_;
|
|
|
| @@ -84,11 +133,23 @@ class ProximityAuthWebUIHandler : public content::WebUIMessageHandler,
|
| // We only support one concurrent API call.
|
| scoped_ptr<CryptAuthClient> cryptauth_client_;
|
|
|
| + // Member variables related to CryptAuth debugging.
|
| // TODO(tengs): These members are temporarily used for development.
|
| scoped_ptr<PrefService> pref_service;
|
| scoped_ptr<CryptAuthGCMManager> gcm_manager_;
|
| scoped_ptr<CryptAuthEnrollmentManager> enrollment_manager_;
|
| scoped_ptr<CryptAuthDeviceManager> device_manager_;
|
| + std::string user_public_key_;
|
| + std::string user_private_key_;
|
| +
|
| + // Member variables for connecting to and authenticating the remote device.
|
| + // TODO(tengs): Support multiple simultaenous connections.
|
| + scoped_ptr<SecureMessageDelegate> secure_message_delegate_;
|
| + scoped_ptr<BluetoothConnection> bluetooth_connection_;
|
| + scoped_ptr<Authenticator> authenticator_;
|
| + scoped_ptr<SecureContext> secure_context_;
|
| + scoped_ptr<ClientImpl> client_;
|
| + scoped_ptr<RemoteStatusUpdate> last_remote_status_update_;
|
|
|
| base::WeakPtrFactory<ProximityAuthWebUIHandler> weak_ptr_factory_;
|
|
|
|
|