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

Unified Diff: chrome/browser/ui/ash/session_state_delegate_chromeos.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/ui/ash/session_state_delegate_chromeos.cc
diff --git a/chrome/browser/ui/ash/session_state_delegate_chromeos.cc b/chrome/browser/ui/ash/session_state_delegate_chromeos.cc
index f7dcc0aab8d8d7a21c01b959733bccf8c133ac56..1a518d82266e1882e647e1db8b9a3f4d0239ded0 100644
--- a/chrome/browser/ui/ash/session_state_delegate_chromeos.cc
+++ b/chrome/browser/ui/ash/session_state_delegate_chromeos.cc
@@ -63,7 +63,7 @@ content::BrowserContext* SessionStateDelegateChromeos::GetBrowserContextByIndex(
content::BrowserContext*
SessionStateDelegateChromeos::GetBrowserContextForWindow(
aura::Window* window) {
- const std::string& user_id =
+ const user_manager::UserID& user_id =
chrome::MultiUserWindowManager::GetInstance()->GetWindowOwner(window);
return user_id.empty() ? NULL
: multi_user_util::GetProfileFromUserID(user_id);
@@ -72,7 +72,7 @@ SessionStateDelegateChromeos::GetBrowserContextForWindow(
content::BrowserContext*
SessionStateDelegateChromeos::GetUserPresentingBrowserContextForWindow(
aura::Window* window) {
- const std::string& user_id =
+ const user_manager::UserID& user_id =
chrome::MultiUserWindowManager::GetInstance()->GetUserPresentingWindow(
window);
return user_id.empty() ? NULL
@@ -181,12 +181,12 @@ bool SessionStateDelegateChromeos::ShouldShowAvatar(
}
void SessionStateDelegateChromeos::SwitchActiveUser(
- const std::string& user_id) {
+ const user_manager::UserID& user_id) {
// Disallow switching to an already active user since that might crash.
// Also check that we got a user id and not an email address.
- DCHECK_EQ(user_id,
- gaia::CanonicalizeEmail(gaia::SanitizeEmail(user_id)));
- if (user_id == user_manager::UserManager::Get()->GetActiveUser()->email())
+ DCHECK_EQ(user_id.GetUserEmail(),
+ gaia::CanonicalizeEmail(gaia::SanitizeEmail(user_id.GetUserEmail())));
+ if (user_id == user_manager::UserManager::Get()->GetActiveUser()->GetUserID())
return;
TryToSwitchUser(user_id);
}
@@ -199,14 +199,14 @@ void SessionStateDelegateChromeos::CycleActiveUser(CycleUser cycle_user) {
const user_manager::UserList& logged_in_users =
user_manager::UserManager::Get()->GetLoggedInUsers();
- std::string user_id =
- user_manager::UserManager::Get()->GetActiveUser()->email();
+ user_manager::UserID user_id =
+ user_manager::UserManager::Get()->GetActiveUser()->GetUserID();
// Get an iterator positioned at the active user.
user_manager::UserList::const_iterator it;
for (it = logged_in_users.begin();
it != logged_in_users.end(); ++it) {
- if ((*it)->email() == user_id)
+ if ((*it)->GetUserID() == user_id)
break;
}
@@ -219,14 +219,14 @@ void SessionStateDelegateChromeos::CycleActiveUser(CycleUser cycle_user) {
switch (cycle_user) {
case CYCLE_TO_NEXT_USER:
if (++it == logged_in_users.end())
- user_id = (*logged_in_users.begin())->email();
+ user_id = (*logged_in_users.begin())->GetUserID();
else
- user_id = (*it)->email();
+ user_id = (*it)->GetUserID();
break;
case CYCLE_TO_PREVIOUS_USER:
if (it == logged_in_users.begin())
it = logged_in_users.end();
- user_id = (*(--it))->email();
+ user_id = (*(--it))->GetUserID();
break;
}
@@ -259,14 +259,14 @@ void SessionStateDelegateChromeos::ActiveUserChanged(
const user_manager::User* active_user) {
FOR_EACH_OBSERVER(ash::SessionStateObserver,
session_state_observer_list_,
- ActiveUserChanged(active_user->email()));
+ ActiveUserChanged(active_user->GetUserID()));
}
void SessionStateDelegateChromeos::UserAddedToSession(
const user_manager::User* added_user) {
FOR_EACH_OBSERVER(ash::SessionStateObserver,
session_state_observer_list_,
- UserAddedToSession(added_user->email()));
+ UserAddedToSession(added_user->GetUserID()));
}
void SessionStateDelegateChromeos::OnUserAddingStarted() {
@@ -292,11 +292,11 @@ void SessionStateDelegateChromeos::NotifySessionStateChanged() {
SessionStateChanged(session_state_));
}
-void DoSwitchUser(const std::string& user_id) {
+void DoSwitchUser(const user_manager::UserID& user_id) {
user_manager::UserManager::Get()->SwitchActiveUser(user_id);
}
void SessionStateDelegateChromeos::TryToSwitchUser(
- const std::string& user_id) {
+ const user_manager::UserID& user_id) {
ash::TrySwitchingActiveUser(base::Bind(&DoSwitchUser, user_id));
}

Powered by Google App Engine
This is Rietveld 408576698