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 #include "components/proximity_auth/webui/proximity_auth_webui_handler.h" | 5 #include "components/proximity_auth/webui/proximity_auth_webui_handler.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/base64url.h" | 10 #include "base/base64url.h" |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/i18n/time_formatting.h" | 12 #include "base/i18n/time_formatting.h" |
| 13 #include "base/memory/ptr_util.h" |
13 #include "base/thread_task_runner_handle.h" | 14 #include "base/thread_task_runner_handle.h" |
14 #include "base/time/default_clock.h" | 15 #include "base/time/default_clock.h" |
15 #include "base/time/default_tick_clock.h" | 16 #include "base/time/default_tick_clock.h" |
16 #include "base/values.h" | 17 #include "base/values.h" |
17 #include "components/prefs/pref_service.h" | 18 #include "components/prefs/pref_service.h" |
18 #include "components/proximity_auth/ble/pref_names.h" | 19 #include "components/proximity_auth/ble/pref_names.h" |
19 #include "components/proximity_auth/bluetooth_connection_finder.h" | 20 #include "components/proximity_auth/bluetooth_connection_finder.h" |
20 #include "components/proximity_auth/cryptauth/cryptauth_enrollment_manager.h" | 21 #include "components/proximity_auth/cryptauth/cryptauth_enrollment_manager.h" |
21 #include "components/proximity_auth/cryptauth/proto/cryptauth_api.pb.h" | 22 #include "components/proximity_auth/cryptauth/proto/cryptauth_api.pb.h" |
22 #include "components/proximity_auth/cryptauth/secure_message_delegate.h" | 23 #include "components/proximity_auth/cryptauth/secure_message_delegate.h" |
(...skipping 21 matching lines...) Expand all Loading... |
44 | 45 |
45 // Keys in the JSON representation of a SyncState object for enrollment or | 46 // Keys in the JSON representation of a SyncState object for enrollment or |
46 // device sync. | 47 // device sync. |
47 const char kSyncStateLastSuccessTime[] = "lastSuccessTime"; | 48 const char kSyncStateLastSuccessTime[] = "lastSuccessTime"; |
48 const char kSyncStateNextRefreshTime[] = "nextRefreshTime"; | 49 const char kSyncStateNextRefreshTime[] = "nextRefreshTime"; |
49 const char kSyncStateRecoveringFromFailure[] = "recoveringFromFailure"; | 50 const char kSyncStateRecoveringFromFailure[] = "recoveringFromFailure"; |
50 const char kSyncStateOperationInProgress[] = "operationInProgress"; | 51 const char kSyncStateOperationInProgress[] = "operationInProgress"; |
51 | 52 |
52 // Converts |log_message| to a raw dictionary value used as a JSON argument to | 53 // Converts |log_message| to a raw dictionary value used as a JSON argument to |
53 // JavaScript functions. | 54 // JavaScript functions. |
54 scoped_ptr<base::DictionaryValue> LogMessageToDictionary( | 55 std::unique_ptr<base::DictionaryValue> LogMessageToDictionary( |
55 const LogBuffer::LogMessage& log_message) { | 56 const LogBuffer::LogMessage& log_message) { |
56 scoped_ptr<base::DictionaryValue> dictionary(new base::DictionaryValue()); | 57 std::unique_ptr<base::DictionaryValue> dictionary( |
| 58 new base::DictionaryValue()); |
57 dictionary->SetString(kLogMessageTextKey, log_message.text); | 59 dictionary->SetString(kLogMessageTextKey, log_message.text); |
58 dictionary->SetString( | 60 dictionary->SetString( |
59 kLogMessageTimeKey, | 61 kLogMessageTimeKey, |
60 base::TimeFormatTimeOfDayWithMilliseconds(log_message.time)); | 62 base::TimeFormatTimeOfDayWithMilliseconds(log_message.time)); |
61 dictionary->SetString(kLogMessageFileKey, log_message.file); | 63 dictionary->SetString(kLogMessageFileKey, log_message.file); |
62 dictionary->SetInteger(kLogMessageLineKey, log_message.line); | 64 dictionary->SetInteger(kLogMessageLineKey, log_message.line); |
63 dictionary->SetInteger(kLogMessageSeverityKey, | 65 dictionary->SetInteger(kLogMessageSeverityKey, |
64 static_cast<int>(log_message.severity)); | 66 static_cast<int>(log_message.severity)); |
65 return dictionary; | 67 return dictionary; |
66 } | 68 } |
67 | 69 |
68 // Keys in the JSON representation of an ExternalDeviceInfo proto. | 70 // Keys in the JSON representation of an ExternalDeviceInfo proto. |
69 const char kExternalDevicePublicKey[] = "publicKey"; | 71 const char kExternalDevicePublicKey[] = "publicKey"; |
70 const char kExternalDeviceFriendlyName[] = "friendlyDeviceName"; | 72 const char kExternalDeviceFriendlyName[] = "friendlyDeviceName"; |
71 const char kExternalDeviceBluetoothAddress[] = "bluetoothAddress"; | 73 const char kExternalDeviceBluetoothAddress[] = "bluetoothAddress"; |
72 const char kExternalDeviceUnlockKey[] = "unlockKey"; | 74 const char kExternalDeviceUnlockKey[] = "unlockKey"; |
73 const char kExternalDeviceConnectionStatus[] = "connectionStatus"; | 75 const char kExternalDeviceConnectionStatus[] = "connectionStatus"; |
74 const char kExternalDeviceRemoteState[] = "remoteState"; | 76 const char kExternalDeviceRemoteState[] = "remoteState"; |
75 | 77 |
76 // The possible values of the |kExternalDeviceConnectionStatus| field. | 78 // The possible values of the |kExternalDeviceConnectionStatus| field. |
77 const char kExternalDeviceConnected[] = "connected"; | 79 const char kExternalDeviceConnected[] = "connected"; |
78 const char kExternalDeviceDisconnected[] = "disconnected"; | 80 const char kExternalDeviceDisconnected[] = "disconnected"; |
79 const char kExternalDeviceConnecting[] = "connecting"; | 81 const char kExternalDeviceConnecting[] = "connecting"; |
80 | 82 |
81 // Keys in the JSON representation of an IneligibleDevice proto. | 83 // Keys in the JSON representation of an IneligibleDevice proto. |
82 const char kIneligibleDeviceReasons[] = "ineligibilityReasons"; | 84 const char kIneligibleDeviceReasons[] = "ineligibilityReasons"; |
83 | 85 |
84 // Creates a SyncState JSON object that can be passed to the WebUI. | 86 // Creates a SyncState JSON object that can be passed to the WebUI. |
85 scoped_ptr<base::DictionaryValue> CreateSyncStateDictionary( | 87 std::unique_ptr<base::DictionaryValue> CreateSyncStateDictionary( |
86 double last_success_time, | 88 double last_success_time, |
87 double next_refresh_time, | 89 double next_refresh_time, |
88 bool is_recovering_from_failure, | 90 bool is_recovering_from_failure, |
89 bool is_enrollment_in_progress) { | 91 bool is_enrollment_in_progress) { |
90 scoped_ptr<base::DictionaryValue> sync_state(new base::DictionaryValue()); | 92 std::unique_ptr<base::DictionaryValue> sync_state( |
| 93 new base::DictionaryValue()); |
91 sync_state->SetDouble(kSyncStateLastSuccessTime, last_success_time); | 94 sync_state->SetDouble(kSyncStateLastSuccessTime, last_success_time); |
92 sync_state->SetDouble(kSyncStateNextRefreshTime, next_refresh_time); | 95 sync_state->SetDouble(kSyncStateNextRefreshTime, next_refresh_time); |
93 sync_state->SetBoolean(kSyncStateRecoveringFromFailure, | 96 sync_state->SetBoolean(kSyncStateRecoveringFromFailure, |
94 is_recovering_from_failure); | 97 is_recovering_from_failure); |
95 sync_state->SetBoolean(kSyncStateOperationInProgress, | 98 sync_state->SetBoolean(kSyncStateOperationInProgress, |
96 is_enrollment_in_progress); | 99 is_enrollment_in_progress); |
97 return sync_state; | 100 return sync_state; |
98 } | 101 } |
99 | 102 |
100 } // namespace | 103 } // namespace |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 base::Unretained(this))); | 156 base::Unretained(this))); |
154 | 157 |
155 web_ui()->RegisterMessageCallback( | 158 web_ui()->RegisterMessageCallback( |
156 "toggleConnection", | 159 "toggleConnection", |
157 base::Bind(&ProximityAuthWebUIHandler::ToggleConnection, | 160 base::Bind(&ProximityAuthWebUIHandler::ToggleConnection, |
158 base::Unretained(this))); | 161 base::Unretained(this))); |
159 } | 162 } |
160 | 163 |
161 void ProximityAuthWebUIHandler::OnLogMessageAdded( | 164 void ProximityAuthWebUIHandler::OnLogMessageAdded( |
162 const LogBuffer::LogMessage& log_message) { | 165 const LogBuffer::LogMessage& log_message) { |
163 scoped_ptr<base::DictionaryValue> dictionary = | 166 std::unique_ptr<base::DictionaryValue> dictionary = |
164 LogMessageToDictionary(log_message); | 167 LogMessageToDictionary(log_message); |
165 web_ui()->CallJavascriptFunction("LogBufferInterface.onLogMessageAdded", | 168 web_ui()->CallJavascriptFunction("LogBufferInterface.onLogMessageAdded", |
166 *dictionary); | 169 *dictionary); |
167 } | 170 } |
168 | 171 |
169 void ProximityAuthWebUIHandler::OnLogBufferCleared() { | 172 void ProximityAuthWebUIHandler::OnLogBufferCleared() { |
170 web_ui()->CallJavascriptFunction("LogBufferInterface.onLogBufferCleared"); | 173 web_ui()->CallJavascriptFunction("LogBufferInterface.onLogBufferCleared"); |
171 } | 174 } |
172 | 175 |
173 void ProximityAuthWebUIHandler::OnEnrollmentStarted() { | 176 void ProximityAuthWebUIHandler::OnEnrollmentStarted() { |
174 web_ui()->CallJavascriptFunction( | 177 web_ui()->CallJavascriptFunction( |
175 "LocalStateInterface.onEnrollmentStateChanged", | 178 "LocalStateInterface.onEnrollmentStateChanged", |
176 *GetEnrollmentStateDictionary()); | 179 *GetEnrollmentStateDictionary()); |
177 } | 180 } |
178 | 181 |
179 void ProximityAuthWebUIHandler::OnEnrollmentFinished(bool success) { | 182 void ProximityAuthWebUIHandler::OnEnrollmentFinished(bool success) { |
180 scoped_ptr<base::DictionaryValue> enrollment_state = | 183 std::unique_ptr<base::DictionaryValue> enrollment_state = |
181 GetEnrollmentStateDictionary(); | 184 GetEnrollmentStateDictionary(); |
182 PA_LOG(INFO) << "Enrollment attempt completed with success=" << success | 185 PA_LOG(INFO) << "Enrollment attempt completed with success=" << success |
183 << ":\n" << *enrollment_state; | 186 << ":\n" << *enrollment_state; |
184 web_ui()->CallJavascriptFunction( | 187 web_ui()->CallJavascriptFunction( |
185 "LocalStateInterface.onEnrollmentStateChanged", *enrollment_state); | 188 "LocalStateInterface.onEnrollmentStateChanged", *enrollment_state); |
186 } | 189 } |
187 | 190 |
188 void ProximityAuthWebUIHandler::OnSyncStarted() { | 191 void ProximityAuthWebUIHandler::OnSyncStarted() { |
189 web_ui()->CallJavascriptFunction( | 192 web_ui()->CallJavascriptFunction( |
190 "LocalStateInterface.onDeviceSyncStateChanged", | 193 "LocalStateInterface.onDeviceSyncStateChanged", |
191 *GetDeviceSyncStateDictionary()); | 194 *GetDeviceSyncStateDictionary()); |
192 } | 195 } |
193 | 196 |
194 void ProximityAuthWebUIHandler::OnSyncFinished( | 197 void ProximityAuthWebUIHandler::OnSyncFinished( |
195 CryptAuthDeviceManager::SyncResult sync_result, | 198 CryptAuthDeviceManager::SyncResult sync_result, |
196 CryptAuthDeviceManager::DeviceChangeResult device_change_result) { | 199 CryptAuthDeviceManager::DeviceChangeResult device_change_result) { |
197 scoped_ptr<base::DictionaryValue> device_sync_state = | 200 std::unique_ptr<base::DictionaryValue> device_sync_state = |
198 GetDeviceSyncStateDictionary(); | 201 GetDeviceSyncStateDictionary(); |
199 PA_LOG(INFO) << "Device sync completed with result=" | 202 PA_LOG(INFO) << "Device sync completed with result=" |
200 << static_cast<int>(sync_result) << ":\n" << *device_sync_state; | 203 << static_cast<int>(sync_result) << ":\n" << *device_sync_state; |
201 web_ui()->CallJavascriptFunction( | 204 web_ui()->CallJavascriptFunction( |
202 "LocalStateInterface.onDeviceSyncStateChanged", *device_sync_state); | 205 "LocalStateInterface.onDeviceSyncStateChanged", *device_sync_state); |
203 | 206 |
204 if (device_change_result == | 207 if (device_change_result == |
205 CryptAuthDeviceManager::DeviceChangeResult::CHANGED) { | 208 CryptAuthDeviceManager::DeviceChangeResult::CHANGED) { |
206 scoped_ptr<base::ListValue> unlock_keys = GetUnlockKeysList(); | 209 std::unique_ptr<base::ListValue> unlock_keys = GetUnlockKeysList(); |
207 PA_LOG(INFO) << "New unlock keys obtained after device sync:\n" | 210 PA_LOG(INFO) << "New unlock keys obtained after device sync:\n" |
208 << *unlock_keys; | 211 << *unlock_keys; |
209 web_ui()->CallJavascriptFunction("LocalStateInterface.onUnlockKeysChanged", | 212 web_ui()->CallJavascriptFunction("LocalStateInterface.onUnlockKeysChanged", |
210 *unlock_keys); | 213 *unlock_keys); |
211 } | 214 } |
212 } | 215 } |
213 | 216 |
214 void ProximityAuthWebUIHandler::OnWebContentsInitialized( | 217 void ProximityAuthWebUIHandler::OnWebContentsInitialized( |
215 const base::ListValue* args) { | 218 const base::ListValue* args) { |
216 if (!web_contents_initialized_) { | 219 if (!web_contents_initialized_) { |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
397 reachable_phone_flow_.reset(); | 400 reachable_phone_flow_.reset(); |
398 base::ListValue device_list; | 401 base::ListValue device_list; |
399 for (const auto& external_device : reachable_phones) { | 402 for (const auto& external_device : reachable_phones) { |
400 device_list.Append(ExternalDeviceInfoToDictionary(external_device)); | 403 device_list.Append(ExternalDeviceInfoToDictionary(external_device)); |
401 } | 404 } |
402 web_ui()->CallJavascriptFunction("CryptAuthInterface.onGotReachableDevices", | 405 web_ui()->CallJavascriptFunction("CryptAuthInterface.onGotReachableDevices", |
403 device_list); | 406 device_list); |
404 } | 407 } |
405 | 408 |
406 void ProximityAuthWebUIHandler::GetLocalState(const base::ListValue* args) { | 409 void ProximityAuthWebUIHandler::GetLocalState(const base::ListValue* args) { |
407 scoped_ptr<base::DictionaryValue> enrollment_state = | 410 std::unique_ptr<base::DictionaryValue> enrollment_state = |
408 GetEnrollmentStateDictionary(); | 411 GetEnrollmentStateDictionary(); |
409 scoped_ptr<base::DictionaryValue> device_sync_state = | 412 std::unique_ptr<base::DictionaryValue> device_sync_state = |
410 GetDeviceSyncStateDictionary(); | 413 GetDeviceSyncStateDictionary(); |
411 scoped_ptr<base::ListValue> unlock_keys = GetUnlockKeysList(); | 414 std::unique_ptr<base::ListValue> unlock_keys = GetUnlockKeysList(); |
412 | 415 |
413 PA_LOG(INFO) << "==== Got Local State ====\n" | 416 PA_LOG(INFO) << "==== Got Local State ====\n" |
414 << "Enrollment State: \n" << *enrollment_state | 417 << "Enrollment State: \n" << *enrollment_state |
415 << "Device Sync State: \n" << *device_sync_state | 418 << "Device Sync State: \n" << *device_sync_state |
416 << "Unlock Keys: \n" << *unlock_keys; | 419 << "Unlock Keys: \n" << *unlock_keys; |
417 web_ui()->CallJavascriptFunction("LocalStateInterface.onGotLocalState", | 420 web_ui()->CallJavascriptFunction("LocalStateInterface.onGotLocalState", |
418 *enrollment_state, *device_sync_state, | 421 *enrollment_state, *device_sync_state, |
419 *unlock_keys); | 422 *unlock_keys); |
420 } | 423 } |
421 | 424 |
422 scoped_ptr<base::DictionaryValue> | 425 std::unique_ptr<base::DictionaryValue> |
423 ProximityAuthWebUIHandler::GetEnrollmentStateDictionary() { | 426 ProximityAuthWebUIHandler::GetEnrollmentStateDictionary() { |
424 CryptAuthEnrollmentManager* enrollment_manager = | 427 CryptAuthEnrollmentManager* enrollment_manager = |
425 proximity_auth_client_->GetCryptAuthEnrollmentManager(); | 428 proximity_auth_client_->GetCryptAuthEnrollmentManager(); |
426 if (!enrollment_manager) | 429 if (!enrollment_manager) |
427 return make_scoped_ptr(new base::DictionaryValue()); | 430 return base::WrapUnique(new base::DictionaryValue()); |
428 | 431 |
429 return CreateSyncStateDictionary( | 432 return CreateSyncStateDictionary( |
430 enrollment_manager->GetLastEnrollmentTime().ToJsTime(), | 433 enrollment_manager->GetLastEnrollmentTime().ToJsTime(), |
431 enrollment_manager->GetTimeToNextAttempt().InMillisecondsF(), | 434 enrollment_manager->GetTimeToNextAttempt().InMillisecondsF(), |
432 enrollment_manager->IsRecoveringFromFailure(), | 435 enrollment_manager->IsRecoveringFromFailure(), |
433 enrollment_manager->IsEnrollmentInProgress()); | 436 enrollment_manager->IsEnrollmentInProgress()); |
434 } | 437 } |
435 | 438 |
436 scoped_ptr<base::DictionaryValue> | 439 std::unique_ptr<base::DictionaryValue> |
437 ProximityAuthWebUIHandler::GetDeviceSyncStateDictionary() { | 440 ProximityAuthWebUIHandler::GetDeviceSyncStateDictionary() { |
438 CryptAuthDeviceManager* device_manager = | 441 CryptAuthDeviceManager* device_manager = |
439 proximity_auth_client_->GetCryptAuthDeviceManager(); | 442 proximity_auth_client_->GetCryptAuthDeviceManager(); |
440 if (!device_manager) | 443 if (!device_manager) |
441 return make_scoped_ptr(new base::DictionaryValue()); | 444 return base::WrapUnique(new base::DictionaryValue()); |
442 | 445 |
443 return CreateSyncStateDictionary( | 446 return CreateSyncStateDictionary( |
444 device_manager->GetLastSyncTime().ToJsTime(), | 447 device_manager->GetLastSyncTime().ToJsTime(), |
445 device_manager->GetTimeToNextAttempt().InMillisecondsF(), | 448 device_manager->GetTimeToNextAttempt().InMillisecondsF(), |
446 device_manager->IsRecoveringFromFailure(), | 449 device_manager->IsRecoveringFromFailure(), |
447 device_manager->IsSyncInProgress()); | 450 device_manager->IsSyncInProgress()); |
448 } | 451 } |
449 | 452 |
450 scoped_ptr<base::ListValue> ProximityAuthWebUIHandler::GetUnlockKeysList() { | 453 std::unique_ptr<base::ListValue> |
451 scoped_ptr<base::ListValue> unlock_keys(new base::ListValue()); | 454 ProximityAuthWebUIHandler::GetUnlockKeysList() { |
| 455 std::unique_ptr<base::ListValue> unlock_keys(new base::ListValue()); |
452 CryptAuthDeviceManager* device_manager = | 456 CryptAuthDeviceManager* device_manager = |
453 proximity_auth_client_->GetCryptAuthDeviceManager(); | 457 proximity_auth_client_->GetCryptAuthDeviceManager(); |
454 if (!device_manager) | 458 if (!device_manager) |
455 return unlock_keys; | 459 return unlock_keys; |
456 | 460 |
457 for (const auto& unlock_key : device_manager->unlock_keys()) { | 461 for (const auto& unlock_key : device_manager->unlock_keys()) { |
458 unlock_keys->Append(ExternalDeviceInfoToDictionary(unlock_key)); | 462 unlock_keys->Append(ExternalDeviceInfoToDictionary(unlock_key)); |
459 } | 463 } |
460 | 464 |
461 return unlock_keys; | 465 return unlock_keys; |
462 } | 466 } |
463 | 467 |
464 void ProximityAuthWebUIHandler::OnRemoteDevicesLoaded( | 468 void ProximityAuthWebUIHandler::OnRemoteDevicesLoaded( |
465 const std::vector<RemoteDevice>& remote_devices) { | 469 const std::vector<RemoteDevice>& remote_devices) { |
466 if (remote_devices[0].persistent_symmetric_key.empty()) { | 470 if (remote_devices[0].persistent_symmetric_key.empty()) { |
467 PA_LOG(ERROR) << "Failed to derive PSK."; | 471 PA_LOG(ERROR) << "Failed to derive PSK."; |
468 return; | 472 return; |
469 } | 473 } |
470 | 474 |
471 selected_remote_device_ = remote_devices[0]; | 475 selected_remote_device_ = remote_devices[0]; |
472 life_cycle_.reset(new RemoteDeviceLifeCycleImpl(selected_remote_device_, | 476 life_cycle_.reset(new RemoteDeviceLifeCycleImpl(selected_remote_device_, |
473 proximity_auth_client_)); | 477 proximity_auth_client_)); |
474 life_cycle_->AddObserver(this); | 478 life_cycle_->AddObserver(this); |
475 life_cycle_->Start(); | 479 life_cycle_->Start(); |
476 } | 480 } |
477 | 481 |
478 scoped_ptr<base::DictionaryValue> | 482 std::unique_ptr<base::DictionaryValue> |
479 ProximityAuthWebUIHandler::ExternalDeviceInfoToDictionary( | 483 ProximityAuthWebUIHandler::ExternalDeviceInfoToDictionary( |
480 const cryptauth::ExternalDeviceInfo& device_info) { | 484 const cryptauth::ExternalDeviceInfo& device_info) { |
481 std::string base64_public_key; | 485 std::string base64_public_key; |
482 base::Base64UrlEncode(device_info.public_key(), | 486 base::Base64UrlEncode(device_info.public_key(), |
483 base::Base64UrlEncodePolicy::INCLUDE_PADDING, | 487 base::Base64UrlEncodePolicy::INCLUDE_PADDING, |
484 &base64_public_key); | 488 &base64_public_key); |
485 | 489 |
486 // Set the fields in the ExternalDeviceInfo proto. | 490 // Set the fields in the ExternalDeviceInfo proto. |
487 scoped_ptr<base::DictionaryValue> dictionary(new base::DictionaryValue()); | 491 std::unique_ptr<base::DictionaryValue> dictionary( |
| 492 new base::DictionaryValue()); |
488 dictionary->SetString(kExternalDevicePublicKey, base64_public_key); | 493 dictionary->SetString(kExternalDevicePublicKey, base64_public_key); |
489 dictionary->SetString(kExternalDeviceFriendlyName, | 494 dictionary->SetString(kExternalDeviceFriendlyName, |
490 device_info.friendly_device_name()); | 495 device_info.friendly_device_name()); |
491 dictionary->SetString(kExternalDeviceBluetoothAddress, | 496 dictionary->SetString(kExternalDeviceBluetoothAddress, |
492 device_info.bluetooth_address()); | 497 device_info.bluetooth_address()); |
493 dictionary->SetBoolean(kExternalDeviceUnlockKey, device_info.unlock_key()); | 498 dictionary->SetBoolean(kExternalDeviceUnlockKey, device_info.unlock_key()); |
494 dictionary->SetString(kExternalDeviceConnectionStatus, | 499 dictionary->SetString(kExternalDeviceConnectionStatus, |
495 kExternalDeviceDisconnected); | 500 kExternalDeviceDisconnected); |
496 | 501 |
497 CryptAuthDeviceManager* device_manager = | 502 CryptAuthDeviceManager* device_manager = |
(...skipping 22 matching lines...) Expand all Loading... |
520 life_cycle_->GetState() == | 525 life_cycle_->GetState() == |
521 RemoteDeviceLifeCycle::State::SECURE_CHANNEL_ESTABLISHED) { | 526 RemoteDeviceLifeCycle::State::SECURE_CHANNEL_ESTABLISHED) { |
522 connection_status = kExternalDeviceConnected; | 527 connection_status = kExternalDeviceConnected; |
523 } else if (life_cycle_) { | 528 } else if (life_cycle_) { |
524 connection_status = kExternalDeviceConnecting; | 529 connection_status = kExternalDeviceConnecting; |
525 } | 530 } |
526 dictionary->SetString(kExternalDeviceConnectionStatus, connection_status); | 531 dictionary->SetString(kExternalDeviceConnectionStatus, connection_status); |
527 | 532 |
528 // Fill the remote status dictionary. | 533 // Fill the remote status dictionary. |
529 if (last_remote_status_update_) { | 534 if (last_remote_status_update_) { |
530 scoped_ptr<base::DictionaryValue> status_dictionary( | 535 std::unique_ptr<base::DictionaryValue> status_dictionary( |
531 new base::DictionaryValue()); | 536 new base::DictionaryValue()); |
532 status_dictionary->SetInteger("userPresent", | 537 status_dictionary->SetInteger("userPresent", |
533 last_remote_status_update_->user_presence); | 538 last_remote_status_update_->user_presence); |
534 status_dictionary->SetInteger( | 539 status_dictionary->SetInteger( |
535 "secureScreenLock", | 540 "secureScreenLock", |
536 last_remote_status_update_->secure_screen_lock_state); | 541 last_remote_status_update_->secure_screen_lock_state); |
537 status_dictionary->SetInteger( | 542 status_dictionary->SetInteger( |
538 "trustAgent", last_remote_status_update_->trust_agent_state); | 543 "trustAgent", last_remote_status_update_->trust_agent_state); |
539 dictionary->Set(kExternalDeviceRemoteState, std::move(status_dictionary)); | 544 dictionary->Set(kExternalDeviceRemoteState, std::move(status_dictionary)); |
540 } | 545 } |
541 | 546 |
542 return dictionary; | 547 return dictionary; |
543 } | 548 } |
544 | 549 |
545 scoped_ptr<base::DictionaryValue> | 550 std::unique_ptr<base::DictionaryValue> |
546 ProximityAuthWebUIHandler::IneligibleDeviceToDictionary( | 551 ProximityAuthWebUIHandler::IneligibleDeviceToDictionary( |
547 const cryptauth::IneligibleDevice& ineligible_device) { | 552 const cryptauth::IneligibleDevice& ineligible_device) { |
548 scoped_ptr<base::ListValue> ineligibility_reasons(new base::ListValue()); | 553 std::unique_ptr<base::ListValue> ineligibility_reasons(new base::ListValue()); |
549 for (const std::string& reason : ineligible_device.reasons()) { | 554 for (const std::string& reason : ineligible_device.reasons()) { |
550 ineligibility_reasons->AppendString(reason); | 555 ineligibility_reasons->AppendString(reason); |
551 } | 556 } |
552 | 557 |
553 scoped_ptr<base::DictionaryValue> device_dictionary = | 558 std::unique_ptr<base::DictionaryValue> device_dictionary = |
554 ExternalDeviceInfoToDictionary(ineligible_device.device()); | 559 ExternalDeviceInfoToDictionary(ineligible_device.device()); |
555 device_dictionary->Set(kIneligibleDeviceReasons, | 560 device_dictionary->Set(kIneligibleDeviceReasons, |
556 std::move(ineligibility_reasons)); | 561 std::move(ineligibility_reasons)); |
557 return device_dictionary; | 562 return device_dictionary; |
558 } | 563 } |
559 | 564 |
560 void ProximityAuthWebUIHandler::CleanUpRemoteDeviceLifeCycle() { | 565 void ProximityAuthWebUIHandler::CleanUpRemoteDeviceLifeCycle() { |
561 PA_LOG(INFO) << "Cleaning up connection to " << selected_remote_device_.name | 566 PA_LOG(INFO) << "Cleaning up connection to " << selected_remote_device_.name |
562 << " [" << selected_remote_device_.bluetooth_address << "]"; | 567 << " [" << selected_remote_device_.bluetooth_address << "]"; |
563 life_cycle_.reset(); | 568 life_cycle_.reset(); |
(...skipping 30 matching lines...) Expand all Loading... |
594 const RemoteStatusUpdate& status_update) { | 599 const RemoteStatusUpdate& status_update) { |
595 PA_LOG(INFO) << "Remote status update:" | 600 PA_LOG(INFO) << "Remote status update:" |
596 << "\n user_presence: " | 601 << "\n user_presence: " |
597 << static_cast<int>(status_update.user_presence) | 602 << static_cast<int>(status_update.user_presence) |
598 << "\n secure_screen_lock_state: " | 603 << "\n secure_screen_lock_state: " |
599 << static_cast<int>(status_update.secure_screen_lock_state) | 604 << static_cast<int>(status_update.secure_screen_lock_state) |
600 << "\n trust_agent_state: " | 605 << "\n trust_agent_state: " |
601 << static_cast<int>(status_update.trust_agent_state); | 606 << static_cast<int>(status_update.trust_agent_state); |
602 | 607 |
603 last_remote_status_update_.reset(new RemoteStatusUpdate(status_update)); | 608 last_remote_status_update_.reset(new RemoteStatusUpdate(status_update)); |
604 scoped_ptr<base::ListValue> unlock_keys = GetUnlockKeysList(); | 609 std::unique_ptr<base::ListValue> unlock_keys = GetUnlockKeysList(); |
605 web_ui()->CallJavascriptFunction("LocalStateInterface.onUnlockKeysChanged", | 610 web_ui()->CallJavascriptFunction("LocalStateInterface.onUnlockKeysChanged", |
606 *unlock_keys); | 611 *unlock_keys); |
607 } | 612 } |
608 | 613 |
609 } // namespace proximity_auth | 614 } // namespace proximity_auth |
OLD | NEW |