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

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

Issue 2859053003: [EasyUnlock] Add beacon_seeds to RemoteDevice. (Closed)
Patch Set: [EasyUnlock] Add beacon_seeds to RemoteDevice. 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 : remaining_devices_(device_info_list), 59 : should_load_beacon_seeds_(false),
60 remaining_devices_(device_info_list),
60 user_id_(user_id), 61 user_id_(user_id),
61 user_private_key_(user_private_key), 62 user_private_key_(user_private_key),
62 secure_message_delegate_(std::move(secure_message_delegate)), 63 secure_message_delegate_(std::move(secure_message_delegate)),
63 weak_ptr_factory_(this) {} 64 weak_ptr_factory_(this) {}
64 65
65 RemoteDeviceLoader::~RemoteDeviceLoader() {} 66 RemoteDeviceLoader::~RemoteDeviceLoader() {}
66 67
67 void RemoteDeviceLoader::Load(const RemoteDeviceCallback& callback) { 68 void RemoteDeviceLoader::Load(const RemoteDeviceCallback& callback) {
68 DCHECK(callback_.is_null()); 69 DCHECK(callback_.is_null());
69 callback_ = callback; 70 callback_ = callback;
(...skipping 24 matching lines...) Expand all
94 remaining_devices_.begin(), remaining_devices_.end(), 95 remaining_devices_.begin(), remaining_devices_.end(),
95 [&public_key](const cryptauth::ExternalDeviceInfo& device) { 96 [&public_key](const cryptauth::ExternalDeviceInfo& device) {
96 return device.public_key() == public_key; 97 return device.public_key() == public_key;
97 }); 98 });
98 99
99 DCHECK(iterator != remaining_devices_.end()); 100 DCHECK(iterator != remaining_devices_.end());
100 remaining_devices_.erase(iterator); 101 remaining_devices_.erase(iterator);
101 PA_LOG(INFO) << "Derived PSK for " << device.friendly_device_name() 102 PA_LOG(INFO) << "Derived PSK for " << device.friendly_device_name()
102 << ", " << remaining_devices_.size() << " keys remaining."; 103 << ", " << remaining_devices_.size() << " keys remaining.";
103 104
104 remote_devices_.push_back(cryptauth::RemoteDevice( 105 cryptauth::RemoteDevice remote_device(
105 user_id_, device.friendly_device_name(), device.public_key(), 106 user_id_, device.friendly_device_name(), device.public_key(),
106 device.bluetooth_address(), psk, std::string())); 107 device.bluetooth_address(), psk, std::string());
108
109 if (should_load_beacon_seeds_) {
110 for (const BeaconSeed& beacon_seed : device.beacon_seeds()) {
111 remote_device.beacon_seeds.push_back(beacon_seed);
112 }
113 }
114 remote_devices_.push_back(remote_device);
107 115
108 if (remaining_devices_.empty()) 116 if (remaining_devices_.empty())
109 callback_.Run(remote_devices_); 117 callback_.Run(remote_devices_);
110 } 118 }
111 119
112 } // namespace cryptauth 120 } // namespace cryptauth
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698