Chromium Code Reviews| Index: components/cryptauth/cryptauth_device_manager.cc |
| diff --git a/components/cryptauth/cryptauth_device_manager.cc b/components/cryptauth/cryptauth_device_manager.cc |
| index 420cabc0e1a92fe11e1f25372d231cf58effd28a..4f2a59fd2a65f930c27ce38857997dfda5f16069 100644 |
| --- a/components/cryptauth/cryptauth_device_manager.cc |
| +++ b/components/cryptauth/cryptauth_device_manager.cc |
| @@ -367,23 +367,47 @@ bool CryptAuthDeviceManager::IsRecoveringFromFailure() const { |
| SyncScheduler::Strategy::AGGRESSIVE_RECOVERY; |
| } |
| +const std::vector<ExternalDeviceInfo> |
| +CryptAuthDeviceManager::synced_devices() const { |
| + return synced_devices_; |
| +} |
| + |
| +const std::vector<ExternalDeviceInfo> |
| +CryptAuthDeviceManager::unlock_keys() const { |
|
Tim Song
2016/12/08 00:26:39
I believe the convention in Chrome is to only use
Kyle Horimoto
2016/12/08 00:35:03
Done.
|
| + std::vector<ExternalDeviceInfo> unlock_keys; |
| + for (const auto& device : synced_devices_) { |
| + if (device.unlock_key()) { |
| + unlock_keys.push_back(device); |
| + } |
| + } |
| + return unlock_keys; |
| +} |
| + |
| +const std::vector<ExternalDeviceInfo> |
| +CryptAuthDeviceManager::tether_hosts() const { |
| + std::vector<ExternalDeviceInfo> tether_hosts; |
| + for (const auto& device : synced_devices_) { |
| + if (device.mobile_hotspot_supported()) { |
| + tether_hosts.push_back(device); |
| + } |
| + } |
| + return tether_hosts; |
| +} |
| + |
| void CryptAuthDeviceManager::OnGetMyDevicesSuccess( |
| const cryptauth::GetMyDevicesResponse& response) { |
| - // Update the unlock keys stored in the user's prefs. |
| - std::unique_ptr<base::ListValue> unlock_keys_pref(new base::ListValue()); |
| + // Update the synced devices stored in the user's prefs. |
| std::unique_ptr<base::ListValue> devices_as_list(new base::ListValue()); |
| for (const auto& device : response.devices()) { |
| devices_as_list->Append(UnlockKeyToDictionary(device)); |
| - if (device.unlock_key()) |
| - unlock_keys_pref->Append(UnlockKeyToDictionary(device)); |
| } |
| PA_LOG(INFO) << "Devices Synced:\n" << *devices_as_list; |
| - bool unlock_keys_changed = !unlock_keys_pref->Equals( |
| + bool unlock_keys_changed = !devices_as_list->Equals( |
| pref_service_->GetList(prefs::kCryptAuthDeviceSyncUnlockKeys)); |
| { |
| ListPrefUpdate update(pref_service_, prefs::kCryptAuthDeviceSyncUnlockKeys); |
| - update.Get()->Swap(unlock_keys_pref.get()); |
| + update.Get()->Swap(devices_as_list.get()); |
| } |
| UpdateUnlockKeysFromPrefs(); |
| @@ -431,13 +455,13 @@ void CryptAuthDeviceManager::OnResyncMessage() { |
| void CryptAuthDeviceManager::UpdateUnlockKeysFromPrefs() { |
| const base::ListValue* unlock_key_list = |
| pref_service_->GetList(prefs::kCryptAuthDeviceSyncUnlockKeys); |
| - unlock_keys_.clear(); |
| + synced_devices_.clear(); |
| for (size_t i = 0; i < unlock_key_list->GetSize(); ++i) { |
| const base::DictionaryValue* unlock_key_dictionary; |
| if (unlock_key_list->GetDictionary(i, &unlock_key_dictionary)) { |
| cryptauth::ExternalDeviceInfo unlock_key; |
| if (DictionaryToUnlockKey(*unlock_key_dictionary, &unlock_key)) { |
| - unlock_keys_.push_back(unlock_key); |
| + synced_devices_.push_back(unlock_key); |
| } else { |
| PA_LOG(ERROR) << "Unable to deserialize unlock key dictionary " |
| << "(index=" << i << "):\n" << *unlock_key_dictionary; |