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 e6c79a7488ecb1f451d29521e114c282f7780681..73fe249a954885853e14d47a22e5dfc2ab21bdf7 100644 |
--- a/chrome/browser/chromeos/login/existing_user_controller.cc |
+++ b/chrome/browser/chromeos/login/existing_user_controller.cc |
@@ -16,7 +16,6 @@ |
#include "base/metrics/histogram.h" |
#include "base/prefs/pref_service.h" |
#include "base/strings/string_util.h" |
-#include "base/strings/stringprintf.h" |
#include "base/strings/utf_string_conversions.h" |
#include "base/values.h" |
#include "base/version.h" |
@@ -24,10 +23,8 @@ |
#include "chrome/browser/browser_process.h" |
#include "chrome/browser/browser_process_platform_part.h" |
#include "chrome/browser/chrome_notification_types.h" |
-#include "chrome/browser/chromeos/accessibility/accessibility_manager.h" |
#include "chrome/browser/chromeos/boot_times_loader.h" |
#include "chrome/browser/chromeos/customization_document.h" |
-#include "chrome/browser/chromeos/first_run/first_run.h" |
#include "chrome/browser/chromeos/kiosk_mode/kiosk_mode_settings.h" |
#include "chrome/browser/chromeos/login/helper.h" |
#include "chrome/browser/chromeos/login/login_utils.h" |
@@ -42,7 +39,6 @@ |
#include "chrome/browser/chromeos/policy/device_local_account_policy_service.h" |
#include "chrome/browser/chromeos/profiles/profile_helper.h" |
#include "chrome/browser/chromeos/settings/cros_settings.h" |
-#include "chrome/browser/prefs/session_startup_pref.h" |
#include "chrome/browser/ui/webui/chromeos/login/l10n_util.h" |
#include "chrome/common/chrome_switches.h" |
#include "chrome/common/chrome_version_info.h" |
@@ -88,11 +84,6 @@ namespace { |
const char kCreateAccountURL[] = |
"https://accounts.google.com/NewAccount?service=mail"; |
-// ChromeVox tutorial URL (used in place of "getting started" url when |
-// accessibility is enabled). |
-const char kChromeVoxTutorialURLPattern[] = |
- "http://www.chromevox.com/tutorial/index.html?lang=%s"; |
- |
// Delay for transferring the auth cache to the system profile. |
const long int kAuthCacheTransferDelayMs = 2000; |
@@ -325,8 +316,7 @@ ExistingUserController::~ExistingUserController() { |
void ExistingUserController::CancelPasswordChangedFlow() { |
login_performer_.reset(NULL); |
- login_display_->SetUIEnabled(true); |
- StartPublicSessionAutoLoginTimer(); |
+ PerformLoginFinishedActions(true); |
} |
void ExistingUserController::CreateAccount() { |
@@ -343,11 +333,7 @@ void ExistingUserController::CompleteLogin(const UserContext& user_context) { |
return; |
} |
- // Stop the auto-login timer when attempting login. |
- StopPublicSessionAutoLoginTimer(); |
- |
- // Disable UI while loading user profile. |
- login_display_->SetUIEnabled(false); |
+ PerformPreLoginActions(user_context); |
if (!time_init_.is_null()) { |
base::TimeDelta delta = base::Time::Now() - time_init_; |
@@ -386,7 +372,7 @@ void ExistingUserController::CompleteLoginInternal( |
// Enable UI for the enrollment screen. SetUIEnabled(true) will post a |
// request to show the sign-in screen again when invoked at the sign-in |
// screen; invoke SetUIEnabled() after navigating to the enrollment screen. |
- login_display_->SetUIEnabled(true); |
+ PerformLoginFinishedActions(false /* don't start public session timer */); |
} else { |
PerformLogin(user_context, LoginPerformer::AUTH_MODE_EXTENSION); |
} |
@@ -427,34 +413,18 @@ void ExistingUserController::Login(const UserContext& user_context, |
if (!user_context.HasCredentials()) |
return; |
- // Stop the auto-login timer when attempting login. |
- StopPublicSessionAutoLoginTimer(); |
- |
- // Disable clicking on other windows. |
- login_display_->SetUIEnabled(false); |
- |
- if (last_login_attempt_username_ != user_context.GetUserID()) { |
- last_login_attempt_username_ = user_context.GetUserID(); |
- num_login_attempts_ = 0; |
- // Also reset state variables, which are used to determine password change. |
- offline_failed_ = false; |
- online_succeeded_for_.clear(); |
- } |
- num_login_attempts_++; |
+ PerformPreLoginActions(user_context); |
PerformLogin(user_context, LoginPerformer::AUTH_MODE_INTERNAL); |
} |
void ExistingUserController::PerformLogin( |
const UserContext& user_context, |
LoginPerformer::AuthorizationMode auth_mode) { |
- ChromeUserManager::Get()->GetUserFlow(last_login_attempt_username_)->set_host( |
+ ChromeUserManager::Get()->GetUserFlow(user_context.GetUserID())->set_host( |
host_); |
BootTimesLoader::Get()->RecordLoginAttempted(); |
- // Disable UI while loading user profile. |
- login_display_->SetUIEnabled(false); |
- |
// Use the same LoginPerformer for subsequent login as it has state |
// such as Authenticator instance. |
if (!login_performer_.get() || num_login_attempts_ <= 1) { |
@@ -463,7 +433,6 @@ void ExistingUserController::PerformLogin( |
login_performer_.reset(new LoginPerformer(this)); |
} |
- is_login_in_progress_ = true; |
if (gaia::ExtractDomainName(user_context.GetUserID()) == |
chromeos::login::kSupervisedUserDomain) { |
login_performer_->LoginAsSupervisedUser(user_context); |
@@ -475,18 +444,14 @@ void ExistingUserController::PerformLogin( |
} |
void ExistingUserController::LoginAsRetailModeUser() { |
- // Stop the auto-login timer when attempting login. |
- StopPublicSessionAutoLoginTimer(); |
+ PerformPreLoginActions(UserContext(chromeos::login::kRetailModeUserName)); |
Denis Kuznetsov (DE-MUC)
2014/10/20 13:38:59
You might want to use
UserContext(user_manager::U
Nikita (slow)
2014/10/20 13:52:11
Done.
|
- // Disable clicking on other windows. |
- login_display_->SetUIEnabled(false); |
// TODO(rkc): Add a CHECK to make sure retail mode logins are allowed once |
// the enterprise policy wiring is done for retail mode. |
// Only one instance of LoginPerformer should exist at a time. |
login_performer_.reset(NULL); |
login_performer_.reset(new LoginPerformer(this)); |
- is_login_in_progress_ = true; |
login_performer_->LoginRetailMode(); |
SendAccessibilityAlert( |
l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_LOGIN_SIGNIN_DEMOUSER)); |
@@ -498,11 +463,7 @@ void ExistingUserController::LoginAsGuest() { |
return; |
} |
- // Stop the auto-login timer when attempting login. |
- StopPublicSessionAutoLoginTimer(); |
- |
- // Disable clicking on other windows. |
- login_display_->SetUIEnabled(false); |
+ PerformPreLoginActions(UserContext(chromeos::login::kGuestUserName)); |
CrosSettingsProvider::TrustedStatus status = |
cros_settings_->PrepareTrustedValues( |
@@ -512,9 +473,7 @@ void ExistingUserController::LoginAsGuest() { |
if (status == CrosSettingsProvider::PERMANENTLY_UNTRUSTED) { |
login_display_->ShowError(IDS_LOGIN_ERROR_OWNER_KEY_LOST, 1, |
HelpAppLauncher::HELP_CANT_ACCESS_ACCOUNT); |
- // Reenable clicking on other windows and status area. |
- login_display_->SetUIEnabled(true); |
- StartPublicSessionAutoLoginTimer(); |
+ PerformLoginFinishedActions(true); |
display_email_.clear(); |
return; |
} else if (status != CrosSettingsProvider::TRUSTED) { |
@@ -531,9 +490,7 @@ void ExistingUserController::LoginAsGuest() { |
// this nicely. |
login_display_->ShowError(IDS_LOGIN_ERROR_WHITELIST, 1, |
HelpAppLauncher::HELP_CANT_ACCESS_ACCOUNT); |
- // Reenable clicking on other windows and status area. |
- login_display_->SetUIEnabled(true); |
- StartPublicSessionAutoLoginTimer(); |
+ PerformLoginFinishedActions(true); |
display_email_.clear(); |
return; |
} |
@@ -541,7 +498,6 @@ void ExistingUserController::LoginAsGuest() { |
// Only one instance of LoginPerformer should exist at a time. |
login_performer_.reset(NULL); |
login_performer_.reset(new LoginPerformer(this)); |
- is_login_in_progress_ = true; |
login_performer_->LoginOffTheRecord(); |
SendAccessibilityAlert( |
l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_LOGIN_SIGNIN_OFFRECORD)); |
@@ -560,11 +516,7 @@ void ExistingUserController::LoginAsPublicSession( |
return; |
} |
- // Stop the auto-login timer when attempting login. |
- StopPublicSessionAutoLoginTimer(); |
- |
- // Disable clicking on other windows. |
- login_display_->SetUIEnabled(false); |
+ PerformPreLoginActions(user_context); |
CrosSettingsProvider::TrustedStatus status = |
cros_settings_->PrepareTrustedValues( |
@@ -576,8 +528,7 @@ void ExistingUserController::LoginAsPublicSession( |
if (status == CrosSettingsProvider::PERMANENTLY_UNTRUSTED) { |
login_display_->ShowError(IDS_LOGIN_ERROR_OWNER_KEY_LOST, 1, |
HelpAppLauncher::HELP_CANT_ACCESS_ACCOUNT); |
- // Re-enable clicking on other windows. |
- login_display_->SetUIEnabled(true); |
+ PerformLoginFinishedActions(false); |
return; |
} |
@@ -591,9 +542,7 @@ void ExistingUserController::LoginAsPublicSession( |
const user_manager::User* user = |
user_manager::UserManager::Get()->FindUser(user_context.GetUserID()); |
if (!user || user->GetType() != user_manager::USER_TYPE_PUBLIC_ACCOUNT) { |
- // Re-enable clicking on other windows. |
- login_display_->SetUIEnabled(true); |
- StartPublicSessionAutoLoginTimer(); |
+ PerformLoginFinishedActions(true); |
return; |
} |
@@ -768,16 +717,15 @@ void ExistingUserController::ShowTPMError() { |
// |
void ExistingUserController::OnAuthFailure(const AuthFailure& failure) { |
- is_login_in_progress_ = false; |
offline_failed_ = true; |
- |
guest_mode_url_ = GURL::EmptyGURL(); |
std::string error = failure.GetErrorString(); |
+ PerformLoginFinishedActions(false); |
+ |
if (ChromeUserManager::Get() |
->GetUserFlow(last_login_attempt_username_) |
->HandleLoginFailure(failure)) { |
- login_display_->SetUIEnabled(true); |
return; |
} |
@@ -816,8 +764,6 @@ void ExistingUserController::OnAuthFailure(const AuthFailure& failure) { |
ShowError(IDS_LOGIN_ERROR_AUTHENTICATING, error); |
} |
} |
- // Reenable clicking on other windows and status area. |
- login_display_->SetUIEnabled(true); |
login_display_->ClearAndEnablePassword(); |
StartPublicSessionAutoLoginTimer(); |
} |
@@ -875,46 +821,20 @@ void ExistingUserController::OnAuthSuccess(const UserContext& user_context) { |
} |
} |
-void ExistingUserController::OnProfilePrepared(Profile* profile) { |
+void ExistingUserController::OnProfilePrepared(Profile* profile, |
+ bool browser_launched) { |
// Reenable clicking on other windows and status area. |
login_display_->SetUIEnabled(true); |
- user_manager::UserManager* user_manager = user_manager::UserManager::Get(); |
- if (user_manager->IsCurrentUserNew() && |
- user_manager->IsLoggedInAsSupervisedUser()) { |
- // Supervised users should launch into empty desktop on first run. |
- CommandLine::ForCurrentProcess()->AppendSwitch(::switches::kSilentLaunch); |
- } |
- |
- if (user_manager->IsCurrentUserNew() && |
- !ChromeUserManager::Get() |
- ->GetCurrentUserFlow() |
- ->ShouldSkipPostLoginScreens() && |
- !WizardController::default_controller()->skip_post_login_screens()) { |
- // Don't specify start URLs if the administrator has configured the start |
- // URLs via policy. |
- if (!SessionStartupPref::TypeIsManaged(profile->GetPrefs())) |
- InitializeStartUrls(); |
- |
- // Mark the device as registered., i.e. the second part of OOBE as |
- // completed. |
- if (!StartupUtils::IsDeviceRegistered()) |
- StartupUtils::MarkDeviceRegistered(base::Closure()); |
- |
- if (CommandLine::ForCurrentProcess()->HasSwitch( |
- chromeos::switches::kOobeSkipPostLogin)) { |
- LoginUtils::Get()->DoBrowserLaunch(profile, host_); |
- host_ = NULL; |
- } else { |
- ActivateWizard(WizardController::kTermsOfServiceScreenName); |
- } |
- } else { |
- LoginUtils::Get()->DoBrowserLaunch(profile, host_); |
+ if (browser_launched) |
host_ = NULL; |
- } |
+ |
// Inform |auth_status_consumer_| about successful login. |
- if (auth_status_consumer_) |
- auth_status_consumer_->OnAuthSuccess(UserContext()); |
+ // TODO(nkostylev): Pass UserContext back crbug.com/424550 |
+ if (auth_status_consumer_) { |
+ auth_status_consumer_-> |
+ OnAuthSuccess(UserContext(last_login_attempt_username_)); |
+ } |
} |
void ExistingUserController::OnOffTheRecordAuthSuccess() { |
@@ -968,13 +888,11 @@ void ExistingUserController::OnPasswordChangeDetected() { |
} |
void ExistingUserController::WhiteListCheckFailed(const std::string& email) { |
- is_login_in_progress_ = false; |
+ PerformLoginFinishedActions(true); |
offline_failed_ = false; |
ShowError(IDS_LOGIN_ERROR_WHITELIST, email); |
- // Reenable clicking on other windows and status area. |
- login_display_->SetUIEnabled(true); |
login_display_->ShowSigninUI(email); |
if (auth_status_consumer_) { |
@@ -983,22 +901,14 @@ void ExistingUserController::WhiteListCheckFailed(const std::string& email) { |
} |
display_email_.clear(); |
- |
- StartPublicSessionAutoLoginTimer(); |
} |
void ExistingUserController::PolicyLoadFailed() { |
ShowError(IDS_LOGIN_ERROR_OWNER_KEY_LOST, ""); |
- // Reenable clicking on other windows and status area. |
- is_login_in_progress_ = false; |
+ PerformLoginFinishedActions(true); |
Denis Kuznetsov (DE-MUC)
2014/10/20 13:38:59
Check if it makes sense to restart timer in policy
Nikita (slow)
2014/10/20 13:52:11
Done.
|
offline_failed_ = false; |
- login_display_->SetUIEnabled(true); |
- |
display_email_.clear(); |
- |
- // Policy load failure stops login attempts -- restart the timer. |
- StartPublicSessionAutoLoginTimer(); |
} |
void ExistingUserController::OnOnlineChecked(const std::string& username, |
@@ -1023,11 +933,6 @@ void ExistingUserController::DeviceSettingsChanged() { |
} |
} |
-void ExistingUserController::ActivateWizard(const std::string& screen_name) { |
- scoped_ptr<base::DictionaryValue> params; |
- host_->StartWizard(screen_name, params.Pass()); |
-} |
- |
LoginPerformer::AuthorizationMode ExistingUserController::auth_mode() const { |
if (login_performer_) |
return login_performer_->auth_mode(); |
@@ -1122,56 +1027,6 @@ gfx::NativeWindow ExistingUserController::GetNativeWindow() const { |
return host_->GetNativeWindow(); |
} |
-void ExistingUserController::InitializeStartUrls() const { |
- std::vector<std::string> start_urls; |
- |
- const base::ListValue *urls; |
- user_manager::UserManager* user_manager = user_manager::UserManager::Get(); |
- bool can_show_getstarted_guide = |
- user_manager->GetActiveUser()->GetType() == |
- user_manager::USER_TYPE_REGULAR && |
- !user_manager->IsCurrentUserNonCryptohomeDataEphemeral(); |
- if (user_manager->IsLoggedInAsDemoUser()) { |
- if (CrosSettings::Get()->GetList(kStartUpUrls, &urls)) { |
- // The retail mode user will get start URLs from a special policy if it is |
- // set. |
- for (base::ListValue::const_iterator it = urls->begin(); |
- it != urls->end(); ++it) { |
- std::string url; |
- if ((*it)->GetAsString(&url)) |
- start_urls.push_back(url); |
- } |
- } |
- can_show_getstarted_guide = false; |
- // Skip the default first-run behavior for public accounts. |
- } else if (!user_manager->IsLoggedInAsPublicAccount()) { |
- if (AccessibilityManager::Get()->IsSpokenFeedbackEnabled()) { |
- const char* url = kChromeVoxTutorialURLPattern; |
- PrefService* prefs = g_browser_process->local_state(); |
- const std::string current_locale = |
- base::StringToLowerASCII(prefs->GetString(prefs::kApplicationLocale)); |
- std::string vox_url = base::StringPrintf(url, current_locale.c_str()); |
- start_urls.push_back(vox_url); |
- can_show_getstarted_guide = false; |
- } |
- } |
- |
- // Only show getting started guide for a new user. |
- const bool should_show_getstarted_guide = user_manager->IsCurrentUserNew(); |
- |
- if (can_show_getstarted_guide && should_show_getstarted_guide) { |
- // Don't open default Chrome window if we're going to launch the first-run |
- // app. Because we dont' want the first-run app to be hidden in the |
- // background. |
- CommandLine::ForCurrentProcess()->AppendSwitch(::switches::kSilentLaunch); |
- first_run::MaybeLaunchDialogAfterSessionStart(); |
- } else { |
- for (size_t i = 0; i < start_urls.size(); ++i) { |
- CommandLine::ForCurrentProcess()->AppendArg(start_urls[i]); |
- } |
- } |
-} |
- |
void ExistingUserController::ShowError(int error_id, |
const std::string& details) { |
// TODO(dpolukhin): show detailed error info. |details| string contains |
@@ -1255,10 +1110,45 @@ void ExistingUserController::LoginAsPublicSessionInternal( |
// Only one instance of LoginPerformer should exist at a time. |
login_performer_.reset(NULL); |
login_performer_.reset(new LoginPerformer(this)); |
- is_login_in_progress_ = true; |
login_performer_->LoginAsPublicSession(user_context); |
SendAccessibilityAlert( |
l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_LOGIN_SIGNIN_PUBLIC_ACCOUNT)); |
} |
+void ExistingUserController::PerformPreLoginActions( |
+ const UserContext& user_context) { |
+ // Disable clicking on other windows. |
+ login_display_->SetUIEnabled(false); |
+ |
+ if (last_login_attempt_username_ != user_context.GetUserID()) { |
+ last_login_attempt_username_ = user_context.GetUserID(); |
+ num_login_attempts_ = 0; |
+ |
+ // Also reset state variables, which are used to determine password change. |
+ offline_failed_ = false; |
+ online_succeeded_for_.clear(); |
+ } |
+ // Guard in cases when we're called twice but login is still active. |
+ // This might happen when login process is paused till signed settings status |
+ // is verified. |
+ if (!is_login_in_progress_) |
+ num_login_attempts_++; |
+ |
+ // Stop the auto-login timer when attempting login. |
+ StopPublicSessionAutoLoginTimer(); |
+ |
+ is_login_in_progress_ = true; |
Denis Kuznetsov (DE-MUC)
2014/10/20 13:38:59
Reorder with last statement.
Nikita (slow)
2014/10/20 13:52:11
Done.
|
+} |
+ |
+void ExistingUserController::PerformLoginFinishedActions( |
+ bool start_public_session_timer) { |
+ is_login_in_progress_ = false; |
+ |
+ // Reenable clicking on other windows and status area. |
+ login_display_->SetUIEnabled(true); |
+ |
+ if (start_public_session_timer) |
+ StartPublicSessionAutoLoginTimer(); |
+} |
+ |
} // namespace chromeos |