diff options
author | dpolukhin@chromium.org <dpolukhin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-30 10:30:40 +0000 |
---|---|---|
committer | dpolukhin@chromium.org <dpolukhin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-30 10:30:40 +0000 |
commit | 2afa5a08dc165d0d3203f03607545848ebe40dd0 (patch) | |
tree | 1cf1f205b65a105ddaf749c1c227beac1192146c /chrome/browser | |
parent | 26a61c6d0b7ec22cd3e763ff00dc852315feb605 (diff) | |
download | chromium_src-2afa5a08dc165d0d3203f03607545848ebe40dd0.zip chromium_src-2afa5a08dc165d0d3203f03607545848ebe40dd0.tar.gz chromium_src-2afa5a08dc165d0d3203f03607545848ebe40dd0.tar.bz2 |
Landing 3259001: Adds curtain screen with "Checking for updates..."
Original CL: http://codereview.chromium.org/3259001
Adds curtain screen with "Checking for updates..." label and throbber to update screen. Curtain screen is shown at most 15 secs.
BUG=hromium-os:2444
TEST=Go through updating process and notice that first 15 seconds only spinner with "Checking for updates..." label is shown. After 15 seconds usual update progress screen is shown.
Review URL: http://codereview.chromium.org/3275004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@57848 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/chromeos/login/update_screen.cc | 41 | ||||
-rw-r--r-- | chrome/browser/chromeos/login/update_screen.h | 26 | ||||
-rw-r--r-- | chrome/browser/chromeos/login/update_screen_browsertest.cc | 5 | ||||
-rw-r--r-- | chrome/browser/chromeos/login/update_view.cc | 67 | ||||
-rw-r--r-- | chrome/browser/chromeos/login/update_view.h | 18 | ||||
-rw-r--r-- | chrome/browser/chromeos/login/wizard_controller.cc | 10 |
6 files changed, 116 insertions, 51 deletions
diff --git a/chrome/browser/chromeos/login/update_screen.cc b/chrome/browser/chromeos/login/update_screen.cc index 4260241..20b04b05 100644 --- a/chrome/browser/chromeos/login/update_screen.cc +++ b/chrome/browser/chromeos/login/update_screen.cc @@ -30,9 +30,8 @@ namespace chromeos { UpdateScreen::UpdateScreen(WizardScreenDelegate* delegate) : DefaultViewScreen<chromeos::UpdateView>(delegate), - proceed_with_oobe_(false), checking_for_update_(true), - minimal_update_time_(0), + maximal_curtain_time_(0), reboot_check_delay_(0) { } @@ -60,6 +59,7 @@ void UpdateScreen::UpdateStatusChanged(UpdateLibrary* library) { break; case UPDATE_STATUS_DOWNLOADING: { + view()->ShowCurtain(false); int download_progress = static_cast<int>( library->status().download_progress * kDownloadProgressIncrement); view()->SetProgress(kBeforeDownloadProgress + download_progress); @@ -73,6 +73,7 @@ void UpdateScreen::UpdateStatusChanged(UpdateLibrary* library) { break; case UPDATE_STATUS_UPDATED_NEED_REBOOT: view()->SetProgress(kProgressComplete); + view()->ShowCurtain(false); CrosLibrary::Get()->GetUpdateLibrary()->RebootAfterUpdate(); LOG(INFO) << "Reboot API was called. Waiting for reboot."; reboot_timer_.Start(base::TimeDelta::FromSeconds(reboot_check_delay_), @@ -82,10 +83,7 @@ void UpdateScreen::UpdateStatusChanged(UpdateLibrary* library) { case UPDATE_STATUS_IDLE: case UPDATE_STATUS_ERROR: case UPDATE_STATUS_REPORTING_ERROR_EVENT: - if (MinimalUpdateTimeElapsed()) { - ExitUpdate(); - } - proceed_with_oobe_ = true; + ExitUpdate(); break; default: NOTREACHED(); @@ -98,12 +96,14 @@ void UpdateScreen::StartUpdate() { view()->Reset(); view()->set_controller(this); - // Start the minimal update time timer. - if (minimal_update_time_ > 0) { - minimal_update_time_timer_.Start( - base::TimeDelta::FromSeconds(minimal_update_time_), + // Start the maximal curtain time timer. + if (maximal_curtain_time_ > 0) { + maximal_curtain_time_timer_.Start( + base::TimeDelta::FromSeconds(maximal_curtain_time_), this, - &UpdateScreen::OnMinimalUpdateTimeElapsed); + &UpdateScreen::OnMaximalCurtainTimeElapsed); + } else { + view()->ShowCurtain(false); } view()->SetProgress(kBeforeUpdateCheckProgress); @@ -126,7 +126,7 @@ void UpdateScreen::CancelUpdate() { } void UpdateScreen::ExitUpdate() { - minimal_update_time_timer_.Stop(); + maximal_curtain_time_timer_.Stop(); ScreenObserver* observer = delegate()->GetObserver(this); if (!CrosLibrary::Get()->EnsureLoaded()) { @@ -150,13 +150,8 @@ void UpdateScreen::ExitUpdate() { } } -bool UpdateScreen::MinimalUpdateTimeElapsed() { - return !minimal_update_time_timer_.IsRunning(); -} - -void UpdateScreen::OnMinimalUpdateTimeElapsed() { - if (proceed_with_oobe_) - ExitUpdate(); +void UpdateScreen::OnMaximalCurtainTimeElapsed() { + view()->ShowCurtain(false); } void UpdateScreen::OnWaitForRebootTimeElapsed() { @@ -164,11 +159,11 @@ void UpdateScreen::OnWaitForRebootTimeElapsed() { view()->ShowManualRebootInfo(); } -void UpdateScreen::SetMinimalUpdateTime(int seconds) { +void UpdateScreen::SetMaximalCurtainTime(int seconds) { if (seconds <= 0) - minimal_update_time_timer_.Stop(); - DCHECK(!minimal_update_time_timer_.IsRunning()); - minimal_update_time_ = seconds; + maximal_curtain_time_timer_.Stop(); + DCHECK(!maximal_curtain_time_timer_.IsRunning()); + maximal_curtain_time_ = seconds; } void UpdateScreen::SetRebootCheckDelay(int seconds) { diff --git a/chrome/browser/chromeos/login/update_screen.h b/chrome/browser/chromeos/login/update_screen.h index ce5dd8a..2253c2e 100644 --- a/chrome/browser/chromeos/login/update_screen.h +++ b/chrome/browser/chromeos/login/update_screen.h @@ -38,12 +38,9 @@ class UpdateScreen: public DefaultViewScreen<chromeos::UpdateView>, // Reports update results to the ScreenObserver. virtual void ExitUpdate(); - // Returns true if minimal update time has elapsed. - virtual bool MinimalUpdateTimeElapsed(); - - // Minimal update time get/set, in seconds. - int minimal_update_time() const { return minimal_update_time_; } - void SetMinimalUpdateTime(int seconds); + // Maximal curtain time get/set, in seconds. + int maximal_curtain_time() const { return maximal_curtain_time_; } + void SetMaximalCurtainTime(int seconds); // Reboot check delay get/set, in seconds. int reboot_check_delay() const { return reboot_check_delay_; } @@ -51,28 +48,25 @@ class UpdateScreen: public DefaultViewScreen<chromeos::UpdateView>, private: // Timer notification handlers. - void OnMinimalUpdateTimeElapsed(); + void OnMaximalCurtainTimeElapsed(); void OnWaitForRebootTimeElapsed(); - // Timer for the minimal interval when update screen is shown. - base::OneShotTimer<UpdateScreen> minimal_update_time_timer_; + // Timer for the interval while curtain view is shown. + base::OneShotTimer<UpdateScreen> maximal_curtain_time_timer_; // Timer for the interval to wait for the reboot. // If reboot didn't happen - ask user to reboot manually. base::OneShotTimer<UpdateScreen> reboot_timer_; - // True if should proceed with OOBE once timer is elapsed. - bool proceed_with_oobe_; - // True if in the process of checking for update. bool checking_for_update_; - // Minimal update delay in seconds, for a user to notice - // check for update is taking place. - int minimal_update_time_; + // Maximal time (secs) the curtain view is shown. Updating progress is shown + // to the user when this time elapsed. + int maximal_curtain_time_; // Time in seconds after which we decide that the device has not rebooted - // automatically. If reboot didn't happen durin this interval, ask user to + // automatically. If reboot didn't happen during this interval, ask user to // reboot device manually. int reboot_check_delay_; diff --git a/chrome/browser/chromeos/login/update_screen_browsertest.cc b/chrome/browser/chromeos/login/update_screen_browsertest.cc index dd33ee8..c3052ae 100644 --- a/chrome/browser/chromeos/login/update_screen_browsertest.cc +++ b/chrome/browser/chromeos/login/update_screen_browsertest.cc @@ -80,7 +80,6 @@ IN_PROC_BROWSER_TEST_F(UpdateScreenTest, TestNoUpdate) { UpdateScreen* update_screen = controller()->GetUpdateScreen(); ASSERT_TRUE(update_screen != NULL); ASSERT_EQ(controller()->current_screen(), update_screen); - update_screen->SetMinimalUpdateTime(0); UpdateLibrary::Status status; status.status = UPDATE_STATUS_IDLE; @@ -101,7 +100,6 @@ IN_PROC_BROWSER_TEST_F(UpdateScreenTest, TestUpdateAvailable) { UpdateScreen* update_screen = controller()->GetUpdateScreen(); ASSERT_TRUE(update_screen != NULL); ASSERT_EQ(controller()->current_screen(), update_screen); - update_screen->SetMinimalUpdateTime(0); UpdateLibrary::Status status; @@ -161,7 +159,6 @@ IN_PROC_BROWSER_TEST_F(UpdateScreenTest, TestErrorIssuingUpdateCheck) { UpdateScreen* update_screen = controller()->GetUpdateScreen(); ASSERT_TRUE(update_screen != NULL); ASSERT_EQ(controller()->current_screen(), update_screen); - update_screen->SetMinimalUpdateTime(0); UpdateLibrary::Status status; @@ -200,7 +197,6 @@ IN_PROC_BROWSER_TEST_F(UpdateScreenTest, TestErrorCheckingForUpdate) { UpdateScreen* update_screen = controller()->GetUpdateScreen(); ASSERT_TRUE(update_screen != NULL); ASSERT_EQ(controller()->current_screen(), update_screen); - update_screen->SetMinimalUpdateTime(0); UpdateLibrary::Status status; status.status = UPDATE_STATUS_ERROR; @@ -222,7 +218,6 @@ IN_PROC_BROWSER_TEST_F(UpdateScreenTest, TestErrorUpdating) { UpdateScreen* update_screen = controller()->GetUpdateScreen(); ASSERT_TRUE(update_screen != NULL); ASSERT_EQ(controller()->current_screen(), update_screen); - update_screen->SetMinimalUpdateTime(0); UpdateLibrary::Status status; diff --git a/chrome/browser/chromeos/login/update_view.cc b/chrome/browser/chromeos/login/update_view.cc index 9a382f5..b99f4af 100644 --- a/chrome/browser/chromeos/login/update_view.cc +++ b/chrome/browser/chromeos/login/update_view.cc @@ -8,6 +8,7 @@ #include "app/l10n_util.h" #include "app/resource_bundle.h" +#include "chrome/browser/chromeos/login/helper.h" #include "chrome/browser/chromeos/login/rounded_rect_painter.h" #include "chrome/browser/chromeos/login/update_screen.h" #include "grit/chromium_strings.h" @@ -15,6 +16,7 @@ #include "views/border.h" #include "views/controls/label.h" #include "views/controls/progress_bar.h" +#include "views/controls/throbber.h" #include "views/focus/focus_manager.h" #include "views/widget/widget.h" @@ -41,6 +43,8 @@ const int kProgressBarWidth = 550; const int kProgressBarHeight = 18; // Horizontal spacing (ex. min left and right margins for label on the screen). const int kHorizontalSpacing = 75; +// Horizontal spacing between spinner and label on the curtain screen. +const int kBetweenSpacing = 25; // Label color. const SkColor kLabelColor = 0xFF000000; @@ -57,6 +61,8 @@ UpdateView::UpdateView(chromeos::ScreenObserver* observer) reboot_label_(NULL), manual_reboot_label_(NULL), progress_bar_(NULL), + show_curtain_(true), + show_manual_reboot_label_(false), observer_(observer) { } @@ -78,7 +84,10 @@ void UpdateView::Init() { progress_bar_ = new views::ProgressBar(); AddChildView(progress_bar_); - UpdateLocalizedStrings(); + // Curtain view. + InitLabel(&checking_label_); + throbber_ = CreateDefaultThrobber(); + AddChildView(throbber_); #if !defined(OFFICIAL_BUILD) InitLabel(&escape_to_skip_label_); @@ -86,6 +95,9 @@ void UpdateView::Init() { escape_to_skip_label_->SetText( L"Press ESCAPE to skip (Non-official builds only)"); #endif + + UpdateLocalizedStrings(); + UpdateVisibility(); } void UpdateView::Reset() { @@ -102,6 +114,7 @@ void UpdateView::UpdateLocalizedStrings() { l10n_util::GetString(IDS_PRODUCT_OS_NAME))); reboot_label_->SetText(l10n_util::GetString(IDS_INSTALLING_UPDATE_DESC)); manual_reboot_label_->SetText(l10n_util::GetString(IDS_UPDATE_COMPLETED)); + checking_label_->SetText(l10n_util::GetString(IDS_CHECKING_FOR_UPDATES)); } void UpdateView::AddProgress(int ticks) { @@ -113,9 +126,27 @@ void UpdateView::SetProgress(int progress) { } void UpdateView::ShowManualRebootInfo() { - installing_updates_label_->SetVisible(false); - reboot_label_->SetVisible(false); - manual_reboot_label_->SetVisible(true); + show_manual_reboot_label_ = true; + UpdateVisibility(); +} + +void UpdateView::ShowCurtain(bool show_curtain) { + if (show_curtain_ != show_curtain) { + show_curtain_ = show_curtain; + UpdateVisibility(); + } +} + +// Sets the bounds of the view, placing center of the view at the given +// coordinates (|x| and |y|). +static void setViewBounds(views::View* view, int x, int y) { + int preferred_width = view->GetPreferredSize().width(); + int preferred_height = view->GetPreferredSize().height(); + view->SetBounds( + x - preferred_width / 2, + y - preferred_height / 2, + preferred_width, + preferred_height); } void UpdateView::Layout() { @@ -145,6 +176,18 @@ void UpdateView::Layout() { kRebootLabelYFromProgressBar); manual_reboot_label_->SetX(reboot_label_->x()); manual_reboot_label_->SetY(reboot_label_->y()); + // Curtain layout is independed. + int x_center = width() / 2; + int throbber_width = throbber_->GetPreferredSize().width(); + checking_label_->SizeToFit(max_width - throbber_width - kBetweenSpacing); + int checking_label_width = checking_label_->GetPreferredSize().width(); + int space_half = (kBetweenSpacing + 1) / 2; + setViewBounds( + throbber_, x_center - checking_label_width / 2 - space_half, + vertical_center); + setViewBounds( + checking_label_, x_center + (throbber_width + 1) / 2 + space_half, + vertical_center); #if !defined(OFFICIAL_BUILD) escape_to_skip_label_->SizeToFit(max_width); escape_to_skip_label_->SetX(right_margin); @@ -179,4 +222,20 @@ void UpdateView::InitLabel(views::Label** label) { AddChildView(*label); } +void UpdateView::UpdateVisibility() { + installing_updates_label_->SetVisible( + !show_curtain_&& !show_manual_reboot_label_); + reboot_label_->SetVisible(!show_curtain_&& !show_manual_reboot_label_); + manual_reboot_label_->SetVisible(!show_curtain_ && show_manual_reboot_label_); + progress_bar_->SetVisible(!show_curtain_); + + checking_label_->SetVisible(show_curtain_); + throbber_->SetVisible(show_curtain_); + if (show_curtain_) { + throbber_->Start(); + } else { + throbber_->Stop(); + } +} + } // namespace chromeos diff --git a/chrome/browser/chromeos/login/update_view.h b/chrome/browser/chromeos/login/update_view.h index 9c929f2..c8c0b60 100644 --- a/chrome/browser/chromeos/login/update_view.h +++ b/chrome/browser/chromeos/login/update_view.h @@ -11,6 +11,7 @@ namespace views { class Label; class ProgressBar; +class Throbber; } // namespace views namespace chromeos { @@ -43,6 +44,10 @@ class UpdateView : public views::View { // Usually is not called since we rely on API that will reboot after update. void ShowManualRebootInfo(); + // Whether curtain window with throbber and label in the center should + // be shown. + void ShowCurtain(bool show_curtain); + // views::View implementation: virtual void Layout(); virtual bool AcceleratorPressed(const views::Accelerator& a); @@ -51,6 +56,9 @@ class UpdateView : public views::View { // Creates Label control and adds it as a child. void InitLabel(views::Label** label); + // Updates visibility of the elements. + void UpdateVisibility(); + // Keyboard accelerator to allow cancelling update by hitting escape. views::Accelerator escape_accelerator_; @@ -61,6 +69,16 @@ class UpdateView : public views::View { views::Label* escape_to_skip_label_; views::ProgressBar* progress_bar_; + // Curtain views. + views::Label* checking_label_; + views::Throbber* throbber_; + + // Show curtain view? + bool show_curtain_; + + // Show manual reboot label? + bool show_manual_reboot_label_; + // Notifications receiver. chromeos::ScreenObserver* observer_; // Update controller. diff --git a/chrome/browser/chromeos/login/wizard_controller.cc b/chrome/browser/chromeos/login/wizard_controller.cc index eca8dae..a5b964e 100644 --- a/chrome/browser/chromeos/login/wizard_controller.cc +++ b/chrome/browser/chromeos/login/wizard_controller.cc @@ -70,8 +70,8 @@ const char kOobeCompleteFlagFilePath[] = const int kWizardScreenWidth = 700; const int kWizardScreenHeight = 416; -// Update window should appear for at least kMinimalUpdateTimeSec seconds. -const int kMinimalUpdateTimeSec = 3; +// Upadate window will be behind the curtain at most |kMaximalCurtainTimeSec|. +const int kMaximalCurtainTimeSec = 15; // Time in seconds that we wait for the device to reboot. // If reboot didn't happen, ask user to reboot device manually. @@ -361,7 +361,7 @@ chromeos::AccountScreen* WizardController::GetAccountScreen() { chromeos::UpdateScreen* WizardController::GetUpdateScreen() { if (!update_screen_.get()) { update_screen_.reset(new chromeos::UpdateScreen(this)); - update_screen_->SetMinimalUpdateTime(kMinimalUpdateTimeSec); + update_screen_->SetMaximalCurtainTime(kMaximalCurtainTimeSec); update_screen_->SetRebootCheckDelay(kWaitForRebootTimeSec); } return update_screen_.get(); @@ -452,7 +452,11 @@ void WizardController::ShowUpdateScreen() { SetStatusAreaVisible(true); SetCurrentScreen(GetUpdateScreen()); // There is no special step for update. +#if defined(OFFICIAL_BUILD) + background_view_->SetOobeProgress(chromeos::BackgroundView::EULA); +#else background_view_->SetOobeProgress(chromeos::BackgroundView::SELECT_NETWORK); +#endif } void WizardController::ShowUserImageScreen() { |