Index: chrome/browser/signin/easy_unlock_service.cc |
diff --git a/chrome/browser/signin/easy_unlock_service.cc b/chrome/browser/signin/easy_unlock_service.cc |
index c86f6ef0e4bc5e8e51b467df1057298605bfda75..7373b7c36e3f800fccb487599287d40cc72b77b6 100644 |
--- a/chrome/browser/signin/easy_unlock_service.cc |
+++ b/chrome/browser/signin/easy_unlock_service.cc |
@@ -31,6 +31,7 @@ |
#include "components/proximity_auth/screenlock_bridge.h" |
#include "components/proximity_auth/switches.h" |
#include "components/user_manager/user.h" |
+#include "components/user_manager/user_id.h" |
#include "device/bluetooth/bluetooth_adapter.h" |
#include "device/bluetooth/bluetooth_adapter_factory.h" |
@@ -285,7 +286,7 @@ void EasyUnlockService::RegisterPrefs(PrefRegistrySimple* registry) { |
} |
// static |
-void EasyUnlockService::ResetLocalStateForUser(const std::string& user_id) { |
+void EasyUnlockService::ResetLocalStateForUser(const user_manager::UserID& user_id) { |
DCHECK(!user_id.empty()); |
PrefService* local_state = GetLocalState(); |
@@ -293,7 +294,7 @@ void EasyUnlockService::ResetLocalStateForUser(const std::string& user_id) { |
return; |
DictionaryPrefUpdate update(local_state, prefs::kEasyUnlockHardlockState); |
- update->RemoveWithoutPathExpansion(user_id, NULL); |
+ update->RemoveWithoutPathExpansion(user_id.GetUserEmail(), NULL); |
#if defined(OS_CHROMEOS) |
EasyUnlockTpmKeyManager::ResetLocalStateForUser(user_id); |
@@ -302,7 +303,7 @@ void EasyUnlockService::ResetLocalStateForUser(const std::string& user_id) { |
// static |
EasyUnlockService::UserSettings EasyUnlockService::GetUserSettings( |
- const std::string& user_id) { |
+ const user_manager::UserID& user_id) { |
DCHECK(!user_id.empty()); |
UserSettings user_settings; |
@@ -316,7 +317,7 @@ EasyUnlockService::UserSettings EasyUnlockService::GetUserSettings( |
return user_settings; |
const base::DictionaryValue* user_prefs_dict; |
- if (!all_user_prefs_dict->GetDictionaryWithoutPathExpansion(user_id, |
+ if (!all_user_prefs_dict->GetDictionaryWithoutPathExpansion(user_id.GetUserEmail(), |
&user_prefs_dict)) |
return user_settings; |
@@ -384,7 +385,7 @@ void EasyUnlockService::OpenSetupApp() { |
void EasyUnlockService::SetHardlockState( |
EasyUnlockScreenlockStateHandler::HardlockState state) { |
- const std::string user_id = GetUserEmail(); |
+ const user_manager::UserID user_id = GetUserID(); |
if (user_id.empty()) |
return; |
@@ -405,7 +406,7 @@ EasyUnlockService::GetHardlockState() const { |
bool EasyUnlockService::GetPersistedHardlockState( |
EasyUnlockScreenlockStateHandler::HardlockState* state) const { |
- std::string user_id = GetUserEmail(); |
+ const user_manager::UserID user_id = GetUserID(); |
if (user_id.empty()) |
return false; |
@@ -416,7 +417,7 @@ bool EasyUnlockService::GetPersistedHardlockState( |
const base::DictionaryValue* dict = |
local_state->GetDictionary(prefs::kEasyUnlockHardlockState); |
int state_int; |
- if (dict && dict->GetIntegerWithoutPathExpansion(user_id, &state_int)) { |
+ if (dict && dict->GetIntegerWithoutPathExpansion(user_id.GetUserEmail(), &state_int)) { |
*state = |
static_cast<EasyUnlockScreenlockStateHandler::HardlockState>(state_int); |
return true; |
@@ -448,7 +449,7 @@ EasyUnlockScreenlockStateHandler* |
return NULL; |
if (!screenlock_state_handler_) { |
screenlock_state_handler_.reset(new EasyUnlockScreenlockStateHandler( |
- GetUserEmail(), GetHardlockState(), GetScreenlockBridgeInstance())); |
+ GetUserID(), GetHardlockState(), GetScreenlockBridgeInstance())); |
} |
return screenlock_state_handler_.get(); |
} |
@@ -471,7 +472,7 @@ bool EasyUnlockService::UpdateScreenlockState(ScreenlockState state) { |
auth_attempt_.reset(); |
if (!handler->InStateValidOnRemoteAuthFailure()) |
- HandleAuthFailure(GetUserEmail()); |
+ HandleAuthFailure(GetUserID()); |
} |
FOR_EACH_OBSERVER( |
@@ -487,17 +488,17 @@ ScreenlockState EasyUnlockService::GetScreenlockState() { |
return handler->state(); |
} |
-void EasyUnlockService::AttemptAuth(const std::string& user_id) { |
+void EasyUnlockService::AttemptAuth(const user_manager::UserID& user_id) { |
AttemptAuth(user_id, AttemptAuthCallback()); |
} |
-void EasyUnlockService::AttemptAuth(const std::string& user_id, |
+void EasyUnlockService::AttemptAuth(const user_manager::UserID& user_id, |
const AttemptAuthCallback& callback) { |
const EasyUnlockAuthAttempt::Type auth_attempt_type = |
GetType() == TYPE_REGULAR ? EasyUnlockAuthAttempt::TYPE_UNLOCK |
: EasyUnlockAuthAttempt::TYPE_SIGNIN; |
- const std::string user_email = GetUserEmail(); |
- if (user_email.empty()) { |
+ const user_manager::UserID current_user_id = GetUserID(); |
+ if (current_user_id.empty()) { |
LOG(ERROR) << "Empty user email. Refresh token might go bad."; |
if (!callback.is_null()) { |
const bool kFailure = false; |
@@ -507,7 +508,7 @@ void EasyUnlockService::AttemptAuth(const std::string& user_id, |
return; |
} |
- CHECK_EQ(GetUserEmail(), user_id); |
+ CHECK_EQ(GetUserID(), user_id); |
auth_attempt_.reset(new EasyUnlockAuthAttempt(app_manager_.get(), user_id, |
auth_attempt_type, callback)); |
@@ -520,7 +521,7 @@ void EasyUnlockService::FinalizeUnlock(bool success) { |
return; |
this->OnWillFinalizeUnlock(success); |
- auth_attempt_->FinalizeUnlock(GetUserEmail(), success); |
+ auth_attempt_->FinalizeUnlock(GetUserID(), success); |
auth_attempt_.reset(); |
// TODO(isherman): If observing screen unlock events, is there a race |
// condition in terms of reading the service's state vs. the app setting the |
@@ -529,7 +530,7 @@ void EasyUnlockService::FinalizeUnlock(bool success) { |
// Make sure that the lock screen is updated on failure. |
if (!success) { |
RecordEasyUnlockScreenUnlockEvent(EASY_UNLOCK_FAILURE); |
- HandleAuthFailure(GetUserEmail()); |
+ HandleAuthFailure(GetUserID()); |
} |
} |
@@ -538,18 +539,18 @@ void EasyUnlockService::FinalizeSignin(const std::string& key) { |
return; |
std::string wrapped_secret = GetWrappedSecret(); |
if (!wrapped_secret.empty()) |
- auth_attempt_->FinalizeSignin(GetUserEmail(), wrapped_secret, key); |
+ auth_attempt_->FinalizeSignin(GetUserID(), wrapped_secret, key); |
auth_attempt_.reset(); |
// Processing empty key is equivalent to auth cancellation. In this case the |
// signin request will not actually be processed by login stack, so the lock |
// screen state should be set from here. |
if (key.empty()) |
- HandleAuthFailure(GetUserEmail()); |
+ HandleAuthFailure(GetUserID()); |
} |
-void EasyUnlockService::HandleAuthFailure(const std::string& user_id) { |
- if (user_id != GetUserEmail()) |
+void EasyUnlockService::HandleAuthFailure(const user_manager::UserID& user_id) { |
+ if (user_id != GetUserID()) |
return; |
if (!screenlock_state_handler_.get()) |
@@ -561,7 +562,7 @@ void EasyUnlockService::HandleAuthFailure(const std::string& user_id) { |
void EasyUnlockService::CheckCryptohomeKeysAndMaybeHardlock() { |
#if defined(OS_CHROMEOS) |
- std::string user_id = GetUserEmail(); |
+ const user_manager::UserID user_id = GetUserID(); |
if (user_id.empty()) |
return; |
@@ -688,7 +689,7 @@ void EasyUnlockService::DisableAppWithoutResettingScreenlockState() { |
} |
void EasyUnlockService::NotifyUserUpdated() { |
- std::string user_id = GetUserEmail(); |
+ const user_manager::UserID user_id = GetUserID(); |
if (user_id.empty()) |
return; |
@@ -748,7 +749,7 @@ void EasyUnlockService::OnBluetoothAdapterPresentChanged() { |
} |
void EasyUnlockService::SetHardlockStateForUser( |
- const std::string& user_id, |
+ const user_manager::UserID& user_id, |
EasyUnlockScreenlockStateHandler::HardlockState state) { |
DCHECK(!user_id.empty()); |
@@ -757,9 +758,9 @@ void EasyUnlockService::SetHardlockStateForUser( |
return; |
DictionaryPrefUpdate update(local_state, prefs::kEasyUnlockHardlockState); |
- update->SetIntegerWithoutPathExpansion(user_id, static_cast<int>(state)); |
+ update->SetIntegerWithoutPathExpansion(user_id.GetUserEmail(), static_cast<int>(state)); |
- if (GetUserEmail() == user_id) |
+ if (GetUserID() == user_id) |
SetScreenlockHardlockedState(state); |
} |
@@ -819,7 +820,7 @@ EasyUnlockAuthEvent EasyUnlockService::GetPasswordAuthEvent() const { |
#if defined(OS_CHROMEOS) |
void EasyUnlockService::OnCryptohomeKeysFetchedForChecking( |
- const std::string& user_id, |
+ const user_manager::UserID& user_id, |
const std::set<std::string> paired_devices, |
bool success, |
const chromeos::EasyUnlockDeviceKeyDataList& key_data_list) { |
@@ -853,7 +854,7 @@ void EasyUnlockService::PrepareForSuspend() { |
} |
void EasyUnlockService::EnsureTpmKeyPresentIfNeeded() { |
- if (tpm_key_checked_ || GetType() != TYPE_REGULAR || GetUserEmail().empty() || |
+ if (tpm_key_checked_ || GetType() != TYPE_REGULAR || GetUserID().empty() || |
GetHardlockState() == EasyUnlockScreenlockStateHandler::NO_PAIRING) { |
return; |
} |