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/memory/weak_ptr.h" | 8 #include "base/memory/weak_ptr.h" |
9 #include "base/values.h" | 9 #include "base/values.h" |
10 #include "components/proximity_auth/authenticator.h" | 10 #include "components/proximity_auth/authenticator.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 } | 23 } |
24 | 24 |
25 namespace cryptauth { | 25 namespace cryptauth { |
26 class ExternalDeviceInfo; | 26 class ExternalDeviceInfo; |
27 } | 27 } |
28 | 28 |
29 namespace proximity_auth { | 29 namespace proximity_auth { |
30 | 30 |
31 class Authenticator; | 31 class Authenticator; |
32 class BluetoothConnection; | 32 class BluetoothConnection; |
| 33 class BluetoothThrottler; |
| 34 class BluetoothLowEnergyDeviceWhitelist; |
33 class Connection; | 35 class Connection; |
| 36 class ConnectionFinder; |
34 class ClientImpl; | 37 class ClientImpl; |
35 class ReachablePhoneFlow; | 38 class ReachablePhoneFlow; |
36 struct RemoteStatusUpdate; | 39 struct RemoteStatusUpdate; |
37 class SecureContext; | 40 class SecureContext; |
38 | 41 |
39 // Handles messages from the chrome://proximity-auth page. | 42 // Handles messages from the chrome://proximity-auth page. |
40 class ProximityAuthWebUIHandler : public content::WebUIMessageHandler, | 43 class ProximityAuthWebUIHandler : public content::WebUIMessageHandler, |
41 public LogBuffer::Observer, | 44 public LogBuffer::Observer, |
42 public CryptAuthEnrollmentManager::Observer, | 45 public CryptAuthEnrollmentManager::Observer, |
43 public CryptAuthDeviceManager::Observer, | 46 public CryptAuthDeviceManager::Observer, |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 const cryptauth::FindEligibleUnlockDevicesResponse& response); | 96 const cryptauth::FindEligibleUnlockDevicesResponse& response); |
94 | 97 |
95 // Callback when |reachable_phone_flow_| completes. | 98 // Callback when |reachable_phone_flow_| completes. |
96 void OnReachablePhonesFound( | 99 void OnReachablePhonesFound( |
97 const std::vector<cryptauth::ExternalDeviceInfo>& reachable_phones); | 100 const std::vector<cryptauth::ExternalDeviceInfo>& reachable_phones); |
98 | 101 |
99 // Called when the key agreement of PSK of the remote device completes. | 102 // Called when the key agreement of PSK of the remote device completes. |
100 void OnPSKDerived(const cryptauth::ExternalDeviceInfo& unlock_key, | 103 void OnPSKDerived(const cryptauth::ExternalDeviceInfo& unlock_key, |
101 const std::string& persistent_symmetric_key); | 104 const std::string& persistent_symmetric_key); |
102 | 105 |
103 // Callbacks for bluetooth_util::SeekDeviceByAddress(). | 106 // Tries to create a classic Bluetooth connection to the unlock key. |
104 void OnSeekedDeviceByAddress(); | 107 void FindBluetoothClassicConnection(const RemoteDevice& remote_device); |
105 void OnSeekedDeviceByAddressError(const std::string& error_message); | 108 |
| 109 // Tries to create a Bluetooth Low Energy connection to the unlock key. |
| 110 void FindBluetoothLowEnergyConnection(const RemoteDevice& remote_device); |
| 111 |
| 112 // Called when |connection_finder_| finds a connection. |
| 113 void OnConnectionFound(scoped_ptr<Connection> connection); |
106 | 114 |
107 // Callback when |authenticator_| completes authentication. | 115 // Callback when |authenticator_| completes authentication. |
108 void OnAuthenticationResult(Authenticator::Result result, | 116 void OnAuthenticationResult(Authenticator::Result result, |
109 scoped_ptr<SecureContext> secure_context); | 117 scoped_ptr<SecureContext> secure_context); |
110 | 118 |
111 // Creates the client which parses status updates. | 119 // Creates the client which parses status updates. |
112 void CreateStatusUpdateClient(); | 120 void CreateStatusUpdateClient(); |
113 | 121 |
114 // Returns the active connection, whether it's owned the |this| instance or | 122 // Returns the active connection, whether it's owned the |this| instance or |
115 // |client_|. | 123 // |client_|. |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 | 156 |
149 // Creates CryptAuth client instances to make API calls. | 157 // Creates CryptAuth client instances to make API calls. |
150 scoped_ptr<CryptAuthClientFactory> cryptauth_client_factory_; | 158 scoped_ptr<CryptAuthClientFactory> cryptauth_client_factory_; |
151 | 159 |
152 // We only support one concurrent API call. | 160 // We only support one concurrent API call. |
153 scoped_ptr<CryptAuthClient> cryptauth_client_; | 161 scoped_ptr<CryptAuthClient> cryptauth_client_; |
154 | 162 |
155 // The flow for getting a list of reachable phones. | 163 // The flow for getting a list of reachable phones. |
156 scoped_ptr<ReachablePhoneFlow> reachable_phone_flow_; | 164 scoped_ptr<ReachablePhoneFlow> reachable_phone_flow_; |
157 | 165 |
158 // True if the WebContents backing the WebUI has been initialized. | |
159 bool web_contents_initialized_; | |
160 | |
161 // Member variables related to CryptAuth debugging. | 166 // Member variables related to CryptAuth debugging. |
162 // TODO(tengs): These members are temporarily used for development. | 167 // TODO(tengs): These members are temporarily used for development. |
163 scoped_ptr<PrefService> pref_service; | 168 scoped_ptr<PrefService> pref_service; |
164 scoped_ptr<CryptAuthGCMManager> gcm_manager_; | 169 scoped_ptr<CryptAuthGCMManager> gcm_manager_; |
165 scoped_ptr<CryptAuthEnrollmentManager> enrollment_manager_; | 170 scoped_ptr<CryptAuthEnrollmentManager> enrollment_manager_; |
166 scoped_ptr<CryptAuthDeviceManager> device_manager_; | 171 scoped_ptr<CryptAuthDeviceManager> device_manager_; |
167 std::string user_public_key_; | 172 std::string user_public_key_; |
168 std::string user_private_key_; | 173 std::string user_private_key_; |
169 | 174 |
170 // Member variables for connecting to and authenticating the remote device. | 175 // Member variables for connecting to and authenticating the remote device. |
171 // TODO(tengs): Support multiple simultaenous connections. | 176 // TODO(tengs): Support multiple simultaenous connections. |
172 scoped_ptr<SecureMessageDelegate> secure_message_delegate_; | 177 scoped_ptr<SecureMessageDelegate> secure_message_delegate_; |
173 scoped_ptr<BluetoothConnection> bluetooth_connection_; | 178 scoped_ptr<BluetoothLowEnergyDeviceWhitelist> ble_device_whitelist_; |
| 179 RemoteDevice selected_remote_device_; |
| 180 scoped_ptr<BluetoothThrottler> bluetooth_throttler_; |
| 181 scoped_ptr<ConnectionFinder> connection_finder_; |
| 182 scoped_ptr<Connection> connection_; |
174 scoped_ptr<Authenticator> authenticator_; | 183 scoped_ptr<Authenticator> authenticator_; |
175 scoped_ptr<SecureContext> secure_context_; | 184 scoped_ptr<SecureContext> secure_context_; |
176 scoped_ptr<ClientImpl> client_; | 185 scoped_ptr<ClientImpl> client_; |
177 scoped_ptr<RemoteStatusUpdate> last_remote_status_update_; | 186 scoped_ptr<RemoteStatusUpdate> last_remote_status_update_; |
178 | 187 |
179 base::WeakPtrFactory<ProximityAuthWebUIHandler> weak_ptr_factory_; | 188 base::WeakPtrFactory<ProximityAuthWebUIHandler> weak_ptr_factory_; |
180 | 189 |
181 DISALLOW_COPY_AND_ASSIGN(ProximityAuthWebUIHandler); | 190 DISALLOW_COPY_AND_ASSIGN(ProximityAuthWebUIHandler); |
182 }; | 191 }; |
183 | 192 |
184 } // namespace proximity_auth | 193 } // namespace proximity_auth |
185 | 194 |
186 #endif // COMPONENTS_PROXIMITY_AUTH_WEBUI_PROXIMITY_AUTH_WEBUI_HANDLER_H_ | 195 #endif // COMPONENTS_PROXIMITY_AUTH_WEBUI_PROXIMITY_AUTH_WEBUI_HANDLER_H_ |
OLD | NEW |