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

Unified Diff: chrome/browser/ui/webui/chromeos/login/signin_screen_handler.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/webui/chromeos/login/signin_screen_handler.cc
diff --git a/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.cc b/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.cc
index dd2b7015d23b54dfeec4e3254c2ffc82bee496fa..31fe77657b6bfb389e9b33f4069fc7ebc2c9135f 100644
--- a/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.cc
+++ b/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.cc
@@ -177,12 +177,12 @@ std::string GetNetworkName(const std::string& service_path) {
}
static bool SetUserInputMethodImpl(
- const std::string& username,
+ const user_manager::UserID& user_id,
const std::string& user_input_method,
input_method::InputMethodManager::State* ime_state) {
if (!chromeos::input_method::InputMethodManager::Get()->IsLoginKeyboard(
user_input_method)) {
- LOG(WARNING) << "SetUserInputMethod('" << username
+ LOG(WARNING) << "SetUserInputMethod('" << user_id.GetUserEmail()
<< "'): stored user LRU input method '" << user_input_method
<< "' is no longer Full Latin Keyboard Language"
<< " (entry dropped). Use hardware default instead.";
@@ -192,14 +192,14 @@ static bool SetUserInputMethodImpl(
base::DictionaryValue* const users_lru_input_methods = updater.Get();
if (users_lru_input_methods != NULL) {
- users_lru_input_methods->SetStringWithoutPathExpansion(username, "");
+ users_lru_input_methods->SetStringWithoutPathExpansion(user_id.GetUserEmail(), "");
}
return false;
}
if (!Contains(ime_state->GetActiveInputMethodIds(), user_input_method)) {
if (!ime_state->EnableInputMethod(user_input_method)) {
- DLOG(ERROR) << "SigninScreenHandler::SetUserInputMethod('" << username
+ DLOG(ERROR) << "SigninScreenHandler::SetUserInputMethod('" << user_id.GetUserEmail()
<< "'): user input method '" << user_input_method
<< "' is not enabled and enabling failed (ignored!).";
}
@@ -297,27 +297,27 @@ SigninScreenHandler::~SigninScreenHandler() {
max_mode_delegate_.reset(NULL);
}
GetScreenlockBridgeInstance()->SetLockHandler(NULL);
- GetScreenlockBridgeInstance()->SetFocusedUser("");
+ GetScreenlockBridgeInstance()->SetFocusedUser(user_manager::UserID(std::string(), std::string()));
}
// static
std::string SigninScreenHandler::GetUserLRUInputMethod(
- const std::string& username) {
+ const user_manager::UserID& user_id) {
PrefService* const local_state = g_browser_process->local_state();
const base::DictionaryValue* users_lru_input_methods =
local_state->GetDictionary(prefs::kUsersLRUInputMethod);
if (!users_lru_input_methods) {
- DLOG(WARNING) << "GetUserLRUInputMethod('" << username
+ DLOG(WARNING) << "GetUserLRUInputMethod('" << user_id.GetUserEmail()
<< "'): no kUsersLRUInputMethod";
return std::string();
}
std::string input_method;
- if (!users_lru_input_methods->GetStringWithoutPathExpansion(username,
+ if (!users_lru_input_methods->GetStringWithoutPathExpansion(user_id.GetUserEmail(),
&input_method)) {
- DVLOG(0) << "GetUserLRUInputMethod('" << username
+ DVLOG(0) << "GetUserLRUInputMethod('" << user_id.GetUserEmail()
<< "'): no input method for this user";
return std::string();
}
@@ -328,20 +328,20 @@ std::string SigninScreenHandler::GetUserLRUInputMethod(
// static
// Update keyboard layout to least recently used by the user.
void SigninScreenHandler::SetUserInputMethod(
- const std::string& username,
+ const user_manager::UserID& user_id,
input_method::InputMethodManager::State* ime_state) {
bool succeed = false;
- const std::string input_method = GetUserLRUInputMethod(username);
+ const std::string input_method = GetUserLRUInputMethod(user_id);
if (!input_method.empty())
- succeed = SetUserInputMethodImpl(username, input_method, ime_state);
+ succeed = SetUserInputMethodImpl(user_id, input_method, ime_state);
// This is also a case when LRU layout is set only for a few local users,
// thus others need to be switched to default locale.
// Otherwise they will end up using another user's locale to log in.
if (!succeed) {
- DVLOG(0) << "SetUserInputMethod('" << username
+ DVLOG(0) << "SetUserInputMethod('" << user_id.GetUserEmail()
<< "'): failed to set user layout. Switching to default.";
ime_state->SetInputMethodLoginDefault();
@@ -886,15 +886,15 @@ void SigninScreenHandler::RefocusCurrentPod() {
core_oobe_actor_->RefocusCurrentPod();
}
-void SigninScreenHandler::OnUserRemoved(const std::string& username) {
- CallJS("login.AccountPickerScreen.removeUser", username);
+void SigninScreenHandler::OnUserRemoved(const user_manager::UserID& user_id) {
+ CallJS("login.AccountPickerScreen.removeUser", user_id.GetUserEmail());
if (delegate_->GetUsers().empty())
OnShowAddUser();
}
void SigninScreenHandler::OnUserImageChanged(const user_manager::User& user) {
if (page_is_ready())
- CallJS("login.AccountPickerScreen.updateUserImage", user.email());
+ CallJS("login.AccountPickerScreen.updateUserImage", user.GetUserID().GetUserEmail());
}
void SigninScreenHandler::OnPreferencesChanged() {
@@ -939,29 +939,29 @@ void SigninScreenHandler::ShowErrorScreen(LoginDisplay::SigninError error_id) {
}
}
-void SigninScreenHandler::ShowSigninUI(const std::string& email) {
- core_oobe_actor_->ShowSignInUI(email);
+void SigninScreenHandler::ShowSigninUI(const user_manager::UserID& user_id) {
+ core_oobe_actor_->ShowSignInUI(user_id);
}
-void SigninScreenHandler::ShowGaiaPasswordChanged(const std::string& username) {
- gaia_screen_handler_->PasswordChangedFor(username);
- gaia_screen_handler_->PopulateEmail(username);
- core_oobe_actor_->ShowSignInUI(username);
- CallJS("login.setAuthType", username,
+void SigninScreenHandler::ShowGaiaPasswordChanged(const user_manager::UserID& user_id) {
+ gaia_screen_handler_->PasswordChangedFor(user_id);
+ gaia_screen_handler_->PopulateEmail(user_id.GetUserEmail());
+ core_oobe_actor_->ShowSignInUI(user_id);
+ CallJS("login.setAuthType", user_id.GetUserEmail(),
static_cast<int>(UserSelectionScreen::ONLINE_SIGN_IN),
base::StringValue(""));
}
void SigninScreenHandler::ShowPasswordChangedDialog(bool show_password_error,
- const std::string& email) {
- core_oobe_actor_->ShowPasswordChangedScreen(show_password_error, email);
+ const user_manager::UserID& user_id) {
+ core_oobe_actor_->ShowPasswordChangedScreen(show_password_error, user_id);
}
void SigninScreenHandler::ShowSigninScreenForCreds(
- const std::string& username,
+ const user_manager::UserID& user_id,
const std::string& password) {
DCHECK(gaia_screen_handler_);
- gaia_screen_handler_->ShowSigninScreenForCreds(username, password);
+ gaia_screen_handler_->ShowSigninScreenForCreds(user_id, password);
}
void SigninScreenHandler::ShowWhitelistCheckFailedError() {
@@ -1029,13 +1029,13 @@ void SigninScreenHandler::HandleAuthenticateUser(const std::string& username,
const std::string& password) {
if (!delegate_)
return;
- UserContext user_context(gaia::SanitizeEmail(username));
+ UserContext user_context(user_manager::UserID::FromUserEmail(gaia::SanitizeEmail(username)));
user_context.SetKey(Key(password));
delegate_->Login(user_context, SigninSpecifics());
}
void SigninScreenHandler::HandleLaunchIncognito() {
- UserContext context(user_manager::USER_TYPE_GUEST, std::string());
+ UserContext context(user_manager::USER_TYPE_GUEST, user_manager::UserID(std::string(), std::string()));
if (delegate_)
delegate_->Login(context, SigninSpecifics());
}
@@ -1050,12 +1050,14 @@ void SigninScreenHandler::HandleShowSupervisedUserCreationScreen() {
}
void SigninScreenHandler::HandleLaunchPublicSession(
- const std::string& user_id,
+ const std::string& user_id_str,
const std::string& locale,
const std::string& input_method) {
if (!delegate_)
return;
+ const user_manager::UserID user_id(user_manager::UserID::FromUserEmail(user_id_str));
+
UserContext context(user_manager::USER_TYPE_PUBLIC_ACCOUNT, user_id);
context.SetPublicSessionLocale(locale),
context.SetPublicSessionInputMethod(input_method);
@@ -1083,7 +1085,7 @@ void SigninScreenHandler::HandleShutdownSystem() {
void SigninScreenHandler::HandleLoadWallpaper(const std::string& email) {
if (delegate_)
- delegate_->LoadWallpaper(email);
+ delegate_->LoadWallpaper(user_manager::UserID::FromUserEmail(email));
}
void SigninScreenHandler::HandleRebootSystem() {
@@ -1093,7 +1095,7 @@ void SigninScreenHandler::HandleRebootSystem() {
void SigninScreenHandler::HandleRemoveUser(const std::string& email) {
if (!delegate_)
return;
- delegate_->RemoveUser(email);
+ delegate_->RemoveUser(user_manager::UserID::FromUserEmail(email));
UpdateAddButtonStatus();
}
@@ -1108,7 +1110,7 @@ void SigninScreenHandler::HandleShowAddUser(const base::ListValue* args) {
args->GetString(0, &email);
gaia_screen_handler_->PopulateEmail(email);
if (!email.empty())
- SendReauthReason(email);
+ SendReauthReason(user_manager::UserID::FromUserEmail(email));
OnShowAddUser();
}
@@ -1214,9 +1216,9 @@ void SigninScreenHandler::HandleLoginVisible(const std::string& source) {
}
void SigninScreenHandler::HandleCancelPasswordChangedFlow(
- const std::string& user_id) {
- if (!user_id.empty())
- RecordReauthReason(user_id, ReauthReason::PASSWORD_UPDATE_SKIPPED);
+ const std::string& user_id_str) {
+ if (!user_id_str.empty())
+ RecordReauthReason(user_manager::UserID::FromUserEmail(user_id_str), ReauthReason::PASSWORD_UPDATE_SKIPPED);
gaia_screen_handler_->StartClearingCookies(
base::Bind(&SigninScreenHandler::CancelPasswordChangedFlowInternal,
weak_factory_.GetWeakPtr()));
@@ -1278,7 +1280,8 @@ void SigninScreenHandler::HandleUpdateOfflineLogin(bool offline_login_active) {
offline_login_active_ = offline_login_active;
}
-void SigninScreenHandler::HandleFocusPod(const std::string& user_id) {
+void SigninScreenHandler::HandleFocusPod(const std::string& user_id_str) {
+ const user_manager::UserID user_id(user_manager::UserID::FromUserEmail(user_id_str));
SetUserInputMethod(user_id, ime_state_.get());
WallpaperManager::Get()->SetUserWallpaperDelayed(user_id);
GetScreenlockBridgeInstance()->SetFocusedUser(user_id);
@@ -1289,29 +1292,30 @@ void SigninScreenHandler::HandleFocusPod(const std::string& user_id) {
}
void SigninScreenHandler::HandleGetPublicSessionKeyboardLayouts(
- const std::string& user_id,
+ const std::string& user_id_str,
const std::string& locale) {
GetKeyboardLayoutsForLocale(
base::Bind(&SigninScreenHandler::SendPublicSessionKeyboardLayouts,
weak_factory_.GetWeakPtr(),
- user_id,
+ user_manager::UserID::FromUserEmail(user_id_str),
locale),
locale);
}
void SigninScreenHandler::SendPublicSessionKeyboardLayouts(
- const std::string& user_id,
+ const user_manager::UserID& user_id,
const std::string& locale,
scoped_ptr<base::ListValue> keyboard_layouts) {
CallJS("login.AccountPickerScreen.setPublicSessionKeyboardLayouts",
- user_id,
+ user_id.GetUserEmail(),
locale,
*keyboard_layouts);
}
void SigninScreenHandler::HandleLaunchKioskApp(const std::string& app_id,
bool diagnostic_mode) {
- UserContext context(user_manager::USER_TYPE_KIOSK_APP, app_id);
+ const user_manager::UserID app_user_id(user_manager::UserID::FromUserEmail(app_id));
+ UserContext context(user_manager::USER_TYPE_KIOSK_APP, app_user_id);
SigninSpecifics specifics;
specifics.kiosk_diagnostic_mode = diagnostic_mode;
if (delegate_)
@@ -1352,7 +1356,7 @@ void SigninScreenHandler::HandleFirstIncorrectPasswordAttempt(
void SigninScreenHandler::HandleMaxIncorrectPasswordAttempts(
const std::string& email) {
- RecordReauthReason(email, ReauthReason::INCORRECT_PASSWORD_ENTERED);
+ RecordReauthReason(user_manager::UserID::FromUserEmail(email), ReauthReason::INCORRECT_PASSWORD_ENTERED);
}
bool SigninScreenHandler::AllWhitelistedUsersPresent() {
@@ -1373,7 +1377,7 @@ bool SigninScreenHandler::AllWhitelistedUsersPresent() {
std::string whitelisted_user;
// NB: Wildcards in the whitelist are also detected as not present here.
if (!whitelist->GetString(i, &whitelisted_user) ||
- !user_manager->IsKnownUser(whitelisted_user)) {
+ !user_manager->IsKnownUser(user_manager::UserID::FromUserEmail(whitelisted_user))) {
return false;
}
}

Powered by Google App Engine
This is Rietveld 408576698