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

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

Issue 1412813003: This CL replaces user_manager::UserID with AccountId. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@468875--Chrome-OS-handles-deletion-of-Gmail-account-poorly--Create-AccountID-structure-part2--user_names
Patch Set: Fix Win GN build. Created 5 years, 1 month 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"
11 #include "base/values.h" 11 #include "base/values.h"
12 #include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_tpm_key_manager. h" 12 #include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_tpm_key_manager. h"
13 #include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_tpm_key_manager_ factory.h" 13 #include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_tpm_key_manager_ factory.h"
14 #include "components/signin/core/account_id/account_id.h"
14 15
15 namespace chromeos { 16 namespace chromeos {
16 17
17 namespace { 18 namespace {
18 19
19 const char kKeyBluetoothAddress[] = "bluetoothAddress"; 20 const char kKeyBluetoothAddress[] = "bluetoothAddress";
20 const char kKeyPermitRecord[] = "permitRecord"; 21 const char kKeyPermitRecord[] = "permitRecord";
21 const char kKeyPermitId[] = "permitRecord.id"; 22 const char kKeyPermitId[] = "permitRecord.id";
22 const char kKeyPermitPermitId[] = "permitRecord.permitId"; 23 const char kKeyPermitPermitId[] = "permitRecord.permitId";
23 const char kKeyPermitData[] = "permitRecord.data"; 24 const char kKeyPermitData[] = "permitRecord.data";
(...skipping 21 matching lines...) Expand all
45 const RefreshKeysCallback& callback) { 46 const RefreshKeysCallback& callback) {
46 base::Closure do_refresh_keys = base::Bind( 47 base::Closure do_refresh_keys = base::Bind(
47 &EasyUnlockKeyManager::RefreshKeysWithTpmKeyPresent, 48 &EasyUnlockKeyManager::RefreshKeysWithTpmKeyPresent,
48 weak_ptr_factory_.GetWeakPtr(), 49 weak_ptr_factory_.GetWeakPtr(),
49 user_context, 50 user_context,
50 base::Owned(remote_devices.DeepCopy()), 51 base::Owned(remote_devices.DeepCopy()),
51 callback); 52 callback);
52 53
53 EasyUnlockTpmKeyManager* tpm_key_manager = 54 EasyUnlockTpmKeyManager* tpm_key_manager =
54 EasyUnlockTpmKeyManagerFactory::GetInstance()->GetForUser( 55 EasyUnlockTpmKeyManagerFactory::GetInstance()->GetForUser(
55 user_context.GetUserID()); 56 user_context.GetAccountId().GetUserEmail());
56 if (!tpm_key_manager) { 57 if (!tpm_key_manager) {
57 LOG(ERROR) << "No TPM key manager."; 58 LOG(ERROR) << "No TPM key manager.";
58 callback.Run(false); 59 callback.Run(false);
59 return; 60 return;
60 } 61 }
61 62
62 // Private TPM key is needed only when adding new keys. 63 // Private TPM key is needed only when adding new keys.
63 if (remote_devices.empty() || 64 if (remote_devices.empty() ||
64 tpm_key_manager->PrepareTpmKey(false /* check_private_key */, 65 tpm_key_manager->PrepareTpmKey(false /* check_private_key */,
65 do_refresh_keys)) { 66 do_refresh_keys)) {
66 do_refresh_keys.Run(); 67 do_refresh_keys.Run();
67 } else { 68 } else {
68 // In case Chrome is supposed to restart to apply user session flags, the 69 // In case Chrome is supposed to restart to apply user session flags, the
69 // Chrome restart will be postponed until Easy Sign-in keys are refreshed. 70 // Chrome restart will be postponed until Easy Sign-in keys are refreshed.
70 // This is to ensure that creating TPM key does not hang if TPM system 71 // This is to ensure that creating TPM key does not hang if TPM system
71 // loading takes too much time. Note that in normal circumstances the 72 // loading takes too much time. Note that in normal circumstances the
72 // chances that TPM slot cannot be loaded should be extremely low. 73 // chances that TPM slot cannot be loaded should be extremely low.
73 // TODO(tbarzic): Add some metrics to measure if the timeout even gets hit. 74 // TODO(tbarzic): Add some metrics to measure if the timeout even gets hit.
74 tpm_key_manager->StartGetSystemSlotTimeoutMs(2000); 75 tpm_key_manager->StartGetSystemSlotTimeoutMs(2000);
75 } 76 }
76 } 77 }
77 78
78 void EasyUnlockKeyManager::RefreshKeysWithTpmKeyPresent( 79 void EasyUnlockKeyManager::RefreshKeysWithTpmKeyPresent(
79 const UserContext& user_context, 80 const UserContext& user_context,
80 base::ListValue* remote_devices, 81 base::ListValue* remote_devices,
81 const RefreshKeysCallback& callback) { 82 const RefreshKeysCallback& callback) {
82 EasyUnlockTpmKeyManager* tpm_key_manager = 83 EasyUnlockTpmKeyManager* tpm_key_manager =
83 EasyUnlockTpmKeyManagerFactory::GetInstance()->GetForUser( 84 EasyUnlockTpmKeyManagerFactory::GetInstance()->GetForUser(
84 user_context.GetUserID()); 85 user_context.GetAccountId().GetUserEmail());
85 std::string tpm_public_key = 86 const std::string tpm_public_key = tpm_key_manager->GetPublicTpmKey(
86 tpm_key_manager->GetPublicTpmKey(user_context.GetUserID()); 87 user_context.GetAccountId().GetUserEmail());
87 88
88 EasyUnlockDeviceKeyDataList devices; 89 EasyUnlockDeviceKeyDataList devices;
89 if (!RemoteDeviceListToDeviceDataList(*remote_devices, &devices)) 90 if (!RemoteDeviceListToDeviceDataList(*remote_devices, &devices))
90 devices.clear(); 91 devices.clear();
91 92
92 write_operation_queue_.push_back(new EasyUnlockRefreshKeysOperation( 93 write_operation_queue_.push_back(new EasyUnlockRefreshKeysOperation(
93 user_context, tpm_public_key, devices, 94 user_context, tpm_public_key, devices,
94 base::Bind(&EasyUnlockKeyManager::OnKeysRefreshed, 95 base::Bind(&EasyUnlockKeyManager::OnKeysRefreshed,
95 weak_ptr_factory_.GetWeakPtr(), callback))); 96 weak_ptr_factory_.GetWeakPtr(), callback)));
96 RunNextOperation(); 97 RunNextOperation();
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 const EasyUnlockDeviceKeyDataList& fetched_data) { 216 const EasyUnlockDeviceKeyDataList& fetched_data) {
216 if (!callback.is_null()) 217 if (!callback.is_null())
217 callback.Run(fetch_success, fetched_data); 218 callback.Run(fetch_success, fetched_data);
218 219
219 DCHECK(pending_read_operation_); 220 DCHECK(pending_read_operation_);
220 pending_read_operation_.reset(); 221 pending_read_operation_.reset();
221 RunNextOperation(); 222 RunNextOperation();
222 } 223 }
223 224
224 } // namespace chromeos 225 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698