diff options
author | dpolukhin@chromium.org <dpolukhin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-01 10:01:32 +0000 |
---|---|---|
committer | dpolukhin@chromium.org <dpolukhin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-01 10:01:32 +0000 |
commit | 8c59a5d3bb7d8b49e6487558dc0d4cfeac7d8a98 (patch) | |
tree | 724628cce549ff138b71c963988f37c729ef99a2 | |
parent | 9e1dc92bdaf7d3201bec0e73a5badfd08a8aa616 (diff) | |
download | chromium_src-8c59a5d3bb7d8b49e6487558dc0d4cfeac7d8a98.zip chromium_src-8c59a5d3bb7d8b49e6487558dc0d4cfeac7d8a98.tar.gz chromium_src-8c59a5d3bb7d8b49e6487558dc0d4cfeac7d8a98.tar.bz2 |
Replace login screen with images login.
BUG=crosbug.com/3280
TEST=See login with on Chrome OS.
Review URL: http://codereview.chromium.org/2848033
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@51355 0039d316-1c4b-4281-b951-d872f2087c98
3 files changed, 54 insertions, 11 deletions
diff --git a/chrome/browser/chromeos/login/existing_user_controller.cc b/chrome/browser/chromeos/login/existing_user_controller.cc index ea9057c..d12b22a 100644 --- a/chrome/browser/chromeos/login/existing_user_controller.cc +++ b/chrome/browser/chromeos/login/existing_user_controller.cc @@ -74,6 +74,9 @@ void EnableTooltipsIfNeeded(const std::vector<UserController*>& controllers) { } // namespace +ExistingUserController* + ExistingUserController::delete_scheduled_instance_ = NULL; + ExistingUserController::ExistingUserController( const std::vector<UserManager::User>& users, const gfx::Rect& background_bounds) @@ -82,6 +85,9 @@ ExistingUserController::ExistingUserController( background_view_(NULL), selected_view_index_(kNotSelected), bubble_(NULL) { + if (delete_scheduled_instance_) + delete_scheduled_instance_->Delete(); + // Caclulate the max number of users from available screen size. size_t max_users = kMaxUsers; int screen_width = background_bounds.width(); @@ -101,10 +107,12 @@ ExistingUserController::ExistingUserController( } void ExistingUserController::Init() { - background_window_ = BackgroundView::CreateWindowContainingView( - background_bounds_, - &background_view_); - background_window_->Show(); + if (!background_window_) { + background_window_ = BackgroundView::CreateWindowContainingView( + background_bounds_, + &background_view_); + background_window_->Show(); + } for (size_t i = 0; i < controllers_.size(); ++i) { (controllers_[i])->Init(static_cast<int>(i), static_cast<int>(controllers_.size())); @@ -118,6 +126,14 @@ void ExistingUserController::Init() { CrosLibrary::Get()->GetLoginLibrary()->EmitLoginPromptReady(); } +void ExistingUserController::OwnBackground( + views::Widget* background_widget, + chromeos::BackgroundView* background_view) { + DCHECK(!background_window_); + background_window_ = background_widget; + background_view_ = background_view; +} + ExistingUserController::~ExistingUserController() { ClearErrors(); @@ -130,6 +146,7 @@ ExistingUserController::~ExistingUserController() { } void ExistingUserController::Delete() { + delete_scheduled_instance_ = NULL; delete this; } @@ -212,6 +229,8 @@ void ExistingUserController::ActivateWizard(const std::string& screen_name) { // And schedule us for deletion. We delay for a second as the window manager // is doing an animation with our windows. + DCHECK(!delete_scheduled_instance_); + delete_scheduled_instance_ = this; delete_timer_.Start(base::TimeDelta::FromSeconds(1), this, &ExistingUserController::Delete); } diff --git a/chrome/browser/chromeos/login/existing_user_controller.h b/chrome/browser/chromeos/login/existing_user_controller.h index c5482ef..82a6589 100644 --- a/chrome/browser/chromeos/login/existing_user_controller.h +++ b/chrome/browser/chromeos/login/existing_user_controller.h @@ -53,6 +53,10 @@ class ExistingUserController : public WmMessageListener::Observer, // Creates and shows the appropriate set of windows. void Init(); + // Takes ownership of the specified background widget and view. + void OwnBackground(views::Widget* background_widget, + chromeos::BackgroundView* background_view); + private: friend class DeleteTask<ExistingUserController>; @@ -125,6 +129,10 @@ class ExistingUserController : public WmMessageListener::Observer, // See comment in ProcessWmMessage. base::OneShotTimer<ExistingUserController> delete_timer_; + // Pointer to the instance that was scheduled to be deleted soon or NULL + // if there is no such instance. + static ExistingUserController* delete_scheduled_instance_; + // Pointer to shown message bubble. We don't need to delete it because // it will be deleted on bubble closing. MessageBubble* bubble_; diff --git a/chrome/browser/chromeos/login/wizard_controller.cc b/chrome/browser/chromeos/login/wizard_controller.cc index 95c9782..d0c3a40 100644 --- a/chrome/browser/chromeos/login/wizard_controller.cc +++ b/chrome/browser/chromeos/login/wizard_controller.cc @@ -314,6 +314,25 @@ void WizardController::ShowNetworkScreen() { void WizardController::ShowLoginScreen() { SetStatusAreaVisible(true); + + if (chromeos::CrosLibrary::Get()->EnsureLoaded() && + CommandLine::ForCurrentProcess()->HasSwitch( + switches::kEnableLoginImages)) { + std::vector<chromeos::UserManager::User> users = + chromeos::UserManager::Get()->GetUsers(); + // ExistingUserController deletes itself. + gfx::Rect screen_bounds; + background_widget_->GetBounds(&screen_bounds, true); + chromeos::ExistingUserController* controller = + new chromeos::ExistingUserController(users, screen_bounds); + controller->OwnBackground(background_widget_, background_view_); + controller->Init(); + background_widget_ = NULL; + background_view_ = NULL; + MessageLoop::current()->DeleteSoon(FROM_HERE, this); + return; + } + SetCurrentScreen(GetLoginScreen()); } @@ -589,19 +608,16 @@ void ShowLoginWizard(const std::string& first_screen_name, bool oobe_complete = g_browser_process->local_state()-> GetBoolean(kOobeComplete); - // TODO(nkostylev): Always switch to ExistingUserController after OOBE - // is completed. Enable it after fix for WM is ready. if (first_screen_name.empty() && + oobe_complete && chromeos::CrosLibrary::Get()->EnsureLoaded() && CommandLine::ForCurrentProcess()->HasSwitch( switches::kEnableLoginImages)) { std::vector<chromeos::UserManager::User> users = chromeos::UserManager::Get()->GetUsers(); - if (!users.empty()) { - // ExistingUserController deletes itself. - (new chromeos::ExistingUserController(users, screen_bounds))->Init(); - return; - } + // ExistingUserController deletes itself. + (new chromeos::ExistingUserController(users, screen_bounds))->Init(); + return; } scoped_ptr<chromeos::StartupCustomizationDocument> customization; |