Index: chrome/browser/chromeos/login/session/user_session_manager.cc |
diff --git a/chrome/browser/chromeos/login/session/user_session_manager.cc b/chrome/browser/chromeos/login/session/user_session_manager.cc |
index 1efaa708ab48479b5b6e43ca67d903a177c5b22a..7c2aa36bbb7aabb19e729377b6c180ee8ee124f6 100644 |
--- a/chrome/browser/chromeos/login/session/user_session_manager.cc |
+++ b/chrome/browser/chromeos/login/session/user_session_manager.cc |
@@ -452,7 +452,8 @@ void UserSessionManager::StartSession( |
delegate_ = delegate; |
start_session_type_ = start_session_type; |
- VLOG(1) << "Starting session for " << user_context.GetUserID(); |
+ VLOG(1) << "Starting session for " |
+ << user_context.GetAccountId().GetUserEmail(); |
PreStartSession(); |
CreateUserSession(user_context, has_auth_cookies); |
@@ -466,7 +467,7 @@ void UserSessionManager::StartSession( |
if (!user_context.GetDeviceId().empty()) { |
user_manager::UserManager::Get()->SetKnownUserDeviceId( |
- user_context.GetUserID(), user_context.GetDeviceId()); |
+ user_context.GetAccountId(), user_context.GetDeviceId()); |
} |
PrepareProfile(); |
@@ -702,7 +703,7 @@ bool UserSessionManager::RestartToApplyPerSessionFlagsIfNeed( |
} |
bool UserSessionManager::NeedsToUpdateEasyUnlockKeys() const { |
- return !user_context_.GetUserID().empty() && |
+ return user_context_.GetAccountId().is_valid() && |
user_manager::User::TypeHasGaiaAccount(user_context_.GetUserType()) && |
user_context_.GetKey() && !user_context_.GetKey()->GetSecret().empty(); |
} |
@@ -760,7 +761,7 @@ void UserSessionManager::OnSessionRestoreStateChanged( |
if (!connection_error) { |
// We are in one of "done" states here. |
user_manager::UserManager::Get()->SaveUserOAuthStatus( |
- user_manager::UserManager::Get()->GetLoggedInUser()->email(), |
+ user_manager::UserManager::Get()->GetLoggedInUser()->GetAccountId(), |
user_status); |
} |
@@ -863,7 +864,7 @@ void UserSessionManager::PreStartSession() { |
void UserSessionManager::StoreUserContextDataBeforeProfileIsCreated() { |
// Store obfuscated GAIA ID. |
if (!user_context_.GetGaiaID().empty()) { |
- user_manager::UserManager::Get()->UpdateGaiaID(user_context_.GetUserID(), |
+ user_manager::UserManager::Get()->UpdateGaiaID(user_context_.GetAccountId(), |
user_context_.GetGaiaID()); |
} |
} |
@@ -871,8 +872,8 @@ void UserSessionManager::StoreUserContextDataBeforeProfileIsCreated() { |
void UserSessionManager::StartCrosSession() { |
BootTimesRecorder* btl = BootTimesRecorder::Get(); |
btl->AddLoginTimeMarker("StartSession-Start", false); |
- DBusThreadManager::Get()->GetSessionManagerClient()-> |
- StartSession(user_context_.GetUserID()); |
+ DBusThreadManager::Get()->GetSessionManagerClient()->StartSession( |
+ user_context_.GetAccountId().GetUserEmail()); |
btl->AddLoginTimeMarker("StartSession-End", false); |
} |
@@ -880,15 +881,14 @@ void UserSessionManager::NotifyUserLoggedIn() { |
BootTimesRecorder* btl = BootTimesRecorder::Get(); |
btl->AddLoginTimeMarker("UserLoggedIn-Start", false); |
user_manager::UserManager* user_manager = user_manager::UserManager::Get(); |
- user_manager->UserLoggedIn(user_context_.GetUserID(), |
- user_context_.GetUserIDHash(), |
- false); |
+ user_manager->UserLoggedIn(user_context_.GetAccountId(), |
+ user_context_.GetUserIDHash(), false); |
btl->AddLoginTimeMarker("UserLoggedIn-End", false); |
} |
void UserSessionManager::PrepareProfile() { |
- bool is_demo_session = |
- DemoAppLauncher::IsDemoAppSession(user_context_.GetUserID()); |
+ const bool is_demo_session = DemoAppLauncher::IsDemoAppSession( |
+ user_context_.GetAccountId().GetUserEmail()); |
// TODO(nkostylev): Figure out whether demo session is using the right profile |
// path or not. See https://codereview.chromium.org/171423009 |
@@ -914,9 +914,8 @@ void UserSessionManager::OnProfileCreated(const UserContext& user_context, |
// Profile is created, extensions and promo resources are initialized. |
// At this point all other Chrome OS services will be notified that it is |
// safe to use this profile. |
- UserProfileInitialized(profile, |
- is_incognito_profile, |
- user_context.GetUserID()); |
+ UserProfileInitialized(profile, is_incognito_profile, |
+ user_context.GetAccountId()); |
break; |
case Profile::CREATE_STATUS_LOCAL_FAIL: |
case Profile::CREATE_STATUS_REMOTE_FAIL: |
@@ -966,8 +965,8 @@ void UserSessionManager::InitProfilePreferences( |
if (gaia_id.empty()) { |
AccountTrackerService* account_tracker = |
AccountTrackerServiceFactory::GetForProfile(profile); |
- AccountInfo info = |
- account_tracker->FindAccountInfoByEmail(user_context.GetUserID()); |
+ const AccountInfo info = account_tracker->FindAccountInfoByEmail( |
+ user_context.GetAccountId().GetUserEmail()); |
gaia_id = info.gaia; |
DCHECK(!gaia_id.empty()); |
} |
@@ -977,22 +976,22 @@ void UserSessionManager::InitProfilePreferences( |
// profiles that might not have it set yet). |
SigninManagerBase* signin_manager = |
SigninManagerFactory::GetForProfile(profile); |
- signin_manager->SetAuthenticatedAccountInfo(gaia_id, |
- user_context.GetUserID()); |
+ signin_manager->SetAuthenticatedAccountInfo( |
+ gaia_id, user_context.GetAccountId().GetUserEmail()); |
// Backfill GAIA ID in user prefs stored in Local State. |
std::string tmp_gaia_id; |
user_manager::UserManager* user_manager = user_manager::UserManager::Get(); |
- if (!user_manager->FindGaiaID(user_context.GetUserID(), &tmp_gaia_id) && |
+ if (!user_manager->FindGaiaID(user_context.GetAccountId(), &tmp_gaia_id) && |
!gaia_id.empty()) { |
- user_manager->UpdateGaiaID(user_context.GetUserID(), gaia_id); |
+ user_manager->UpdateGaiaID(user_context.GetAccountId(), gaia_id); |
} |
} |
} |
void UserSessionManager::UserProfileInitialized(Profile* profile, |
bool is_incognito_profile, |
- const std::string& user_id) { |
+ const AccountId& account_id) { |
// Demo user signed in. |
if (is_incognito_profile) { |
profile->OnLogin(); |
@@ -1019,9 +1018,10 @@ void UserSessionManager::UserProfileInitialized(Profile* profile, |
// first. |
bool transfer_saml_auth_cookies_on_subsequent_login = false; |
if (has_auth_cookies_ && |
- g_browser_process->platform_part()-> |
- browser_policy_connector_chromeos()->GetUserAffiliation(user_id) == |
- policy::USER_AFFILIATION_MANAGED) { |
+ g_browser_process->platform_part() |
+ ->browser_policy_connector_chromeos() |
+ ->GetUserAffiliation(account_id.GetUserEmail()) == |
+ policy::USER_AFFILIATION_MANAGED) { |
CrosSettings::Get()->GetBoolean( |
kAccountsPrefTransferSAMLCookies, |
&transfer_saml_auth_cookies_on_subsequent_login); |
@@ -1090,7 +1090,7 @@ void UserSessionManager::FinalizePrepareProfile(Profile* profile) { |
user_manager::UserManager* user_manager = user_manager::UserManager::Get(); |
if (user_manager->IsLoggedInAsUserWithGaiaAccount()) { |
if (user_context_.GetAuthFlow() == UserContext::AUTH_FLOW_GAIA_WITH_SAML) |
- user_manager->UpdateUsingSAML(user_context_.GetUserID(), true); |
+ user_manager->UpdateUsingSAML(user_context_.GetAccountId(), true); |
SAMLOfflineSigninLimiter* saml_offline_signin_limiter = |
SAMLOfflineSigninLimiterFactory::GetForProfile(profile); |
if (saml_offline_signin_limiter) |
@@ -1123,10 +1123,10 @@ void UserSessionManager::FinalizePrepareProfile(Profile* profile) { |
user_context_.ClearSecrets(); |
if (TokenHandlesEnabled()) { |
CreateTokenUtilIfMissing(); |
- if (token_handle_util_->ShouldObtainHandle(user->GetUserID())) { |
+ if (token_handle_util_->ShouldObtainHandle(user->GetAccountId())) { |
if (!token_handle_fetcher_.get()) { |
token_handle_fetcher_.reset(new TokenHandleFetcher( |
- token_handle_util_.get(), user->GetUserID())); |
+ token_handle_util_.get(), user->GetAccountId())); |
token_handle_fetcher_->BackfillToken( |
profile, base::Bind(&UserSessionManager::OnTokenHandleObtained, |
weak_factory_.GetWeakPtr())); |
@@ -1438,7 +1438,7 @@ void UserSessionManager::RestorePendingUserSessions() { |
DCHECK(!user_already_logged_in); |
if (!user_already_logged_in) { |
- UserContext user_context(user_id); |
+ UserContext user_context(AccountId::FromUserEmail(user_id)); |
user_context.SetUserIDHash(user_id_hash); |
user_context.SetIsUsingOAuth(false); |
@@ -1476,7 +1476,7 @@ void UserSessionManager::UpdateEasyUnlockKeys(const UserContext& user_context) { |
// TODO(xiyuan): Fix inconsistency user type of |user_context| introduced in |
// authenticator. |
const user_manager::User* user = |
- user_manager::UserManager::Get()->FindUser(user_context.GetUserID()); |
+ user_manager::UserManager::Get()->FindUser(user_context.GetAccountId()); |
if (!user || !user->HasGaiaAccount()) |
return; |
@@ -1501,7 +1501,7 @@ void UserSessionManager::UpdateEasyUnlockKeys(const UserContext& user_context) { |
key_manager->RefreshKeys( |
user_context, *device_list, |
base::Bind(&UserSessionManager::OnEasyUnlockKeyOpsFinished, AsWeakPtr(), |
- user_context.GetUserID())); |
+ user_context.GetAccountId().GetUserEmail())); |
} |
net::URLRequestContextGetter* |
@@ -1562,8 +1562,8 @@ void UserSessionManager::OnEasyUnlockKeyOpsFinished( |
if (!easy_unlock_key_ops_finished_callback_.is_null()) |
easy_unlock_key_ops_finished_callback_.Run(); |
- const user_manager::User* user = |
- user_manager::UserManager::Get()->FindUser(user_id); |
+ const user_manager::User* user = user_manager::UserManager::Get()->FindUser( |
+ AccountId::FromUserEmail(user_id)); |
EasyUnlockService* easy_unlock_service = |
EasyUnlockService::GetForUser(*user); |
easy_unlock_service->CheckCryptohomeKeysAndMaybeHardlock(); |
@@ -1724,9 +1724,9 @@ void UserSessionManager::SendUserPodsMetrics() { |
void UserSessionManager::OnOAuth2TokensFetched(UserContext context) { |
if (StartupUtils::IsWebviewSigninEnabled() && TokenHandlesEnabled()) { |
CreateTokenUtilIfMissing(); |
- if (token_handle_util_->ShouldObtainHandle(context.GetUserID())) { |
+ if (token_handle_util_->ShouldObtainHandle(context.GetAccountId())) { |
token_handle_fetcher_.reset(new TokenHandleFetcher( |
- token_handle_util_.get(), context.GetUserID())); |
+ token_handle_util_.get(), context.GetAccountId())); |
token_handle_fetcher_->FillForNewUser( |
context.GetAccessToken(), |
base::Bind(&UserSessionManager::OnTokenHandleObtained, |
@@ -1735,7 +1735,7 @@ void UserSessionManager::OnOAuth2TokensFetched(UserContext context) { |
} |
} |
-void UserSessionManager::OnTokenHandleObtained(const user_manager::UserID& id, |
+void UserSessionManager::OnTokenHandleObtained(const AccountId& account_id, |
bool success) { |
if (!success) |
LOG(ERROR) << "OAuth2 token handle fetch failed."; |