| 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 COMPONENTS_PROXIMITY_AUTH_WEBUI_PROXIMITY_AUTH_WEBUI_HANDLER_H_ | 5 #ifndef COMPONENTS_PROXIMITY_AUTH_WEBUI_PROXIMITY_AUTH_WEBUI_HANDLER_H_ |
| 6 #define COMPONENTS_PROXIMITY_AUTH_WEBUI_PROXIMITY_AUTH_WEBUI_HANDLER_H_ | 6 #define COMPONENTS_PROXIMITY_AUTH_WEBUI_PROXIMITY_AUTH_WEBUI_HANDLER_H_ |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| 11 #include "components/cryptauth/cryptauth_client.h" |
| 12 #include "components/cryptauth/cryptauth_device_manager.h" |
| 13 #include "components/cryptauth/cryptauth_enrollment_manager.h" |
| 14 #include "components/cryptauth/cryptauth_gcm_manager.h" |
| 11 #include "components/proximity_auth/authenticator.h" | 15 #include "components/proximity_auth/authenticator.h" |
| 12 #include "components/proximity_auth/connection_observer.h" | 16 #include "components/proximity_auth/connection_observer.h" |
| 13 #include "components/proximity_auth/cryptauth/cryptauth_client.h" | |
| 14 #include "components/proximity_auth/cryptauth/cryptauth_device_manager.h" | |
| 15 #include "components/proximity_auth/cryptauth/cryptauth_enrollment_manager.h" | |
| 16 #include "components/proximity_auth/cryptauth/cryptauth_gcm_manager.h" | |
| 17 #include "components/proximity_auth/logging/log_buffer.h" | 17 #include "components/proximity_auth/logging/log_buffer.h" |
| 18 #include "components/proximity_auth/messenger_observer.h" | 18 #include "components/proximity_auth/messenger_observer.h" |
| 19 #include "components/proximity_auth/proximity_auth_client.h" | 19 #include "components/proximity_auth/proximity_auth_client.h" |
| 20 #include "components/proximity_auth/remote_device_life_cycle.h" | 20 #include "components/proximity_auth/remote_device_life_cycle.h" |
| 21 #include "content/public/browser/web_ui_message_handler.h" | 21 #include "content/public/browser/web_ui_message_handler.h" |
| 22 | 22 |
| 23 namespace base { | 23 namespace base { |
| 24 class ListValue; | 24 class ListValue; |
| 25 } | 25 } |
| 26 | 26 |
| 27 namespace cryptauth { | 27 namespace cryptauth { |
| 28 class ExternalDeviceInfo; | 28 class ExternalDeviceInfo; |
| 29 } | 29 } |
| 30 | 30 |
| 31 namespace proximity_auth { | 31 namespace proximity_auth { |
| 32 | 32 |
| 33 class ReachablePhoneFlow; | 33 class ReachablePhoneFlow; |
| 34 class RemoteDeviceLifeCycle; | 34 class RemoteDeviceLifeCycle; |
| 35 class RemoteDeviceLoader; | 35 class RemoteDeviceLoader; |
| 36 struct RemoteStatusUpdate; | 36 struct RemoteStatusUpdate; |
| 37 | 37 |
| 38 // Handles messages from the chrome://proximity-auth page. | 38 // Handles messages from the chrome://proximity-auth page. |
| 39 class ProximityAuthWebUIHandler : public content::WebUIMessageHandler, | 39 class ProximityAuthWebUIHandler |
| 40 public LogBuffer::Observer, | 40 : public content::WebUIMessageHandler, |
| 41 public CryptAuthEnrollmentManager::Observer, | 41 public LogBuffer::Observer, |
| 42 public CryptAuthDeviceManager::Observer, | 42 public cryptauth::CryptAuthEnrollmentManager::Observer, |
| 43 public RemoteDeviceLifeCycle::Observer, | 43 public cryptauth::CryptAuthDeviceManager::Observer, |
| 44 public MessengerObserver { | 44 public RemoteDeviceLifeCycle::Observer, |
| 45 public MessengerObserver { |
| 45 public: | 46 public: |
| 46 // |client_| is not owned and must outlive this instance. | 47 // |client_| is not owned and must outlive this instance. |
| 47 explicit ProximityAuthWebUIHandler( | 48 explicit ProximityAuthWebUIHandler( |
| 48 ProximityAuthClient* proximity_auth_client); | 49 ProximityAuthClient* proximity_auth_client); |
| 49 ~ProximityAuthWebUIHandler() override; | 50 ~ProximityAuthWebUIHandler() override; |
| 50 | 51 |
| 51 // content::WebUIMessageHandler: | 52 // content::WebUIMessageHandler: |
| 52 void RegisterMessages() override; | 53 void RegisterMessages() override; |
| 53 | 54 |
| 54 private: | 55 private: |
| 55 // LogBuffer::Observer: | 56 // LogBuffer::Observer: |
| 56 void OnLogMessageAdded(const LogBuffer::LogMessage& log_message) override; | 57 void OnLogMessageAdded(const LogBuffer::LogMessage& log_message) override; |
| 57 void OnLogBufferCleared() override; | 58 void OnLogBufferCleared() override; |
| 58 | 59 |
| 59 // CryptAuthEnrollmentManager::Observer: | 60 // CryptAuthEnrollmentManager::Observer: |
| 60 void OnEnrollmentStarted() override; | 61 void OnEnrollmentStarted() override; |
| 61 void OnEnrollmentFinished(bool success) override; | 62 void OnEnrollmentFinished(bool success) override; |
| 62 | 63 |
| 63 // CryptAuthDeviceManager::Observer: | 64 // CryptAuthDeviceManager::Observer: |
| 64 void OnSyncStarted() override; | 65 void OnSyncStarted() override; |
| 65 void OnSyncFinished( | 66 void OnSyncFinished(cryptauth::CryptAuthDeviceManager::SyncResult sync_result, |
| 66 CryptAuthDeviceManager::SyncResult sync_result, | 67 cryptauth::CryptAuthDeviceManager::DeviceChangeResult |
| 67 CryptAuthDeviceManager::DeviceChangeResult device_change_result) override; | 68 device_change_result) override; |
| 68 | 69 |
| 69 // Message handler callbacks. | 70 // Message handler callbacks. |
| 70 void OnWebContentsInitialized(const base::ListValue* args); | 71 void OnWebContentsInitialized(const base::ListValue* args); |
| 71 void GetLogMessages(const base::ListValue* args); | 72 void GetLogMessages(const base::ListValue* args); |
| 72 void ClearLogBuffer(const base::ListValue* args); | 73 void ClearLogBuffer(const base::ListValue* args); |
| 73 void ToggleUnlockKey(const base::ListValue* args); | 74 void ToggleUnlockKey(const base::ListValue* args); |
| 74 void FindEligibleUnlockDevices(const base::ListValue* args); | 75 void FindEligibleUnlockDevices(const base::ListValue* args); |
| 75 void FindReachableDevices(const base::ListValue* args); | 76 void FindReachableDevices(const base::ListValue* args); |
| 76 void GetLocalState(const base::ListValue* args); | 77 void GetLocalState(const base::ListValue* args); |
| 77 void ForceEnrollment(const base::ListValue* args); | 78 void ForceEnrollment(const base::ListValue* args); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 // Returns the current device sync state that can be used as a JSON object. | 126 // Returns the current device sync state that can be used as a JSON object. |
| 126 std::unique_ptr<base::DictionaryValue> GetDeviceSyncStateDictionary(); | 127 std::unique_ptr<base::DictionaryValue> GetDeviceSyncStateDictionary(); |
| 127 | 128 |
| 128 // Returns the current unlock keys that can be used as a JSON object. | 129 // Returns the current unlock keys that can be used as a JSON object. |
| 129 std::unique_ptr<base::ListValue> GetUnlockKeysList(); | 130 std::unique_ptr<base::ListValue> GetUnlockKeysList(); |
| 130 | 131 |
| 131 // The delegate used to fetch dependencies. Must outlive this instance. | 132 // The delegate used to fetch dependencies. Must outlive this instance. |
| 132 ProximityAuthClient* proximity_auth_client_; | 133 ProximityAuthClient* proximity_auth_client_; |
| 133 | 134 |
| 134 // Creates CryptAuth client instances to make API calls. | 135 // Creates CryptAuth client instances to make API calls. |
| 135 std::unique_ptr<CryptAuthClientFactory> cryptauth_client_factory_; | 136 std::unique_ptr<cryptauth::CryptAuthClientFactory> cryptauth_client_factory_; |
| 136 | 137 |
| 137 // We only support one concurrent API call. | 138 // We only support one concurrent API call. |
| 138 std::unique_ptr<CryptAuthClient> cryptauth_client_; | 139 std::unique_ptr<cryptauth::CryptAuthClient> cryptauth_client_; |
| 139 | 140 |
| 140 // The flow for getting a list of reachable phones. | 141 // The flow for getting a list of reachable phones. |
| 141 std::unique_ptr<ReachablePhoneFlow> reachable_phone_flow_; | 142 std::unique_ptr<ReachablePhoneFlow> reachable_phone_flow_; |
| 142 | 143 |
| 143 // True if we get a message from the loaded WebContents to know that it is | 144 // True if we get a message from the loaded WebContents to know that it is |
| 144 // initialized, and we can inject JavaScript. | 145 // initialized, and we can inject JavaScript. |
| 145 bool web_contents_initialized_; | 146 bool web_contents_initialized_; |
| 146 | 147 |
| 147 // Member variables for connecting to and authenticating the remote device. | 148 // Member variables for connecting to and authenticating the remote device. |
| 148 // TODO(tengs): Support multiple simultaenous connections. | 149 // TODO(tengs): Support multiple simultaenous connections. |
| 149 std::unique_ptr<RemoteDeviceLoader> remote_device_loader_; | 150 std::unique_ptr<RemoteDeviceLoader> remote_device_loader_; |
| 150 RemoteDevice selected_remote_device_; | 151 RemoteDevice selected_remote_device_; |
| 151 std::unique_ptr<RemoteDeviceLifeCycle> life_cycle_; | 152 std::unique_ptr<RemoteDeviceLifeCycle> life_cycle_; |
| 152 std::unique_ptr<RemoteStatusUpdate> last_remote_status_update_; | 153 std::unique_ptr<RemoteStatusUpdate> last_remote_status_update_; |
| 153 | 154 |
| 154 base::WeakPtrFactory<ProximityAuthWebUIHandler> weak_ptr_factory_; | 155 base::WeakPtrFactory<ProximityAuthWebUIHandler> weak_ptr_factory_; |
| 155 | 156 |
| 156 DISALLOW_COPY_AND_ASSIGN(ProximityAuthWebUIHandler); | 157 DISALLOW_COPY_AND_ASSIGN(ProximityAuthWebUIHandler); |
| 157 }; | 158 }; |
| 158 | 159 |
| 159 } // namespace proximity_auth | 160 } // namespace proximity_auth |
| 160 | 161 |
| 161 #endif // COMPONENTS_PROXIMITY_AUTH_WEBUI_PROXIMITY_AUTH_WEBUI_HANDLER_H_ | 162 #endif // COMPONENTS_PROXIMITY_AUTH_WEBUI_PROXIMITY_AUTH_WEBUI_HANDLER_H_ |
| OLD | NEW |