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

Unified Diff: chrome/browser/chromeos/login/session/user_session_manager.cc

Issue 1165323004: We should use UserID object to identify users instead of username. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 months 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 side-by-side diff with in-line comments
Download patch
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 a07149b6de725d3e04f7b8b4b3c9eb52d5faff39..ac6bf73e7b493e3d31912879b5ea0b9b330ceaf5 100644
--- a/chrome/browser/chromeos/login/session/user_session_manager.cc
+++ b/chrome/browser/chromeos/login/session/user_session_manager.cc
@@ -374,7 +374,7 @@ void UserSessionManager::CompleteGuestSessionLogin(const GURL& start_url) {
if (!about_flags::AreSwitchesIdenticalToCurrentCommandLine(
user_flags, *base::CommandLine::ForCurrentProcess(), NULL)) {
DBusThreadManager::Get()->GetSessionManagerClient()->SetFlagsForUser(
- chromeos::login::kGuestUserName, base::CommandLine::StringVector());
+ chromeos::login::GetGuestUserID(), base::CommandLine::StringVector());
}
RestartChrome(cmd_line_str);
@@ -412,7 +412,7 @@ 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.GetUserID().GetUserEmail();
PreStartSession();
CreateUserSession(user_context, has_auth_cookies);
@@ -465,14 +465,14 @@ void UserSessionManager::RestoreAuthenticationSession(Profile* user_profile) {
ProfileHelper::Get()->GetUserByProfile(user_profile);
DCHECK(user);
if (!net::NetworkChangeNotifier::IsOffline()) {
- pending_signin_restore_sessions_.erase(user->email());
+ pending_signin_restore_sessions_.erase(user->GetUserID());
RestoreAuthSessionImpl(user_profile, false /* has_auth_cookies */);
} else {
// Even if we're online we should wait till initial
// OnConnectionTypeChanged() call. Otherwise starting fetchers too early may
// end up canceling all request when initial network connection type is
// processed. See http://crbug.com/121643.
- pending_signin_restore_sessions_.insert(user->email());
+ pending_signin_restore_sessions_.insert(user->GetUserID());
}
}
@@ -656,7 +656,7 @@ bool UserSessionManager::RestartToApplyPerSessionFlagsIfNeed(
flags.assign(user_flags.argv().begin() + 1, user_flags.argv().end());
LOG(WARNING) << "Restarting to apply per-session flags...";
DBusThreadManager::Get()->GetSessionManagerClient()->SetFlagsForUser(
- user_manager::UserManager::Get()->GetActiveUser()->email(), flags);
+ user_manager::UserManager::Get()->GetActiveUser()->GetUserID(), flags);
AttemptRestart(profile);
return true;
}
@@ -721,7 +721,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()->GetUserID(),
user_status);
}
@@ -764,7 +764,7 @@ void UserSessionManager::OnConnectionTypeChanged(
Profile* user_profile = ProfileHelper::Get()->GetProfileByUserUnsafe(*it);
bool should_restore_session =
- pending_signin_restore_sessions_.find((*it)->email()) !=
+ pending_signin_restore_sessions_.find((*it)->GetUserID()) !=
pending_signin_restore_sessions_.end();
OAuth2LoginManager* login_manager =
OAuth2LoginManagerFactory::GetInstance()->GetForProfile(user_profile);
@@ -773,7 +773,7 @@ void UserSessionManager::OnConnectionTypeChanged(
// we need to kick off OAuth token verification process again.
login_manager->ContinueSessionRestore();
} else if (should_restore_session) {
- pending_signin_restore_sessions_.erase((*it)->email());
+ pending_signin_restore_sessions_.erase((*it)->GetUserID());
RestoreAuthSessionImpl(user_profile, false /* has_auth_cookies */);
}
}
@@ -823,9 +823,9 @@ void UserSessionManager::PreStartSession() {
void UserSessionManager::StoreUserContextDataBeforeProfileIsCreated() {
// Store obfuscated GAIA ID.
- if (!user_context_.GetGaiaID().empty()) {
+ if (!user_context_.GetUserID().GetGaiaId().empty()) {
user_manager::UserManager::Get()->UpdateGaiaID(user_context_.GetUserID(),
- user_context_.GetGaiaID());
+ user_context_.GetUserID().GetGaiaId());
}
}
@@ -861,7 +861,7 @@ void UserSessionManager::PrepareProfile() {
is_demo_session),
base::string16(),
base::string16(),
- std::string());
+ user_manager::UserID(std::string(), std::string()));
Denis Kuznetsov (DE-MUC) 2015/06/10 16:50:46 EmptyGaiaID() ?
}
void UserSessionManager::OnProfileCreated(const UserContext& user_context,
@@ -918,23 +918,28 @@ void UserSessionManager::InitProfilePreferences(
user_manager::UserManager::Get()->GetActiveUser();
std::string supervised_user_sync_id =
ChromeUserManager::Get()->GetSupervisedUserManager()->GetUserSyncId(
- active_user->email());
+ active_user->GetUserID());
profile->GetPrefs()->SetString(prefs::kSupervisedUserId,
supervised_user_sync_id);
} else if (user_manager::UserManager::Get()->
IsLoggedInAsUserWithGaiaAccount()) {
- // Get the Gaia ID from the user context. If it's not available, this may
- // not be available when unlocking a previously opened profile, or when
- // creating a supervised users. However, in these cases the gaia_id should
- // be already available in the account tracker.
- std::string gaia_id = user_context.GetGaiaID();
- if (gaia_id.empty()) {
- AccountTrackerService* account_tracker =
- AccountTrackerServiceFactory::GetForProfile(profile);
- AccountTrackerService::AccountInfo info =
- account_tracker->FindAccountInfoByEmail(user_context.GetUserID());
- gaia_id = info.gaia;
- DCHECK(!gaia_id.empty());
+ user_manager::UserID user_id(user->GetUserID());
+
+ {
+ // Get the Gaia ID from the user context. If it's not available, this may
+ // not be available when unlocking a previously opened profile, or when
+ // creating a supervised users. However, in these cases the gaia_id should
+ // be already available in the account tracker.
+ std::string gaia_id = user_context.GetUserID().GetGaiaId();
+ if (gaia_id.empty()) {
+ AccountTrackerService* account_tracker =
+ AccountTrackerServiceFactory::GetForProfile(profile);
+ AccountTrackerService::AccountInfo info =
+ account_tracker->FindAccountInfoByEmail(user_context.GetUserID().GetUserEmail());
+ gaia_id = info.gaia;
+ DCHECK(!gaia_id.empty());
+ }
+ user_id.SetGaiaId(gaia_id);
}
// Make sure that the google service username is properly set (we do this
@@ -942,22 +947,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(user_id.GetGaiaId(),
+ user_id.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) &&
- !gaia_id.empty()) {
- user_manager->UpdateGaiaID(user_context.GetUserID(), gaia_id);
+ !user_id.GetGaiaId().empty()) {
+ user_manager->UpdateGaiaID(user_context.GetUserID(), user_id.GetGaiaId());
}
}
}
void UserSessionManager::UserProfileInitialized(Profile* profile,
bool is_incognito_profile,
- const std::string& user_id) {
+ const user_manager::UserID& user_id) {
// Demo user signed in.
if (is_incognito_profile) {
profile->OnLogin();
@@ -1342,7 +1347,7 @@ void UserSessionManager::OnRestoreActiveSessions(
user_manager::UserManager* user_manager = user_manager::UserManager::Get();
DCHECK(user_manager->GetLoggedInUsers().size() == 1);
DCHECK(user_manager->GetActiveUser());
- std::string active_user_id = user_manager->GetActiveUser()->email();
+ const user_manager::UserID& active_user_id = user_manager->GetActiveUser()->GetUserID();
Denis Kuznetsov (DE-MUC) 2015/06/10 16:50:46 auto
SessionManagerClient::ActiveSessionsMap::const_iterator it;
for (it = sessions.begin(); it != sessions.end(); ++it) {
@@ -1363,7 +1368,7 @@ void UserSessionManager::RestorePendingUserSessions() {
// Get next user to restore sessions and delete it from list.
SessionManagerClient::ActiveSessionsMap::const_iterator it =
pending_user_sessions_.begin();
- std::string user_id = it->first;
+ user_manager::UserID user_id = it->first;
std::string user_id_hash = it->second;
DCHECK(!user_id.empty());
DCHECK(!user_id_hash.empty());
@@ -1377,7 +1382,7 @@ void UserSessionManager::RestorePendingUserSessions() {
it != logged_in_users.end();
++it) {
const user_manager::User* user = (*it);
- if (user->email() == user_id) {
+ if (user->GetUserID() == user_id) {
user_already_logged_in = true;
break;
}
@@ -1497,7 +1502,7 @@ void UserSessionManager::AttemptRestart(Profile* profile) {
}
void UserSessionManager::OnEasyUnlockKeyOpsFinished(
- const std::string& user_id,
+ const user_manager::UserID& user_id,
bool success) {
running_easy_unlock_key_ops_ = false;
if (!easy_unlock_key_ops_finished_callback_.is_null())

Powered by Google App Engine
This is Rietveld 408576698