Index: chrome/browser/chromeos/login/existing_user_controller.cc |
diff --git a/chrome/browser/chromeos/login/existing_user_controller.cc b/chrome/browser/chromeos/login/existing_user_controller.cc |
index 9866456dd4e0d92c43499d2566ea2e3edf68635e..342141a17fe9660c1fcdee04d7aa7c6bfb506bd5 100644 |
--- a/chrome/browser/chromeos/login/existing_user_controller.cc |
+++ b/chrome/browser/chromeos/login/existing_user_controller.cc |
@@ -64,6 +64,7 @@ |
#include "components/policy/core/common/policy_map.h" |
#include "components/policy/core/common/policy_service.h" |
#include "components/policy/core/common/policy_types.h" |
+#include "components/user_manager/user_id.h" |
#include "components/user_manager/user_manager.h" |
#include "components/user_manager/user_type.h" |
#include "content/public/browser/browser_thread.h" |
@@ -152,13 +153,16 @@ ExistingUserController* ExistingUserController::current_controller_ = NULL; |
// ExistingUserController, public: |
ExistingUserController::ExistingUserController(LoginDisplayHost* host) |
- : auth_status_consumer_(NULL), |
+ : public_session_auto_login_user_id_(std::string(), std::string()), |
+ auth_status_consumer_(NULL), |
+ last_login_attempt_user_id_(std::string(), std::string()), |
Denis Kuznetsov (DE-MUC)
2015/06/10 16:50:46
EmptyUserID()
here and above?
|
host_(host), |
login_display_(host_->CreateLoginDisplay(this)), |
num_login_attempts_(0), |
cros_settings_(CrosSettings::Get()), |
offline_failed_(false), |
is_login_in_progress_(false), |
+ online_succeeded_for_(std::string(), std::string()), |
Denis Kuznetsov (DE-MUC)
2015/06/10 16:50:46
EmptyUserID()?
|
password_changed_(false), |
auth_mode_(LoginPerformer::AUTH_MODE_EXTENSION), |
signin_screen_ready_(false), |
@@ -229,7 +233,7 @@ void ExistingUserController::UpdateLoginDisplay( |
(*it)->GetType() != user_manager::USER_TYPE_SUPERVISED || |
user_manager::UserManager::Get()->AreSupervisedUsersAllowed(); |
bool meets_whitelist_requirements = |
- CrosSettings::IsWhitelisted((*it)->email(), NULL) || |
+ CrosSettings::IsWhitelisted((*it)->GetUserID(), NULL) || |
!(*it)->HasGaiaAccount(); |
// Public session accounts are always shown on login screen. |
@@ -330,7 +334,7 @@ void ExistingUserController::CreateAccount() { |
content::RecordAction(base::UserMetricsAction("Login.CreateAccount")); |
guest_mode_url_ = google_util::AppendGoogleLocaleParam( |
GURL(kCreateAccountURL), g_browser_process->GetApplicationLocale()); |
- Login(UserContext(user_manager::USER_TYPE_GUEST, std::string()), |
+ Login(UserContext(user_manager::USER_TYPE_GUEST, login::GetGuestUserID()), |
SigninSpecifics()); |
} |
@@ -383,7 +387,7 @@ void ExistingUserController::PerformLogin( |
login_performer_.reset(new ChromeLoginPerformer(this)); |
} |
- if (gaia::ExtractDomainName(user_context.GetUserID()) == |
+ if (gaia::ExtractDomainName(user_context.GetUserID().GetUserEmail()) == |
Denis Kuznetsov (DE-MUC)
2015/06/10 16:50:46
Maybe add chromeos::login::IsSupervisedUser(UserID
|
chromeos::login::kSupervisedUserDomain) { |
login_performer_->LoginAsSupervisedUser(user_context); |
} else { |
@@ -517,7 +521,7 @@ void ExistingUserController::OnAuthFailure(const AuthFailure& failure) { |
PerformLoginFinishedActions(false /* don't start public session timer */); |
if (ChromeUserManager::Get() |
- ->GetUserFlow(last_login_attempt_username_) |
+ ->GetUserFlow(last_login_attempt_user_id_) |
->HandleLoginFailure(failure)) { |
return; |
} |
@@ -534,7 +538,7 @@ void ExistingUserController::OnAuthFailure(const AuthFailure& failure) { |
ShowTPMError(); |
} else if (!online_succeeded_for_.empty()) { |
ShowGaiaPasswordChanged(online_succeeded_for_); |
- } else if (last_login_attempt_username_ == chromeos::login::kGuestUserName) { |
+ } else if (last_login_attempt_user_id_ == chromeos::login::GetGuestUserID()) { |
Denis Kuznetsov (DE-MUC)
2015/06/10 16:50:46
Maybe introduce chromeos::login::IsGuestUser(UserI
|
// Show no errors, just re-enable input. |
login_display_->ClearAndEnablePassword(); |
StartPublicSessionAutoLoginTimer(); |
@@ -542,7 +546,7 @@ void ExistingUserController::OnAuthFailure(const AuthFailure& failure) { |
// Check networking after trying to login in case user is |
// cached locally or the local admin account. |
bool is_known_user = user_manager::UserManager::Get()->IsKnownUser( |
- last_login_attempt_username_); |
+ last_login_attempt_user_id_); |
if (!network_state_helper_->IsConnected()) { |
if (is_known_user) |
ShowError(IDS_LOGIN_ERROR_AUTHENTICATING, error); |
@@ -567,7 +571,7 @@ void ExistingUserController::OnAuthFailure(const AuthFailure& failure) { |
// Reset user flow to default, so that special flow will not affect next |
// attempt. |
- ChromeUserManager::Get()->ResetUserFlow(last_login_attempt_username_); |
+ ChromeUserManager::Get()->ResetUserFlow(last_login_attempt_user_id_); |
if (auth_status_consumer_) |
auth_status_consumer_->OnAuthFailure(failure); |
@@ -578,7 +582,7 @@ void ExistingUserController::OnAuthFailure(const AuthFailure& failure) { |
// TODO(ginkage): Fix this case once crbug.com/469990 is ready. |
/* |
if (failure.reason() == AuthFailure::COULD_NOT_MOUNT_CRYPTOHOME) { |
- RecordReauthReason(last_login_attempt_username_, |
+ RecordReauthReason(last_login_attempt_user_id_, |
ReauthReason::MISSING_CRYPTOHOME); |
} |
*/ |
@@ -644,7 +648,7 @@ void ExistingUserController::OnProfilePrepared(Profile* profile, |
// TODO(nkostylev): Pass UserContext back crbug.com/424550 |
if (auth_status_consumer_) { |
auth_status_consumer_-> |
- OnAuthSuccess(UserContext(last_login_attempt_username_)); |
+ OnAuthSuccess(UserContext(last_login_attempt_user_id_)); |
} |
} |
@@ -676,7 +680,7 @@ void ExistingUserController::OnPasswordChangeDetected() { |
} |
if (ChromeUserManager::Get() |
- ->GetUserFlow(last_login_attempt_username_) |
+ ->GetUserFlow(last_login_attempt_user_id_) |
->HandlePasswordChangeDetected()) { |
return; |
} |
@@ -691,7 +695,7 @@ void ExistingUserController::OnPasswordChangeDetected() { |
// TODO(gspencer): We shouldn't have to erase stateful data when |
// doing this. See http://crosbug.com/9115 http://crosbug.com/7792 |
login_display_->ShowPasswordChangedDialog(show_invalid_old_password_error, |
- display_email_); |
+ user_manager::UserID::FromUserEmail(display_email_)); |
if (auth_status_consumer_) |
auth_status_consumer_->OnPasswordChangeDetected(); |
@@ -699,7 +703,7 @@ void ExistingUserController::OnPasswordChangeDetected() { |
display_email_.clear(); |
} |
-void ExistingUserController::WhiteListCheckFailed(const std::string& email) { |
+void ExistingUserController::WhiteListCheckFailed(const user_manager::UserID& user_id) { |
PerformLoginFinishedActions(true /* start public session timer */); |
offline_failed_ = false; |
@@ -709,11 +713,11 @@ void ExistingUserController::WhiteListCheckFailed(const std::string& email) { |
if (g_browser_process->platform_part() |
->browser_policy_connector_chromeos() |
->IsEnterpriseManaged()) { |
- ShowError(IDS_ENTERPRISE_LOGIN_ERROR_WHITELIST, email); |
+ ShowError(IDS_ENTERPRISE_LOGIN_ERROR_WHITELIST, user_id.GetUserEmail()); |
} else { |
- ShowError(IDS_LOGIN_ERROR_WHITELIST, email); |
+ ShowError(IDS_LOGIN_ERROR_WHITELIST, user_id.GetUserEmail()); |
} |
- login_display_->ShowSigninUI(email); |
+ login_display_->ShowSigninUI(user_id); |
} |
if (auth_status_consumer_) { |
@@ -732,13 +736,13 @@ void ExistingUserController::PolicyLoadFailed() { |
display_email_.clear(); |
} |
-void ExistingUserController::OnOnlineChecked(const std::string& username, |
+void ExistingUserController::OnOnlineChecked(const user_manager::UserID& user_id, |
bool success) { |
- if (success && last_login_attempt_username_ == username) { |
- online_succeeded_for_ = username; |
+ if (success && last_login_attempt_user_id_ == user_id) { |
+ online_succeeded_for_ = user_id; |
// Wait for login attempt to end, if it hasn't yet. |
if (offline_failed_ && !is_login_in_progress_) |
- ShowGaiaPasswordChanged(username); |
+ ShowGaiaPasswordChanged(user_id); |
} |
} |
@@ -771,7 +775,7 @@ bool ExistingUserController::password_changed() const { |
void ExistingUserController::LoginAsGuest() { |
PerformPreLoginActions(UserContext(user_manager::USER_TYPE_GUEST, |
- chromeos::login::kGuestUserName)); |
+ chromeos::login::GetGuestUserID())); |
bool allow_guest; |
cros_settings_->GetBoolean(kAccountsPrefAllowGuest, &allow_guest); |
@@ -867,10 +871,10 @@ void ExistingUserController::LoginAsPublicSession( |
LoginAsPublicSessionInternal(new_user_context); |
} |
-void ExistingUserController::LoginAsKioskApp(const std::string& app_id, |
+void ExistingUserController::LoginAsKioskApp(const user_manager::UserID& user_id, |
bool diagnostic_mode) { |
const bool auto_start = false; |
- host_->StartAppLaunch(app_id, diagnostic_mode, auto_start); |
+ host_->StartAppLaunch(user_id.GetUserEmail(), diagnostic_mode, auto_start); |
Denis Kuznetsov (DE-MUC)
2015/06/10 16:50:46
Please add ToDo that app id can be at some point b
|
} |
void ExistingUserController::ConfigurePublicSessionAutoLogin() { |
@@ -880,20 +884,20 @@ void ExistingUserController::ConfigurePublicSessionAutoLogin() { |
const std::vector<policy::DeviceLocalAccount> device_local_accounts = |
policy::GetDeviceLocalAccounts(cros_settings_); |
- public_session_auto_login_username_.clear(); |
+ public_session_auto_login_user_id_.clear(); |
for (std::vector<policy::DeviceLocalAccount>::const_iterator |
it = device_local_accounts.begin(); |
it != device_local_accounts.end(); ++it) { |
if (it->account_id == auto_login_account_id) { |
- public_session_auto_login_username_ = it->user_id; |
+ public_session_auto_login_user_id_ = it->user_id; |
break; |
} |
} |
const user_manager::User* user = user_manager::UserManager::Get()->FindUser( |
- public_session_auto_login_username_); |
+ public_session_auto_login_user_id_); |
if (!user || user->GetType() != user_manager::USER_TYPE_PUBLIC_ACCOUNT) |
- public_session_auto_login_username_.clear(); |
+ public_session_auto_login_user_id_.clear(); |
if (!cros_settings_->GetInteger( |
kAccountsPrefDeviceLocalAccountAutoLoginDelay, |
@@ -901,7 +905,7 @@ void ExistingUserController::ConfigurePublicSessionAutoLogin() { |
public_session_auto_login_delay_ = 0; |
} |
- if (!public_session_auto_login_username_.empty()) |
+ if (!public_session_auto_login_user_id_.empty()) |
StartPublicSessionAutoLoginTimer(); |
else |
StopPublicSessionAutoLoginTimer(); |
@@ -916,9 +920,9 @@ void ExistingUserController::ResetPublicSessionAutoLoginTimer() { |
} |
void ExistingUserController::OnPublicSessionAutoLoginTimerFire() { |
- CHECK(signin_screen_ready_ && !public_session_auto_login_username_.empty()); |
+ CHECK(signin_screen_ready_ && !public_session_auto_login_user_id_.empty()); |
Login(UserContext(user_manager::USER_TYPE_PUBLIC_ACCOUNT, |
- public_session_auto_login_username_), |
+ public_session_auto_login_user_id_), |
SigninSpecifics()); |
} |
@@ -930,7 +934,7 @@ void ExistingUserController::StopPublicSessionAutoLoginTimer() { |
void ExistingUserController::StartPublicSessionAutoLoginTimer() { |
if (!signin_screen_ready_ || |
is_login_in_progress_ || |
- public_session_auto_login_username_.empty()) { |
+ public_session_auto_login_user_id_.empty()) { |
return; |
} |
@@ -977,7 +981,7 @@ void ExistingUserController::ShowError(int error_id, |
if (num_login_attempts_ > 1) { |
const user_manager::User* user = |
user_manager::UserManager::Get()->FindUser( |
- last_login_attempt_username_); |
+ last_login_attempt_user_id_); |
if (user && (user->GetType() == user_manager::USER_TYPE_SUPERVISED)) |
error_id = IDS_LOGIN_ERROR_AUTHENTICATING_2ND_TIME_SUPERVISED; |
} |
@@ -987,15 +991,15 @@ void ExistingUserController::ShowError(int error_id, |
} |
void ExistingUserController::ShowGaiaPasswordChanged( |
- const std::string& username) { |
+ const user_manager::UserID& user_id) { |
// Invalidate OAuth token, since it can't be correct after password is |
// changed. |
user_manager::UserManager::Get()->SaveUserOAuthStatus( |
- username, user_manager::User::OAUTH2_TOKEN_STATUS_INVALID); |
- RecordReauthReason(username, ReauthReason::OTHER); |
+ user_id, user_manager::User::OAUTH2_TOKEN_STATUS_INVALID); |
+ RecordReauthReason(user_id, ReauthReason::OTHER); |
login_display_->SetUIEnabled(true); |
- login_display_->ShowGaiaPasswordChanged(username); |
+ login_display_->ShowGaiaPasswordChanged(user_id); |
} |
void ExistingUserController::SendAccessibilityAlert( |
@@ -1040,8 +1044,8 @@ void ExistingUserController::PerformPreLoginActions( |
// Disable clicking on other windows and status tray. |
login_display_->SetUIEnabled(false); |
- if (last_login_attempt_username_ != user_context.GetUserID()) { |
- last_login_attempt_username_ = user_context.GetUserID(); |
+ if (last_login_attempt_user_id_ != user_context.GetUserID()) { |
Denis Kuznetsov (DE-MUC)
2015/06/10 16:50:46
Same question about (un)equality as above.
|
+ last_login_attempt_user_id_ = user_context.GetUserID(); |
num_login_attempts_ = 0; |
// Also reset state variables, which are used to determine password change. |
@@ -1129,7 +1133,7 @@ void ExistingUserController::DoCompleteLogin( |
if (device_id.empty()) { |
bool is_ephemeral = |
ChromeUserManager::Get()->AreEphemeralUsersEnabled() && |
- user_context.GetUserID() != ChromeUserManager::Get()->GetOwnerEmail(); |
+ user_context.GetUserID() != ChromeUserManager::Get()->GetOwnerID(); |
device_id = ChromeSigninClient::GenerateSigninScopedDeviceID(is_ephemeral); |
} |
user_context.SetDeviceId(device_id); |