diff options
author | avayvod@chromium.org <avayvod@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-30 13:40:19 +0000 |
---|---|---|
committer | avayvod@chromium.org <avayvod@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-30 13:40:19 +0000 |
commit | 2558839a26e5a33f5ff00a8de14172775f201adc (patch) | |
tree | 768406ef465989a783dbb5727f931f694571e575 | |
parent | 84a2d52edd965d82320ef0a5909304c3430e6c43 (diff) | |
download | chromium_src-2558839a26e5a33f5ff00a8de14172775f201adc.zip chromium_src-2558839a26e5a33f5ff00a8de14172775f201adc.tar.gz chromium_src-2558839a26e5a33f5ff00a8de14172775f201adc.tar.bz2 |
Fixes transition from account creation screen to images login screen.
BUG=None
TEST=Create user account and verify that images login screen is shown and
the new user logs in.
Review URL: http://codereview.chromium.org/3057020
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@54310 0039d316-1c4b-4281-b951-d872f2087c98
5 files changed, 63 insertions, 16 deletions
diff --git a/chrome/browser/chromeos/login/existing_user_controller.cc b/chrome/browser/chromeos/login/existing_user_controller.cc index 8fffad3..dd262b5 100644 --- a/chrome/browser/chromeos/login/existing_user_controller.cc +++ b/chrome/browser/chromeos/login/existing_user_controller.cc @@ -141,6 +141,27 @@ void ExistingUserController::OwnBackground( background_view_ = background_view; } +void ExistingUserController::LoginNewUser(const std::string& username, + const std::string& password) { + SelectNewUser(); + UserController* new_user = controllers_.back(); + if (!new_user->is_guest()) + return; + NewUserView* new_user_view = new_user->new_user_view(); + new_user_view->SetUsername(username); + + if (password.empty()) + return; + + new_user_view->SetPassword(password); + LOG(INFO) << "Password: " << password; + new_user_view->Login(); +} + +void ExistingUserController::SelectNewUser() { + SelectUser(controllers_.size() - 1); +} + ExistingUserController::~ExistingUserController() { ClearErrors(); @@ -348,7 +369,7 @@ void ExistingUserController::OnLoginSuccess(const std::string& username, AppendStartUrlToCmdline(); if (selected_view_index_ + 1 == controllers_.size()) { // For new user login don't launch browser until we pass image screen. - chromeos::LoginUtils::Get()->EnableBrowserLaunch(false); + LoginUtils::Get()->EnableBrowserLaunch(false); LoginUtils::Get()->CompleteLogin(username, credentials); ActivateWizard(WizardController::kUserImageScreenName); } else { diff --git a/chrome/browser/chromeos/login/existing_user_controller.h b/chrome/browser/chromeos/login/existing_user_controller.h index e825aea..ae3429c 100644 --- a/chrome/browser/chromeos/login/existing_user_controller.h +++ b/chrome/browser/chromeos/login/existing_user_controller.h @@ -57,6 +57,12 @@ class ExistingUserController : public WmMessageListener::Observer, void OwnBackground(views::Widget* background_widget, chromeos::BackgroundView* background_view); + // Tries to login from new user pod with given user login and password. + void LoginNewUser(const std::string& username, const std::string& password); + + // Selects new user pod. + void SelectNewUser(); + private: friend class DeleteTask<ExistingUserController>; diff --git a/chrome/browser/chromeos/login/user_controller.h b/chrome/browser/chromeos/login/user_controller.h index 4aac157..82ac8a9 100644 --- a/chrome/browser/chromeos/login/user_controller.h +++ b/chrome/browser/chromeos/login/user_controller.h @@ -76,6 +76,7 @@ class UserController : public views::ButtonListener, int user_index() const { return user_index_; } bool is_user_selected() const { return is_user_selected_; } bool is_guest() const { return is_guest_; } + NewUserView* new_user_view() const { return new_user_view_; } const UserManager::User& user() const { return user_; } diff --git a/chrome/browser/chromeos/login/wizard_controller.cc b/chrome/browser/chromeos/login/wizard_controller.cc index c3da978..567dfb8 100644 --- a/chrome/browser/chromeos/login/wizard_controller.cc +++ b/chrome/browser/chromeos/login/wizard_controller.cc @@ -340,7 +340,7 @@ void WizardController::ShowNetworkScreen() { background_view_->SetOobeProgress(chromeos::BackgroundView::SELECT_NETWORK); } -void WizardController::ShowLoginScreen() { +chromeos::ExistingUserController* WizardController::ShowLoginScreen() { SetStatusAreaVisible(true); background_view_->SetOobeProgress(chromeos::BackgroundView::SIGNIN); @@ -372,10 +372,11 @@ void WizardController::ShowLoginScreen() { NewRunnableFunction(&DeleteWizardControllerAndApplyCustomization, this)); - return; + return controller; } SetCurrentScreen(GetLoginScreen()); + return NULL; } void WizardController::ShowAccountScreen() { @@ -470,22 +471,33 @@ void WizardController::OnNetworkOffline() { } void WizardController::OnAccountCreateBack() { - ShowLoginScreen(); + chromeos::ExistingUserController* controller = ShowLoginScreen(); + if (controller) + controller->SelectNewUser(); } void WizardController::OnAccountCreated() { - ShowLoginScreen(); + chromeos::ExistingUserController* controller = ShowLoginScreen(); + if (controller) + controller->LoginNewUser(username_, password_); + else + Login(username_, password_); + // TODO(dpolukhin): clear password memory for real. Now it is not + // a problem because we can't extract password from the form. + password_.clear(); +} + +void WizardController::Login(const std::string& username, + const std::string& password) { chromeos::LoginScreen* login = GetLoginScreen(); - if (!username_.empty()) { - login->view()->SetUsername(username_); - if (!password_.empty()) { - login->view()->SetPassword(password_); - // TODO(dpolukhin): clear password memory for real. Now it is not - // a problem because we can't extract password from the form. - password_.clear(); - login->view()->Login(); - } - } + if (username.empty()) + return; + login->view()->SetUsername(username); + + if (password.empty()) + return; + login->view()->SetPassword(password); + login->view()->Login(); } void WizardController::OnConnectionFailed() { diff --git a/chrome/browser/chromeos/login/wizard_controller.h b/chrome/browser/chromeos/login/wizard_controller.h index 82e1f48..802ddf2 100644 --- a/chrome/browser/chromeos/login/wizard_controller.h +++ b/chrome/browser/chromeos/login/wizard_controller.h @@ -24,6 +24,7 @@ namespace chromeos { class AccountScreen; class BackgroundView; class EulaScreen; +class ExistingUserController; class LoginScreen; class NetworkScreen; class RegistrationScreen; @@ -90,12 +91,15 @@ class WizardController : public chromeos::ScreenObserver, // Show specific screen. void ShowNetworkScreen(); - void ShowLoginScreen(); void ShowAccountScreen(); void ShowUpdateScreen(); void ShowUserImageScreen(); void ShowEulaScreen(); void ShowRegistrationScreen(); + // Shows the default login screen and returns NULL or shows images login + // screen and returns the corresponding controller instance for optional + // tweaking. + chromeos::ExistingUserController* ShowLoginScreen(); // Returns a pointer to the current screen or NULL if there's no such // screen. @@ -175,6 +179,9 @@ class WizardController : public chromeos::ScreenObserver, // Marks device registered. i.e. second part of OOBE is completed. void MarkDeviceRegistered(); + // Logs in the specified user via default login screen. + void Login(const std::string& username, const std::string& password); + // Widget we're showing in. views::Widget* widget_; |