diff options
author | denisromanov@google.com <denisromanov@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-12 23:19:44 +0000 |
---|---|---|
committer | denisromanov@google.com <denisromanov@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-12 23:19:44 +0000 |
commit | d5d7347a42965314526caaa43b0c076b83c224b7 (patch) | |
tree | 18246cc8d4355042ab3f0423d7f6e1fcd670cb43 | |
parent | 6dfbbf8d24de61a5d607a7c0d002dc51584c7bda (diff) | |
download | chromium_src-d5d7347a42965314526caaa43b0c076b83c224b7.zip chromium_src-d5d7347a42965314526caaa43b0c076b83c224b7.tar.gz chromium_src-d5d7347a42965314526caaa43b0c076b83c224b7.tar.bz2 |
Added progress bar to the update screen.
Corrected login wizard screens transitions logic.
BUG=35249
TEST=Run out/Debug/chrome --login-manager --login-screen=update. Progress bar should be visible and login screen should appear after it comes to 100%.
Review URL: http://codereview.chromium.org/853006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@41505 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/chromeos/login/rounded_rect_painter.cc | 1 | ||||
-rw-r--r-- | chrome/browser/chromeos/login/screen_observer.h | 2 | ||||
-rw-r--r-- | chrome/browser/chromeos/login/update_view.cc | 57 | ||||
-rw-r--r-- | chrome/browser/chromeos/login/update_view.h | 9 | ||||
-rw-r--r-- | chrome/browser/chromeos/login/wizard_controller.cc | 10 | ||||
-rw-r--r-- | chrome/browser/chromeos/login/wizard_controller.h | 1 |
6 files changed, 66 insertions, 14 deletions
diff --git a/chrome/browser/chromeos/login/rounded_rect_painter.cc b/chrome/browser/chromeos/login/rounded_rect_painter.cc index 20d48ef..fb89324 100644 --- a/chrome/browser/chromeos/login/rounded_rect_painter.cc +++ b/chrome/browser/chromeos/login/rounded_rect_painter.cc @@ -230,4 +230,3 @@ views::Border* CreateWizardBorder(const BorderDefinition* const border) { } } // namespace chromeos - diff --git a/chrome/browser/chromeos/login/screen_observer.h b/chrome/browser/chromeos/login/screen_observer.h index f9c3d72..0251ce9 100644 --- a/chrome/browser/chromeos/login/screen_observer.h +++ b/chrome/browser/chromeos/login/screen_observer.h @@ -26,6 +26,8 @@ class ScreenObserver { NETWORK_OFFLINE, ACCOUNT_CREATED, LANGUAGE_CHANGED, + UPDATE_INSTALLED, + UPDATE_NOUPDATE, }; // Method called by a screen when user's done with it. diff --git a/chrome/browser/chromeos/login/update_view.cc b/chrome/browser/chromeos/login/update_view.cc index 259fe63..8bb06d7 100644 --- a/chrome/browser/chromeos/login/update_view.cc +++ b/chrome/browser/chromeos/login/update_view.cc @@ -9,10 +9,12 @@ #include "app/l10n_util.h" #include "app/resource_bundle.h" #include "chrome/browser/chromeos/login/rounded_rect_painter.h" +#include "chrome/browser/chromeos/login/screen_observer.h" #include "grit/chromium_strings.h" #include "grit/generated_resources.h" #include "views/border.h" #include "views/controls/label.h" +#include "views/controls/progress_bar.h" #include "views/widget/widget.h" #include "views/window/window.h" #include "views/window/window_gtk.h" @@ -23,18 +25,25 @@ using views::View; using views::Widget; namespace { - // Y offset for the 'installing updates' label. const int kInstallingUpdatesLabelY = 200; +// Y offset for the progress bar. +const int kProgressBarY = 250; +// Progress bar width. +const int kProgressBarWidth = 450; // Labels colour. const SkColor kLabelColor = 0xFF000000; +// Timer constants. +const int kProgressTimerInterval = 200; +const int kProgressIncrement = 0.09; } // namespace namespace chromeos { UpdateView::UpdateView(chromeos::ScreenObserver* observer) : installing_updates_label_(NULL), + progress_bar_(NULL), observer_(observer) { } @@ -47,15 +56,22 @@ void UpdateView::Init() { &chromeos::BorderDefinition::kScreenBorder); set_background(views::Background::CreateBackgroundPainter(true, painter)); - // Set UI elements' apperance. ResourceBundle& res_bundle = ResourceBundle::GetSharedInstance(); gfx::Font base_font = res_bundle.GetFont(ResourceBundle::BaseFont); + installing_updates_label_ = new views::Label(); installing_updates_label_->SetColor(kLabelColor); installing_updates_label_->SetFont(base_font); + progress_bar_ = new views::ProgressBar(); + UpdateLocalizedStrings(); AddChildView(installing_updates_label_); + AddChildView(progress_bar_); + + timer_.Start(base::TimeDelta::FromMilliseconds(kProgressTimerInterval), + this, + &UpdateView::OnTimerElapsed); } void UpdateView::UpdateLocalizedStrings() { @@ -64,19 +80,36 @@ void UpdateView::UpdateLocalizedStrings() { l10n_util::GetString(IDS_PRODUCT_OS_NAME))); } -//////////////////////////////////////////////////////////////////////////////// -// views::View: implementation: - void UpdateView::Layout() { - int x = (width() - - installing_updates_label_->GetPreferredSize().width()) / 2; - int y = kInstallingUpdatesLabelY; + int x_center = width() / 2; + int preferred_width = installing_updates_label_->GetPreferredSize().width(); + int preferred_height = installing_updates_label_->GetPreferredSize().height(); installing_updates_label_->SetBounds( - x, - y, - installing_updates_label_->GetPreferredSize().width(), - installing_updates_label_->GetPreferredSize().height()); + x_center - preferred_width / 2, + kInstallingUpdatesLabelY, + preferred_width, + preferred_height); + preferred_width = kProgressBarWidth; + preferred_height = progress_bar_->GetPreferredSize().height(); + progress_bar_->SetBounds( + x_center - preferred_width / 2, + kProgressBarY, + preferred_width, + preferred_height); SchedulePaint(); } +void UpdateView::OnTimerElapsed() { + double progress = progress_bar_->GetProgress(); + if (progress == 1.) { + timer_.Stop(); + if (observer_) { + observer_->OnExit(ScreenObserver::UPDATE_NOUPDATE); + } + } else { + progress += kProgressIncrement; + progress_bar_->SetProgress(progress); + } +} + } // namespace chromeos diff --git a/chrome/browser/chromeos/login/update_view.h b/chrome/browser/chromeos/login/update_view.h index 323cb77..cac2084 100644 --- a/chrome/browser/chromeos/login/update_view.h +++ b/chrome/browser/chromeos/login/update_view.h @@ -5,10 +5,12 @@ #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_UPDATE_VIEW_H_ #define CHROME_BROWSER_CHROMEOS_LOGIN_UPDATE_VIEW_H_ +#include "base/timer.h" #include "views/view.h" namespace views { class Label; +class ProgressBar; } // namespace views namespace chromeos { @@ -29,12 +31,19 @@ class UpdateView : public views::View { virtual void Layout(); private: + // Timer notification handler. + void OnTimerElapsed(); + // Dialog controls. views::Label* installing_updates_label_; + views::ProgressBar* progress_bar_; // Notifications receiver. chromeos::ScreenObserver* observer_; + // Timer. + base::RepeatingTimer<UpdateView> timer_; + DISALLOW_COPY_AND_ASSIGN(UpdateView); }; diff --git a/chrome/browser/chromeos/login/wizard_controller.cc b/chrome/browser/chromeos/login/wizard_controller.cc index d930072..c898962 100644 --- a/chrome/browser/chromeos/login/wizard_controller.cc +++ b/chrome/browser/chromeos/login/wizard_controller.cc @@ -210,7 +210,7 @@ void WizardController::OnLoginCreateAccount() { } void WizardController::OnNetworkConnected() { - SetCurrentScreen(GetLoginScreen()); + SetCurrentScreen(GetUpdateScreen()); } void WizardController::OnAccountCreated() { @@ -221,6 +221,10 @@ void WizardController::OnLanguageChanged() { SetCurrentScreen(GetNetworkScreen()); } +void WizardController::OnUpdateCompleted() { + SetCurrentScreen(GetLoginScreen()); +} + /////////////////////////////////////////////////////////////////////////////// // WizardController, private: void WizardController::OnSwitchLanguage(std::string lang) { @@ -297,6 +301,10 @@ void WizardController::OnExit(ExitCodes exit_code) { case LANGUAGE_CHANGED: OnLanguageChanged(); break; + case UPDATE_INSTALLED: + case UPDATE_NOUPDATE: + OnUpdateCompleted(); + break; default: NOTREACHED(); } diff --git a/chrome/browser/chromeos/login/wizard_controller.h b/chrome/browser/chromeos/login/wizard_controller.h index 66ccbef..1ec5993 100644 --- a/chrome/browser/chromeos/login/wizard_controller.h +++ b/chrome/browser/chromeos/login/wizard_controller.h @@ -71,6 +71,7 @@ class WizardController : public chromeos::ScreenObserver, void OnNetworkConnected(); void OnAccountCreated(); void OnLanguageChanged(); + void OnUpdateCompleted(); // Overridden from chromeos::ScreenObserver: virtual void OnExit(ExitCodes exit_code); |