Chromium Code Reviews| 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 1f05411ec0dd3342a96b0f9468a9157cdc7a9d87..1d841777bc160e498844ba581cdb0a6326b7a4a5 100644 |
| --- a/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.cc |
| +++ b/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.cc |
| @@ -874,7 +874,8 @@ void SigninScreenHandler::OnUserRemoved(const std::string& username, |
| void SigninScreenHandler::OnUserImageChanged(const user_manager::User& user) { |
| if (page_is_ready()) |
| - CallJS("login.AccountPickerScreen.updateUserImage", user.email()); |
| + CallJS("login.AccountPickerScreen.updateUserImage", |
| + user.GetAccountId().Serialize()); |
| } |
| void SigninScreenHandler::OnPreferencesChanged() { |
| @@ -988,12 +989,22 @@ void SigninScreenHandler::UpdateAddButtonStatus() { |
| AllWhitelistedUsersPresent()); |
| } |
| -void SigninScreenHandler::HandleAuthenticateUser(const std::string& username, |
| +void SigninScreenHandler::HandleAuthenticateUser(const std::string& user_id, |
| const std::string& password) { |
| if (!delegate_) |
| return; |
| - UserContext user_context( |
| - AccountId::FromUserEmail(gaia::SanitizeEmail(username))); |
| + AccountId account_id(EmptyAccountId()); |
|
dzhioev (left Google)
2015/11/12 00:46:24
Why default constructor of AccountId doesn't produ
Alexander Alekseev
2015/11/12 06:53:04
To force manual construction. We can change this a
|
| + const bool status = AccountId::Deserialize(user_id, &account_id); |
|
stevenjb
2015/11/11 20:39:23
"user_id" does not imply a JSON dictionary. Use so
Alexander Alekseev
2015/11/12 06:53:04
Done.
|
| + // TODO(alemate): this is used also for offline Gaia. |
| + // Add DCHECK() once migrated. |
| + if (!status) { |
| + LOG(WARNING) << "Failed to parse user_id='" << user_id << "'"; |
| + account_id = AccountId::FromUserEmail(user_id); |
| + } |
| + DCHECK_EQ(account_id.GetUserEmail(), |
| + gaia::SanitizeEmail(account_id.GetUserEmail())); |
| + |
| + UserContext user_context(account_id); |
| user_context.SetKey(Key(password)); |
| delegate_->Login(user_context, SigninSpecifics()); |
| } |
| @@ -1020,7 +1031,11 @@ void SigninScreenHandler::HandleLaunchPublicSession( |
| if (!delegate_) |
| return; |
| - UserContext context(user_manager::USER_TYPE_PUBLIC_ACCOUNT, user_id); |
| + AccountId account_id(EmptyAccountId()); |
| + const bool status = AccountId::Deserialize(user_id, &account_id); |
| + DCHECK(status) << "Failed to parse user_id='" << user_id << "'"; |
| + UserContext context(user_manager::USER_TYPE_PUBLIC_ACCOUNT, |
| + account_id.GetUserEmail()); |
| context.SetPublicSessionLocale(locale), |
| context.SetPublicSessionInputMethod(input_method); |
| delegate_->Login(context, SigninSpecifics()); |
| @@ -1175,9 +1190,12 @@ void SigninScreenHandler::HandleLoginVisible(const std::string& source) { |
| void SigninScreenHandler::HandleCancelPasswordChangedFlow( |
| const std::string& user_id) { |
| - if (!user_id.empty()) |
| - RecordReauthReason(AccountId::FromUserEmail(user_id), |
| - ReauthReason::PASSWORD_UPDATE_SKIPPED); |
| + if (!user_id.empty()) { |
| + AccountId account_id(EmptyAccountId()); |
| + const bool status = AccountId::Deserialize(user_id, &account_id); |
| + DCHECK(status) << "Failed to parse user_id='" << user_id << "'"; |
| + RecordReauthReason(account_id, ReauthReason::PASSWORD_UPDATE_SKIPPED); |
| + } |
| gaia_screen_handler_->StartClearingCookies( |
| base::Bind(&SigninScreenHandler::CancelPasswordChangedFlowInternal, |
| weak_factory_.GetWeakPtr())); |
| @@ -1236,18 +1254,21 @@ void SigninScreenHandler::HandleShowLoadingTimeoutError() { |
| } |
| void SigninScreenHandler::HandleFocusPod(const std::string& user_id) { |
| - SetUserInputMethod(user_id, ime_state_.get()); |
| - WallpaperManager::Get()->SetUserWallpaperDelayed(user_id); |
| - proximity_auth::ScreenlockBridge::Get()->SetFocusedUser(user_id); |
| + AccountId account_id(EmptyAccountId()); |
| + const bool status = AccountId::Deserialize(user_id, &account_id); |
| + DCHECK(status) << "Failed to parse user_id='" << user_id << "'"; |
| + SetUserInputMethod(account_id.GetUserEmail(), ime_state_.get()); |
| + WallpaperManager::Get()->SetUserWallpaperDelayed(account_id.GetUserEmail()); |
| + proximity_auth::ScreenlockBridge::Get()->SetFocusedUser( |
| + account_id.GetUserEmail()); |
| if (delegate_) |
| - delegate_->CheckUserStatus(user_id); |
| + delegate_->CheckUserStatus(account_id.GetUserEmail()); |
| if (!test_focus_pod_callback_.is_null()) |
| test_focus_pod_callback_.Run(); |
| bool use_24hour_clock = false; |
| if (user_manager::UserManager::Get()->GetKnownUserBooleanPref( |
| - AccountId::FromUserEmail(user_id), prefs::kUse24HourClock, |
| - &use_24hour_clock)) { |
| + account_id, prefs::kUse24HourClock, &use_24hour_clock)) { |
| g_browser_process->platform_part() |
| ->GetSystemClock() |
| ->SetLastFocusedPodHourClockType(use_24hour_clock ? base::k24HourClock |
| @@ -1258,27 +1279,30 @@ void SigninScreenHandler::HandleFocusPod(const std::string& user_id) { |
| void SigninScreenHandler::HandleGetPublicSessionKeyboardLayouts( |
| const std::string& user_id, |
| const std::string& locale) { |
| + AccountId account_id(EmptyAccountId()); |
| + const bool status = AccountId::Deserialize(user_id, &account_id); |
| + DCHECK(status) << "Failed to parse user_id='" << user_id << "'"; |
| GetKeyboardLayoutsForLocale( |
| base::Bind(&SigninScreenHandler::SendPublicSessionKeyboardLayouts, |
| - weak_factory_.GetWeakPtr(), |
| - user_id, |
| - locale), |
| + weak_factory_.GetWeakPtr(), account_id, locale), |
| locale); |
| } |
| void SigninScreenHandler::SendPublicSessionKeyboardLayouts( |
| - const std::string& user_id, |
| + const AccountId& account_id, |
| const std::string& locale, |
| scoped_ptr<base::ListValue> keyboard_layouts) { |
| CallJS("login.AccountPickerScreen.setPublicSessionKeyboardLayouts", |
| - user_id, |
| - locale, |
| - *keyboard_layouts); |
| + account_id.Serialize(), locale, *keyboard_layouts); |
| } |
| void SigninScreenHandler::HandleLaunchKioskApp(const std::string& app_id, |
| bool diagnostic_mode) { |
| - UserContext context(user_manager::USER_TYPE_KIOSK_APP, app_id); |
| + AccountId account_id(EmptyAccountId()); |
| + const bool status = AccountId::Deserialize(app_id, &account_id); |
| + DCHECK(status) << "Failed to parse app_id='" << app_id << "'"; |
| + UserContext context(user_manager::USER_TYPE_KIOSK_APP, |
| + account_id.GetUserEmail()); |
| SigninSpecifics specifics; |
| specifics.kiosk_diagnostic_mode = diagnostic_mode; |
| if (delegate_) |
| @@ -1309,7 +1333,7 @@ void SigninScreenHandler::HandleLogRemoveUserWarningShown() { |
| } |
| void SigninScreenHandler::HandleFirstIncorrectPasswordAttempt( |
| - const std::string& email) { |
| + const std::string& user_id) { |
| // TODO(ginkage): Fix this case once crbug.com/469987 is ready. |
| /* |
| if (user_manager::UserManager::Get()->FindUsingSAML(email)) |
| @@ -1318,9 +1342,11 @@ void SigninScreenHandler::HandleFirstIncorrectPasswordAttempt( |
| } |
| void SigninScreenHandler::HandleMaxIncorrectPasswordAttempts( |
| - const std::string& email) { |
| - RecordReauthReason(AccountId::FromUserEmail(email), |
| - ReauthReason::INCORRECT_PASSWORD_ENTERED); |
| + const std::string& user_id) { |
| + AccountId account_id(EmptyAccountId()); |
| + const bool status = AccountId::Deserialize(user_id, &account_id); |
| + DCHECK(status) << "Failed to parse user_id='" << user_id << "'"; |
| + RecordReauthReason(account_id, ReauthReason::INCORRECT_PASSWORD_ENTERED); |
| } |
| bool SigninScreenHandler::AllWhitelistedUsersPresent() { |