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/cryptauth/cryptauth_device_manager.h" | 5 #include "components/cryptauth/cryptauth_device_manager.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdexcept> | 8 #include <stdexcept> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
412 tether_hosts.push_back(device); | 412 tether_hosts.push_back(device); |
413 } | 413 } |
414 } | 414 } |
415 return tether_hosts; | 415 return tether_hosts; |
416 } | 416 } |
417 | 417 |
418 void CryptAuthDeviceManager::OnGetMyDevicesSuccess( | 418 void CryptAuthDeviceManager::OnGetMyDevicesSuccess( |
419 const GetMyDevicesResponse& response) { | 419 const GetMyDevicesResponse& response) { |
420 // Update the synced devices stored in the user's prefs. | 420 // Update the synced devices stored in the user's prefs. |
421 std::unique_ptr<base::ListValue> devices_as_list(new base::ListValue()); | 421 std::unique_ptr<base::ListValue> devices_as_list(new base::ListValue()); |
422 | |
423 PA_LOG(INFO) << "Devices were successfully synced."; | |
Kyle Horimoto
2017/06/08 20:43:03
nit: Only print if !responses.devices().empty().
Ryan Hansberry
2017/06/08 22:13:59
Done.
| |
422 for (const auto& device : response.devices()) { | 424 for (const auto& device : response.devices()) { |
423 devices_as_list->Append(UnlockKeyToDictionary(device)); | 425 std::unique_ptr<base::DictionaryValue> device_dictionary = |
426 UnlockKeyToDictionary(device); | |
427 | |
428 const std::string& device_name = device.has_friendly_device_name() | |
429 ? device.friendly_device_name() | |
430 : "[unknown]"; | |
431 PA_LOG(INFO) << "Synced device '" << device_name | |
432 << "': " << *device_dictionary; | |
433 | |
434 devices_as_list->Append(std::move(device_dictionary)); | |
424 } | 435 } |
425 PA_LOG(INFO) << "Devices Synced:\n" << *devices_as_list; | |
426 | 436 |
427 bool unlock_keys_changed = !devices_as_list->Equals( | 437 bool unlock_keys_changed = !devices_as_list->Equals( |
428 pref_service_->GetList(prefs::kCryptAuthDeviceSyncUnlockKeys)); | 438 pref_service_->GetList(prefs::kCryptAuthDeviceSyncUnlockKeys)); |
429 { | 439 { |
430 ListPrefUpdate update(pref_service_, prefs::kCryptAuthDeviceSyncUnlockKeys); | 440 ListPrefUpdate update(pref_service_, prefs::kCryptAuthDeviceSyncUnlockKeys); |
431 update.Get()->Swap(devices_as_list.get()); | 441 update.Get()->Swap(devices_as_list.get()); |
432 } | 442 } |
433 UpdateUnlockKeysFromPrefs(); | 443 UpdateUnlockKeysFromPrefs(); |
434 | 444 |
435 // Reset metadata used for scheduling syncing. | 445 // Reset metadata used for scheduling syncing. |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
530 request.set_invocation_reason(invocation_reason); | 540 request.set_invocation_reason(invocation_reason); |
531 request.set_allow_stale_read(is_sync_speculative); | 541 request.set_allow_stale_read(is_sync_speculative); |
532 cryptauth_client_->GetMyDevices( | 542 cryptauth_client_->GetMyDevices( |
533 request, base::Bind(&CryptAuthDeviceManager::OnGetMyDevicesSuccess, | 543 request, base::Bind(&CryptAuthDeviceManager::OnGetMyDevicesSuccess, |
534 weak_ptr_factory_.GetWeakPtr()), | 544 weak_ptr_factory_.GetWeakPtr()), |
535 base::Bind(&CryptAuthDeviceManager::OnGetMyDevicesFailure, | 545 base::Bind(&CryptAuthDeviceManager::OnGetMyDevicesFailure, |
536 weak_ptr_factory_.GetWeakPtr())); | 546 weak_ptr_factory_.GetWeakPtr())); |
537 } | 547 } |
538 | 548 |
539 } // namespace cryptauth | 549 } // namespace cryptauth |
OLD | NEW |