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

Unified Diff: chrome/browser/chromeos/login/screens/user_selection_screen.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/screens/user_selection_screen.cc
diff --git a/chrome/browser/chromeos/login/screens/user_selection_screen.cc b/chrome/browser/chromeos/login/screens/user_selection_screen.cc
index 814faee0196f4f8509c36bf03975a9ca2b9b8d0e..18befd404db9a204778905847edb46f997bc14b5 100644
--- a/chrome/browser/chromeos/login/screens/user_selection_screen.cc
+++ b/chrome/browser/chromeos/login/screens/user_selection_screen.cc
@@ -143,14 +143,14 @@ void UserSelectionScreen::FillUserDictionary(
AuthType auth_type,
const std::vector<std::string>* public_session_recommended_locales,
base::DictionaryValue* user_dict) {
- const user_manager::UserID user_id = user->email();
+ const user_manager::UserID user_id = user->GetUserID();
const bool is_public_session =
user->GetType() == user_manager::USER_TYPE_PUBLIC_ACCOUNT;
const bool is_legacy_supervised_user =
user->GetType() == user_manager::USER_TYPE_SUPERVISED;
const bool is_child_user = user->GetType() == user_manager::USER_TYPE_CHILD;
- user_dict->SetString(kKeyUsername, user_id);
+ user_dict->SetString(kKeyUsername, user_id.GetUserEmail());
user_dict->SetString(kKeyEmailAddress, user->display_email());
user_dict->SetString(kKeyDisplayName, user->GetDisplayName());
user_dict->SetBoolean(kKeyPublicAccount, is_public_session);
@@ -174,7 +174,7 @@ void UserSelectionScreen::FillUserDictionary(
void UserSelectionScreen::FillKnownUserPrefs(user_manager::User* user,
base::DictionaryValue* user_dict) {
std::string gaia_id;
- if (user_manager::UserManager::Get()->FindGaiaID(user->email(), &gaia_id)) {
+ if (user_manager::UserManager::Get()->FindGaiaID(user->GetUserID(), &gaia_id)) {
user_dict->SetString(kKeyGaiaID, gaia_id);
}
}
@@ -184,7 +184,7 @@ void UserSelectionScreen::FillMultiProfileUserPrefs(
user_manager::User* user,
base::DictionaryValue* user_dict,
bool is_signin_to_add) {
- const std::string& user_id = user->email();
+ const user_manager::UserID& user_id = user->GetUserID();
if (is_signin_to_add) {
MultiProfileUserController* multi_profile_user_controller =
@@ -240,7 +240,7 @@ bool UserSelectionScreen::ShouldForceOnlineSignIn(
// At this point the reason for invalid token should be already set. If not,
// this might be a leftover from an old version.
if (token_status == user_manager::User::OAUTH2_TOKEN_STATUS_INVALID)
- RecordReauthReason(user->email(), ReauthReason::OTHER);
+ RecordReauthReason(user->GetUserID(), ReauthReason::OTHER);
return user->force_online_signin() ||
(token_status == user_manager::User::OAUTH2_TOKEN_STATUS_INVALID) ||
@@ -265,21 +265,21 @@ void UserSelectionScreen::Init(const user_manager::UserList& users,
activity_detector->AddObserver(this);
}
-void UserSelectionScreen::OnBeforeUserRemoved(const std::string& username) {
+void UserSelectionScreen::OnBeforeUserRemoved(const user_manager::UserID& user_id) {
for (user_manager::UserList::iterator it = users_.begin(); it != users_.end();
++it) {
- if ((*it)->email() == username) {
+ if ((*it)->GetUserID() == user_id) {
users_.erase(it);
break;
}
}
}
-void UserSelectionScreen::OnUserRemoved(const std::string& username) {
+void UserSelectionScreen::OnUserRemoved(const user_manager::UserID& user_id) {
if (!handler_)
return;
- handler_->OnUserRemoved(username);
+ handler_->OnUserRemoved(user_id);
}
void UserSelectionScreen::OnUserImageChanged(const user_manager::User& user) {
@@ -312,17 +312,17 @@ void UserSelectionScreen::OnUserActivity(const ui::Event* event) {
// static
const user_manager::UserList UserSelectionScreen::PrepareUserListForSending(
const user_manager::UserList& users,
- std::string owner,
+ const user_manager::UserID& owner,
bool is_signin_to_add) {
user_manager::UserList users_to_send;
- bool has_owner = owner.size() > 0;
+ bool has_owner = !owner.empty();
size_t max_non_owner_users = has_owner ? kMaxUsers - 1 : kMaxUsers;
size_t non_owner_count = 0;
for (user_manager::UserList::const_iterator it = users.begin();
it != users.end();
++it) {
- const std::string& user_id = (*it)->email();
+ const user_manager::UserID& user_id = (*it)->GetUserID();
Denis Kuznetsov (DE-MUC) 2015/06/10 16:50:46 auto
bool is_owner = (user_id == owner);
bool is_public_account =
((*it)->GetType() == user_manager::USER_TYPE_PUBLIC_ACCOUNT);
@@ -354,8 +354,9 @@ void UserSelectionScreen::SendUserList() {
bool single_user = users.size() == 1;
bool is_signin_to_add = LoginDisplayHostImpl::default_host() &&
user_manager::UserManager::Get()->IsUserLoggedIn();
- std::string owner;
- chromeos::CrosSettings::Get()->GetString(chromeos::kDeviceOwner, &owner);
+ std::string owner_email;
+ chromeos::CrosSettings::Get()->GetString(chromeos::kDeviceOwner, &owner_email);
+ const user_manager::UserID owner(user_manager::UserID::FromUserEmail(owner_email));
policy::BrowserPolicyConnectorChromeOS* connector =
g_browser_process->platform_part()->browser_policy_connector_chromeos();
@@ -370,7 +371,7 @@ void UserSelectionScreen::SendUserList() {
for (user_manager::UserList::const_iterator it = users_to_send.begin();
it != users_to_send.end();
++it) {
- const std::string& user_id = (*it)->email();
+ const user_manager::UserID& user_id = (*it)->GetUserID();
bool is_owner = (user_id == owner);
const bool is_public_account =
((*it)->GetType() == user_manager::USER_TYPE_PUBLIC_ACCOUNT);
@@ -411,7 +412,7 @@ void UserSelectionScreen::HandleGetUsers() {
SendUserList();
}
-void UserSelectionScreen::CheckUserStatus(const std::string& user_id) {
+void UserSelectionScreen::CheckUserStatus(const user_manager::UserID& user_id) {
// No checks on lock screen.
if (ScreenLocker::default_screen_locker())
return;
@@ -440,7 +441,7 @@ void UserSelectionScreen::OnUserStatusChecked(
// EasyUnlock stuff
-void UserSelectionScreen::SetAuthType(const std::string& user_id,
+void UserSelectionScreen::SetAuthType(const user_manager::UserID& user_id,
AuthType auth_type,
const base::string16& initial_value) {
if (GetAuthType(user_id) == FORCE_OFFLINE_PASSWORD)
@@ -452,10 +453,10 @@ void UserSelectionScreen::SetAuthType(const std::string& user_id,
}
proximity_auth::ScreenlockBridge::LockHandler::AuthType
-UserSelectionScreen::GetAuthType(const std::string& username) const {
- if (user_auth_type_map_.find(username) == user_auth_type_map_.end())
+UserSelectionScreen::GetAuthType(const user_manager::UserID& user_id) const {
+ if (user_auth_type_map_.find(user_id) == user_auth_type_map_.end())
return OFFLINE_PASSWORD;
- return user_auth_type_map_.find(username)->second;
+ return user_auth_type_map_.find(user_id)->second;
}
proximity_auth::ScreenlockBridge::LockHandler::ScreenType
@@ -474,7 +475,7 @@ void UserSelectionScreen::ShowBannerMessage(const base::string16& message) {
}
void UserSelectionScreen::ShowUserPodCustomIcon(
- const std::string& user_id,
+ const user_manager::UserID& user_id,
const proximity_auth::ScreenlockBridge::UserPodCustomIconOptions&
icon_options) {
scoped_ptr<base::DictionaryValue> icon = icon_options.ToDictionaryValue();
@@ -483,7 +484,7 @@ void UserSelectionScreen::ShowUserPodCustomIcon(
view_->ShowUserPodCustomIcon(user_id, *icon);
}
-void UserSelectionScreen::HideUserPodCustomIcon(const std::string& user_id) {
+void UserSelectionScreen::HideUserPodCustomIcon(const user_manager::UserID& user_id) {
view_->HideUserPodCustomIcon(user_id);
}
@@ -495,12 +496,12 @@ void UserSelectionScreen::EnableInput() {
ScreenLocker::default_screen_locker()->EnableInput();
}
-void UserSelectionScreen::Unlock(const std::string& user_email) {
+void UserSelectionScreen::Unlock(const user_manager::UserID& user_id) {
DCHECK_EQ(GetScreenType(), LOCK_SCREEN);
ScreenLocker::Hide();
}
-void UserSelectionScreen::AttemptEasySignin(const std::string& user_id,
+void UserSelectionScreen::AttemptEasySignin(const user_manager::UserID& user_id,
const std::string& secret,
const std::string& key_label) {
DCHECK_EQ(GetScreenType(), SIGNIN_SCREEN);
@@ -513,7 +514,7 @@ void UserSelectionScreen::AttemptEasySignin(const std::string& user_id,
login_display_delegate_->Login(user_context, SigninSpecifics());
}
-void UserSelectionScreen::HardLockPod(const std::string& user_id) {
+void UserSelectionScreen::HardLockPod(const user_manager::UserID& user_id) {
view_->SetAuthType(user_id, OFFLINE_PASSWORD, base::string16());
EasyUnlockService* service = GetEasyUnlockServiceForUser(user_id);
if (!service)
@@ -521,14 +522,14 @@ void UserSelectionScreen::HardLockPod(const std::string& user_id) {
service->SetHardlockState(EasyUnlockScreenlockStateHandler::USER_HARDLOCK);
}
-void UserSelectionScreen::AttemptEasyUnlock(const std::string& user_id) {
+void UserSelectionScreen::AttemptEasyUnlock(const user_manager::UserID& user_id) {
EasyUnlockService* service = GetEasyUnlockServiceForUser(user_id);
if (!service)
return;
service->AttemptAuth(user_id);
}
-void UserSelectionScreen::RecordClickOnLockIcon(const std::string& user_id) {
+void UserSelectionScreen::RecordClickOnLockIcon(const user_manager::UserID& user_id) {
EasyUnlockService* service = GetEasyUnlockServiceForUser(user_id);
if (!service)
return;
@@ -536,13 +537,13 @@ void UserSelectionScreen::RecordClickOnLockIcon(const std::string& user_id) {
}
EasyUnlockService* UserSelectionScreen::GetEasyUnlockServiceForUser(
- const std::string& user_id) const {
+ const user_manager::UserID& user_id) const {
if (GetScreenType() == OTHER_SCREEN)
return nullptr;
const user_manager::User* unlock_user = nullptr;
for (const user_manager::User* user : GetUsers()) {
- if (user->email() == user_id) {
+ if (user->GetUserID() == user_id) {
unlock_user = user;
break;
}

Powered by Google App Engine
This is Rietveld 408576698