Chromium Code Reviews| Index: chrome/browser/chromeos/login/easy_unlock/easy_unlock_tpm_key_manager.cc |
| diff --git a/chrome/browser/chromeos/login/easy_unlock/easy_unlock_tpm_key_manager.cc b/chrome/browser/chromeos/login/easy_unlock/easy_unlock_tpm_key_manager.cc |
| index cb389ed55e4673aad7b1bad6772e3bd82d9964d5..bac3ff7eb562e3cfbb0ae21d985bd997ffc1b4b5 100644 |
| --- a/chrome/browser/chromeos/login/easy_unlock/easy_unlock_tpm_key_manager.cc |
| +++ b/chrome/browser/chromeos/login/easy_unlock/easy_unlock_tpm_key_manager.cc |
| @@ -184,7 +184,7 @@ void EasyUnlockTpmKeyManager::RegisterLocalStatePrefs( |
| // static |
| void EasyUnlockTpmKeyManager::ResetLocalStateForUser( |
| - const std::string& user_id) { |
| + const AccountId& account_id) { |
| if (!g_browser_process) |
| return; |
| PrefService* local_state = g_browser_process->local_state(); |
| @@ -192,20 +192,19 @@ void EasyUnlockTpmKeyManager::ResetLocalStateForUser( |
| return; |
| DictionaryPrefUpdate update(local_state, prefs::kEasyUnlockLocalStateTpmKeys); |
| - update->RemoveWithoutPathExpansion(user_id, NULL); |
| + update->RemoveWithoutPathExpansion(account_id.GetUserEmail(), NULL); |
| } |
| EasyUnlockTpmKeyManager::EasyUnlockTpmKeyManager( |
| - const std::string& user_id, |
| + const AccountId& account_id, |
| const std::string& username_hash, |
| PrefService* local_state) |
| - : user_id_(user_id), |
| + : account_id_(account_id), |
| username_hash_(username_hash), |
| local_state_(local_state), |
| create_tpm_key_state_(CREATE_TPM_KEY_NOT_STARTED), |
| get_tpm_slot_weak_ptr_factory_(this), |
| - weak_ptr_factory_(this) { |
| -} |
| + weak_ptr_factory_(this) {} |
| EasyUnlockTpmKeyManager::~EasyUnlockTpmKeyManager() { |
| } |
| @@ -213,13 +212,13 @@ EasyUnlockTpmKeyManager::~EasyUnlockTpmKeyManager() { |
| bool EasyUnlockTpmKeyManager::PrepareTpmKey( |
| bool check_private_key, |
| const base::Closure& callback) { |
| - CHECK(!user_id_.empty()); |
| + CHECK(account_id_.is_valid()); |
| CHECK(!username_hash_.empty()); |
| if (create_tpm_key_state_ == CREATE_TPM_KEY_DONE) |
| return true; |
| - std::string key = GetPublicTpmKey(user_id_); |
| + std::string key = GetPublicTpmKey(account_id_); |
| if (!check_private_key && !key.empty() && |
| create_tpm_key_state_ == CREATE_TPM_KEY_NOT_STARTED) { |
| return true; |
| @@ -257,24 +256,24 @@ bool EasyUnlockTpmKeyManager::StartGetSystemSlotTimeoutMs(size_t timeout_ms) { |
| } |
| std::string EasyUnlockTpmKeyManager::GetPublicTpmKey( |
| - const std::string& user_id) { |
| + const AccountId& account_id) { |
| if (!local_state_) |
| return std::string(); |
| const base::DictionaryValue* dict = |
| local_state_->GetDictionary(prefs::kEasyUnlockLocalStateTpmKeys); |
| std::string key; |
| if (dict) |
| - dict->GetStringWithoutPathExpansion(user_id, &key); |
| + dict->GetStringWithoutPathExpansion(account_id.GetUserEmail(), &key); |
| std::string decoded; |
| base::Base64Decode(key, &decoded); |
| return decoded; |
| } |
| void EasyUnlockTpmKeyManager::SignUsingTpmKey( |
| - const std::string& user_id, |
| + const AccountId& account_id, |
| const std::string& data, |
| const base::Callback<void(const std::string& data)> callback) { |
| - std::string key = GetPublicTpmKey(user_id); |
| + std::string key = GetPublicTpmKey(account_id); |
|
achuithb
2015/12/04 10:12:52
const
Alexander Alekseev
2015/12/04 12:44:06
Done.
|
| if (key.empty()) { |
| callback.Run(std::string()); |
| return; |
| @@ -298,7 +297,7 @@ bool EasyUnlockTpmKeyManager::StartedCreatingTpmKeys() const { |
| create_tpm_key_state_ == CREATE_TPM_KEY_DONE; |
| } |
| -void EasyUnlockTpmKeyManager::SetKeyInLocalState(const std::string& user_id, |
| +void EasyUnlockTpmKeyManager::SetKeyInLocalState(const AccountId& account_id, |
| const std::string& value) { |
| if (!local_state_) |
| return; |
| @@ -307,7 +306,7 @@ void EasyUnlockTpmKeyManager::SetKeyInLocalState(const std::string& user_id, |
| base::Base64Encode(value, &encoded); |
| DictionaryPrefUpdate update(local_state_, |
| prefs::kEasyUnlockLocalStateTpmKeys); |
| - update->SetStringWithoutPathExpansion(user_id, encoded); |
| + update->SetStringWithoutPathExpansion(account_id.GetUserEmail(), encoded); |
| } |
| void EasyUnlockTpmKeyManager::OnUserTPMInitialized( |
| @@ -378,7 +377,7 @@ void EasyUnlockTpmKeyManager::OnTpmKeyCreated(const std::string& public_key) { |
| get_tpm_slot_weak_ptr_factory_.InvalidateWeakPtrs(); |
| if (!public_key.empty()) |
| - SetKeyInLocalState(user_id_, public_key); |
| + SetKeyInLocalState(account_id_, public_key); |
| for (size_t i = 0; i < prepare_tpm_key_callbacks_.size(); ++i) { |
| if (!prepare_tpm_key_callbacks_[i].is_null()) |