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

Side by Side Diff: chrome/browser/chromeos/login/easy_unlock/easy_unlock_key_manager.cc

Issue 1165323004: We should use UserID object to identify users instead of username. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 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 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/chromeos/login/easy_unlock/easy_unlock_key_manager.h" 5 #include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_key_manager.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 const UserContext& user_context, 100 const UserContext& user_context,
101 const GetDeviceDataListCallback& callback) { 101 const GetDeviceDataListCallback& callback) {
102 read_operation_queue_.push_back(new EasyUnlockGetKeysOperation( 102 read_operation_queue_.push_back(new EasyUnlockGetKeysOperation(
103 user_context, base::Bind(&EasyUnlockKeyManager::OnKeysFetched, 103 user_context, base::Bind(&EasyUnlockKeyManager::OnKeysFetched,
104 weak_ptr_factory_.GetWeakPtr(), callback))); 104 weak_ptr_factory_.GetWeakPtr(), callback)));
105 RunNextOperation(); 105 RunNextOperation();
106 } 106 }
107 107
108 // static 108 // static
109 void EasyUnlockKeyManager::DeviceDataToRemoteDeviceDictionary( 109 void EasyUnlockKeyManager::DeviceDataToRemoteDeviceDictionary(
110 const std::string& user_id, 110 const user_manager::UserID& user_id,
111 const EasyUnlockDeviceKeyData& data, 111 const EasyUnlockDeviceKeyData& data,
112 base::DictionaryValue* dict) { 112 base::DictionaryValue* dict) {
113 dict->SetString(kKeyBluetoothAddress, data.bluetooth_address); 113 dict->SetString(kKeyBluetoothAddress, data.bluetooth_address);
114 dict->SetString(kKeyPsk, data.psk); 114 dict->SetString(kKeyPsk, data.psk);
115 scoped_ptr<base::DictionaryValue> permit_record(new base::DictionaryValue); 115 scoped_ptr<base::DictionaryValue> permit_record(new base::DictionaryValue);
116 dict->Set(kKeyPermitRecord, permit_record.release()); 116 dict->Set(kKeyPermitRecord, permit_record.release());
117 dict->SetString(kKeyPermitId, data.public_key); 117 dict->SetString(kKeyPermitId, data.public_key);
118 dict->SetString(kKeyPermitData, data.public_key); 118 dict->SetString(kKeyPermitData, data.public_key);
119 dict->SetString(kKeyPermitType, kPermitTypeLicence); 119 dict->SetString(kKeyPermitType, kPermitTypeLicence);
120 dict->SetString(kKeyPermitPermitId, 120 dict->SetString(kKeyPermitPermitId,
121 base::StringPrintf(kPermitPermitIdFormat, 121 base::StringPrintf(kPermitPermitIdFormat,
122 user_id.c_str())); 122 user_id.GetUserEmail().c_str()));
123 } 123 }
124 124
125 // static 125 // static
126 bool EasyUnlockKeyManager::RemoteDeviceDictionaryToDeviceData( 126 bool EasyUnlockKeyManager::RemoteDeviceDictionaryToDeviceData(
127 const base::DictionaryValue& dict, 127 const base::DictionaryValue& dict,
128 EasyUnlockDeviceKeyData* data) { 128 EasyUnlockDeviceKeyData* data) {
129 std::string bluetooth_address; 129 std::string bluetooth_address;
130 std::string public_key; 130 std::string public_key;
131 std::string psk; 131 std::string psk;
132 132
133 if (!dict.GetString(kKeyBluetoothAddress, &bluetooth_address) || 133 if (!dict.GetString(kKeyBluetoothAddress, &bluetooth_address) ||
134 !dict.GetString(kKeyPermitId, &public_key) || 134 !dict.GetString(kKeyPermitId, &public_key) ||
135 !dict.GetString(kKeyPsk, &psk)) { 135 !dict.GetString(kKeyPsk, &psk)) {
136 return false; 136 return false;
137 } 137 }
138 138
139 data->bluetooth_address.swap(bluetooth_address); 139 data->bluetooth_address.swap(bluetooth_address);
140 data->public_key.swap(public_key); 140 data->public_key.swap(public_key);
141 data->psk.swap(psk); 141 data->psk.swap(psk);
142 return true; 142 return true;
143 } 143 }
144 144
145 // static 145 // static
146 void EasyUnlockKeyManager::DeviceDataListToRemoteDeviceList( 146 void EasyUnlockKeyManager::DeviceDataListToRemoteDeviceList(
147 const std::string& user_id, 147 const user_manager::UserID& user_id,
148 const EasyUnlockDeviceKeyDataList& data_list, 148 const EasyUnlockDeviceKeyDataList& data_list,
149 base::ListValue* device_list) { 149 base::ListValue* device_list) {
150 device_list->Clear(); 150 device_list->Clear();
151 for (size_t i = 0; i < data_list.size(); ++i) { 151 for (size_t i = 0; i < data_list.size(); ++i) {
152 scoped_ptr<base::DictionaryValue> device_dict(new base::DictionaryValue); 152 scoped_ptr<base::DictionaryValue> device_dict(new base::DictionaryValue);
153 DeviceDataToRemoteDeviceDictionary( 153 DeviceDataToRemoteDeviceDictionary(
154 user_id, data_list[i], device_dict.get()); 154 user_id, data_list[i], device_dict.get());
155 device_list->Append(device_dict.release()); 155 device_list->Append(device_dict.release());
156 } 156 }
157 } 157 }
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 const EasyUnlockDeviceKeyDataList& fetched_data) { 215 const EasyUnlockDeviceKeyDataList& fetched_data) {
216 if (!callback.is_null()) 216 if (!callback.is_null())
217 callback.Run(fetch_success, fetched_data); 217 callback.Run(fetch_success, fetched_data);
218 218
219 DCHECK(pending_read_operation_); 219 DCHECK(pending_read_operation_);
220 pending_read_operation_.reset(); 220 pending_read_operation_.reset();
221 RunNextOperation(); 221 RunNextOperation();
222 } 222 }
223 223
224 } // namespace chromeos 224 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698