Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(510)

Unified Diff: components/cryptauth/cryptauth_device_manager.cc

Issue 2561683002: Update CryptAuthDeviceManager to store all synced devices instead of only unlock keys. (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..d35c0cf390062ae7076b209289ddc18d9ec921eb 100644
--- a/components/cryptauth/cryptauth_device_manager.cc
+++ b/components/cryptauth/cryptauth_device_manager.cc
@@ -367,6 +367,28 @@ bool CryptAuthDeviceManager::IsRecoveringFromFailure() const {
SyncScheduler::Strategy::AGGRESSIVE_RECOVERY;
}
+const std::vector<ExternalDeviceInfo>
+CryptAuthDeviceManager::unlock_keys() const {
+ 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.
@@ -374,8 +396,7 @@ void CryptAuthDeviceManager::OnGetMyDevicesSuccess(
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));
+ unlock_keys_pref->Append(UnlockKeyToDictionary(device));
Jeremy Klein 2016/12/07 22:19:54 Any reason not to just use devices_as_list and rem
Kyle Horimoto 2016/12/07 22:25:35 Done.
}
PA_LOG(INFO) << "Devices Synced:\n" << *devices_as_list;
@@ -431,13 +452,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;

Powered by Google App Engine
This is Rietveld 408576698