Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
|
Kyle Horimoto
2017/04/30 03:17:43
Did you mean to change this file as part of the CL
Tim Song
2017/05/01 22:23:38
Done. Sorry, accidentally added this file.
| |
| 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 <memory> | 7 #include <memory> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 58 if (!tpm_key_manager) { | 58 if (!tpm_key_manager) { |
| 59 PA_LOG(ERROR) << "No TPM key manager."; | 59 PA_LOG(ERROR) << "No TPM key manager."; |
| 60 callback.Run(false); | 60 callback.Run(false); |
| 61 return; | 61 return; |
| 62 } | 62 } |
| 63 | 63 |
| 64 // Private TPM key is needed only when adding new keys. | 64 // Private TPM key is needed only when adding new keys. |
| 65 if (remote_devices.empty() || | 65 if (remote_devices.empty() || |
| 66 tpm_key_manager->PrepareTpmKey(false /* check_private_key */, | 66 tpm_key_manager->PrepareTpmKey(false /* check_private_key */, |
| 67 do_refresh_keys)) { | 67 do_refresh_keys)) { |
| 68 PA_LOG(WARNING) << "Refreshing keys..."; | |
| 68 do_refresh_keys.Run(); | 69 do_refresh_keys.Run(); |
| 69 } else { | 70 } else { |
| 70 // In case Chrome is supposed to restart to apply user session flags, the | 71 // In case Chrome is supposed to restart to apply user session flags, the |
| 71 // Chrome restart will be postponed until Easy Sign-in keys are refreshed. | 72 // Chrome restart will be postponed until Easy Sign-in keys are refreshed. |
| 72 // This is to ensure that creating TPM key does not hang if TPM system | 73 // This is to ensure that creating TPM key does not hang if TPM system |
| 73 // loading takes too much time. Note that in normal circumstances the | 74 // loading takes too much time. Note that in normal circumstances the |
| 74 // chances that TPM slot cannot be loaded should be extremely low. | 75 // chances that TPM slot cannot be loaded should be extremely low. |
| 75 // TODO(tbarzic): Add some metrics to measure if the timeout even gets hit. | 76 // TODO(tbarzic): Add some metrics to measure if the timeout even gets hit. |
| 77 PA_LOG(WARNING) << "Refresh keys after loading TPM..."; | |
| 76 tpm_key_manager->StartGetSystemSlotTimeoutMs(2000); | 78 tpm_key_manager->StartGetSystemSlotTimeoutMs(2000); |
| 77 } | 79 } |
| 78 } | 80 } |
| 79 | 81 |
| 80 void EasyUnlockKeyManager::RefreshKeysWithTpmKeyPresent( | 82 void EasyUnlockKeyManager::RefreshKeysWithTpmKeyPresent( |
| 81 const UserContext& user_context, | 83 const UserContext& user_context, |
| 82 base::ListValue* remote_devices, | 84 base::ListValue* remote_devices, |
| 83 const RefreshKeysCallback& callback) { | 85 const RefreshKeysCallback& callback) { |
| 84 EasyUnlockTpmKeyManager* tpm_key_manager = | 86 EasyUnlockTpmKeyManager* tpm_key_manager = |
| 85 EasyUnlockTpmKeyManagerFactory::GetInstance()->GetForUser( | 87 EasyUnlockTpmKeyManagerFactory::GetInstance()->GetForUser( |
| 86 user_context.GetAccountId().GetUserEmail()); | 88 user_context.GetAccountId().GetUserEmail()); |
| 87 const std::string tpm_public_key = | 89 const std::string tpm_public_key = |
| 88 tpm_key_manager->GetPublicTpmKey(user_context.GetAccountId()); | 90 tpm_key_manager->GetPublicTpmKey(user_context.GetAccountId()); |
| 89 | 91 |
| 92 PA_LOG(WARNING) << "Refreshing keys: " << remote_devices; | |
| 93 | |
| 90 EasyUnlockDeviceKeyDataList devices; | 94 EasyUnlockDeviceKeyDataList devices; |
| 91 if (!RemoteDeviceListToDeviceDataList(*remote_devices, &devices)) | 95 if (!RemoteDeviceListToDeviceDataList(*remote_devices, &devices)) { |
| 96 PA_LOG(ERROR) << "ERROR Coverting remote devices"; | |
| 92 devices.clear(); | 97 devices.clear(); |
| 98 } | |
| 93 | 99 |
| 94 write_operation_queue_.push_back( | 100 write_operation_queue_.push_back( |
| 95 base::MakeUnique<EasyUnlockRefreshKeysOperation>( | 101 base::MakeUnique<EasyUnlockRefreshKeysOperation>( |
| 96 user_context, tpm_public_key, devices, | 102 user_context, tpm_public_key, devices, |
| 97 base::Bind(&EasyUnlockKeyManager::OnKeysRefreshed, | 103 base::Bind(&EasyUnlockKeyManager::OnKeysRefreshed, |
| 98 weak_ptr_factory_.GetWeakPtr(), callback))); | 104 weak_ptr_factory_.GetWeakPtr(), callback))); |
| 99 RunNextOperation(); | 105 RunNextOperation(); |
| 100 } | 106 } |
| 101 | 107 |
| 102 void EasyUnlockKeyManager::GetDeviceDataList( | 108 void EasyUnlockKeyManager::GetDeviceDataList( |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 234 const EasyUnlockDeviceKeyDataList& fetched_data) { | 240 const EasyUnlockDeviceKeyDataList& fetched_data) { |
| 235 if (!callback.is_null()) | 241 if (!callback.is_null()) |
| 236 callback.Run(fetch_success, fetched_data); | 242 callback.Run(fetch_success, fetched_data); |
| 237 | 243 |
| 238 DCHECK(pending_read_operation_); | 244 DCHECK(pending_read_operation_); |
| 239 pending_read_operation_.reset(); | 245 pending_read_operation_.reset(); |
| 240 RunNextOperation(); | 246 RunNextOperation(); |
| 241 } | 247 } |
| 242 | 248 |
| 243 } // namespace chromeos | 249 } // namespace chromeos |
| OLD | NEW |