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

Side by Side Diff: components/cryptauth/remote_device_loader.cc

Issue 2897843002: Revert of [EasyUnlock] Add beacon_seeds to RemoteDevice. (Closed)
Patch Set: Created 3 years, 7 months 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 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/remote_device_loader.h" 5 #include "components/cryptauth/remote_device_loader.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"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 user_id, 49 user_id,
50 user_private_key, 50 user_private_key,
51 std::move(secure_message_delegate))); 51 std::move(secure_message_delegate)));
52 } 52 }
53 53
54 RemoteDeviceLoader::RemoteDeviceLoader( 54 RemoteDeviceLoader::RemoteDeviceLoader(
55 const std::vector<cryptauth::ExternalDeviceInfo>& device_info_list, 55 const std::vector<cryptauth::ExternalDeviceInfo>& device_info_list,
56 const std::string& user_id, 56 const std::string& user_id,
57 const std::string& user_private_key, 57 const std::string& user_private_key,
58 std::unique_ptr<cryptauth::SecureMessageDelegate> secure_message_delegate) 58 std::unique_ptr<cryptauth::SecureMessageDelegate> secure_message_delegate)
59 : should_load_beacon_seeds_(false), 59 : remaining_devices_(device_info_list),
60 remaining_devices_(device_info_list),
61 user_id_(user_id), 60 user_id_(user_id),
62 user_private_key_(user_private_key), 61 user_private_key_(user_private_key),
63 secure_message_delegate_(std::move(secure_message_delegate)), 62 secure_message_delegate_(std::move(secure_message_delegate)),
64 weak_ptr_factory_(this) {} 63 weak_ptr_factory_(this) {}
65 64
66 RemoteDeviceLoader::~RemoteDeviceLoader() {} 65 RemoteDeviceLoader::~RemoteDeviceLoader() {}
67 66
68 void RemoteDeviceLoader::Load(bool should_load_beacon_seeds, 67 void RemoteDeviceLoader::Load(const RemoteDeviceCallback& callback) {
69 const RemoteDeviceCallback& callback) {
70 DCHECK(callback_.is_null()); 68 DCHECK(callback_.is_null());
71 should_load_beacon_seeds_ = should_load_beacon_seeds;
72 callback_ = callback; 69 callback_ = callback;
73 PA_LOG(INFO) << "Loading " << remaining_devices_.size() 70 PA_LOG(INFO) << "Loading " << remaining_devices_.size()
74 << " remote devices"; 71 << " remote devices";
75 72
76 if (remaining_devices_.empty()) { 73 if (remaining_devices_.empty()) {
77 callback_.Run(remote_devices_); 74 callback_.Run(remote_devices_);
78 return; 75 return;
79 } 76 }
80 77
81 std::vector<cryptauth::ExternalDeviceInfo> all_devices_to_convert = 78 std::vector<cryptauth::ExternalDeviceInfo> all_devices_to_convert =
(...skipping 15 matching lines...) Expand all
97 remaining_devices_.begin(), remaining_devices_.end(), 94 remaining_devices_.begin(), remaining_devices_.end(),
98 [&public_key](const cryptauth::ExternalDeviceInfo& device) { 95 [&public_key](const cryptauth::ExternalDeviceInfo& device) {
99 return device.public_key() == public_key; 96 return device.public_key() == public_key;
100 }); 97 });
101 98
102 DCHECK(iterator != remaining_devices_.end()); 99 DCHECK(iterator != remaining_devices_.end());
103 remaining_devices_.erase(iterator); 100 remaining_devices_.erase(iterator);
104 PA_LOG(INFO) << "Derived PSK for " << device.friendly_device_name() 101 PA_LOG(INFO) << "Derived PSK for " << device.friendly_device_name()
105 << ", " << remaining_devices_.size() << " keys remaining."; 102 << ", " << remaining_devices_.size() << " keys remaining.";
106 103
107 cryptauth::RemoteDevice remote_device( 104 remote_devices_.push_back(cryptauth::RemoteDevice(
108 user_id_, device.friendly_device_name(), device.public_key(), 105 user_id_, device.friendly_device_name(), device.public_key(),
109 device.bluetooth_address(), psk, std::string()); 106 device.bluetooth_address(), psk, std::string()));
110
111 if (should_load_beacon_seeds_) {
112 std::vector<BeaconSeed> beacon_seeds;
113 for (const BeaconSeed& beacon_seed : device.beacon_seeds()) {
114 beacon_seeds.push_back(beacon_seed);
115 }
116 remote_device.LoadBeaconSeeds(beacon_seeds);
117 }
118 remote_devices_.push_back(remote_device);
119 107
120 if (remaining_devices_.empty()) 108 if (remaining_devices_.empty())
121 callback_.Run(remote_devices_); 109 callback_.Run(remote_devices_);
122 } 110 }
123 111
124 } // namespace cryptauth 112 } // namespace cryptauth
OLDNEW
« no previous file with comments | « components/cryptauth/remote_device_loader.h ('k') | components/cryptauth/remote_device_loader_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698