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

Side by Side Diff: chrome/browser/signin/easy_unlock_service_regular.cc

Issue 2561683002: Update CryptAuthDeviceManager to store all synced devices instead of only unlock keys. (Closed)
Patch Set: tengs@ comments. 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "chrome/browser/signin/easy_unlock_service_regular.h" 5 #include "chrome/browser/signin/easy_unlock_service_regular.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 EasyUnlockServiceRegular::GetCryptAuthDeviceManager() { 96 EasyUnlockServiceRegular::GetCryptAuthDeviceManager() {
97 return device_manager_.get(); 97 return device_manager_.get();
98 } 98 }
99 99
100 proximity_auth::ProximityAuthPrefManager* 100 proximity_auth::ProximityAuthPrefManager*
101 EasyUnlockServiceRegular::GetProximityAuthPrefManager() { 101 EasyUnlockServiceRegular::GetProximityAuthPrefManager() {
102 return pref_manager_.get(); 102 return pref_manager_.get();
103 } 103 }
104 104
105 void EasyUnlockServiceRegular::LoadRemoteDevices() { 105 void EasyUnlockServiceRegular::LoadRemoteDevices() {
106 if (device_manager_->unlock_keys().empty()) { 106 if (device_manager_->GetUnlockKeys().empty()) {
107 SetProximityAuthDevices(GetAccountId(), cryptauth::RemoteDeviceList()); 107 SetProximityAuthDevices(GetAccountId(), cryptauth::RemoteDeviceList());
108 return; 108 return;
109 } 109 }
110 110
111 remote_device_loader_.reset(new proximity_auth::RemoteDeviceLoader( 111 remote_device_loader_.reset(new proximity_auth::RemoteDeviceLoader(
112 device_manager_->unlock_keys(), proximity_auth_client()->GetAccountId(), 112 device_manager_->GetUnlockKeys(), proximity_auth_client()->GetAccountId(),
113 enrollment_manager_->GetUserPrivateKey(), 113 enrollment_manager_->GetUserPrivateKey(),
114 proximity_auth_client()->CreateSecureMessageDelegate(), 114 proximity_auth_client()->CreateSecureMessageDelegate(),
115 pref_manager_.get())); 115 pref_manager_.get()));
116 remote_device_loader_->Load( 116 remote_device_loader_->Load(
117 base::Bind(&EasyUnlockServiceRegular::OnRemoteDevicesLoaded, 117 base::Bind(&EasyUnlockServiceRegular::OnRemoteDevicesLoaded,
118 weak_ptr_factory_.GetWeakPtr())); 118 weak_ptr_factory_.GetWeakPtr()));
119 } 119 }
120 120
121 void EasyUnlockServiceRegular::OnRemoteDevicesLoaded( 121 void EasyUnlockServiceRegular::OnRemoteDevicesLoaded(
122 const cryptauth::RemoteDeviceList& remote_devices) { 122 const cryptauth::RemoteDeviceList& remote_devices) {
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 if (GetCryptAuthDeviceManager()) { 310 if (GetCryptAuthDeviceManager()) {
311 std::string public_key; 311 std::string public_key;
312 if (!base::Base64UrlDecode(b64_public_key, 312 if (!base::Base64UrlDecode(b64_public_key,
313 base::Base64UrlDecodePolicy::REQUIRE_PADDING, 313 base::Base64UrlDecodePolicy::REQUIRE_PADDING,
314 &public_key)) { 314 &public_key)) {
315 PA_LOG(ERROR) << "Unable to base64url decode the public key: " 315 PA_LOG(ERROR) << "Unable to base64url decode the public key: "
316 << b64_public_key; 316 << b64_public_key;
317 return; 317 return;
318 } 318 }
319 const std::vector<cryptauth::ExternalDeviceInfo> unlock_keys = 319 const std::vector<cryptauth::ExternalDeviceInfo> unlock_keys =
320 GetCryptAuthDeviceManager()->unlock_keys(); 320 GetCryptAuthDeviceManager()->GetUnlockKeys();
321 auto iterator = std::find_if( 321 auto iterator = std::find_if(
322 unlock_keys.begin(), unlock_keys.end(), 322 unlock_keys.begin(), unlock_keys.end(),
323 [&public_key](const cryptauth::ExternalDeviceInfo& unlock_key) { 323 [&public_key](const cryptauth::ExternalDeviceInfo& unlock_key) {
324 return unlock_key.public_key() == public_key; 324 return unlock_key.public_key() == public_key;
325 }); 325 });
326 326
327 if (iterator != unlock_keys.end()) { 327 if (iterator != unlock_keys.end()) {
328 LoadRemoteDevices(); 328 LoadRemoteDevices();
329 } else { 329 } else {
330 GetCryptAuthDeviceManager()->ForceSyncNow( 330 GetCryptAuthDeviceManager()->ForceSyncNow(
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
680 PA_LOG(INFO) << "Refresh token not yet available, " 680 PA_LOG(INFO) << "Refresh token not yet available, "
681 << "waiting before starting CryptAuth managers"; 681 << "waiting before starting CryptAuth managers";
682 token_service->AddObserver(this); 682 token_service->AddObserver(this);
683 } 683 }
684 684
685 device_manager_->AddObserver(this); 685 device_manager_->AddObserver(this);
686 enrollment_manager_->Start(); 686 enrollment_manager_->Start();
687 device_manager_->Start(); 687 device_manager_->Start();
688 } 688 }
689 #endif 689 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698