diff options
author | dpolukhin@chromium.org <dpolukhin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-08 10:31:46 +0000 |
---|---|---|
committer | dpolukhin@chromium.org <dpolukhin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-08 10:31:46 +0000 |
commit | 8673bc8e18b0540feaf9ad923279286f1ddcbcbc (patch) | |
tree | a9998255a5ac44e4c0f442e0120153d51b7bd462 | |
parent | 833fac19b949a7444ea63a564c09482ab71a01e7 (diff) | |
download | chromium_src-8673bc8e18b0540feaf9ad923279286f1ddcbcbc.zip chromium_src-8673bc8e18b0540feaf9ad923279286f1ddcbcbc.tar.gz chromium_src-8673bc8e18b0540feaf9ad923279286f1ddcbcbc.tar.bz2 |
Show progress bar as soon as update state changed to UPDATE_STATUS_UPDATE_AVAILABLE
BUG=chromium-os:15263
TEST=manual
Review URL: http://codereview.chromium.org/7057055
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@88317 0039d316-1c4b-4281-b951-d872f2087c98
9 files changed, 78 insertions, 10 deletions
diff --git a/chrome/browser/chromeos/login/mock_update_screen.h b/chrome/browser/chromeos/login/mock_update_screen.h index 975e336..3a65a8e 100644 --- a/chrome/browser/chromeos/login/mock_update_screen.h +++ b/chrome/browser/chromeos/login/mock_update_screen.h @@ -32,6 +32,7 @@ class MockUpdateScreenActor : public UpdateScreenActor { MOCK_METHOD0(ShowManualRebootInfo, void()); MOCK_METHOD1(SetProgress, void(int progress)); MOCK_METHOD1(ShowCurtain, void(bool enable)); + MOCK_METHOD1(ShowPreparingUpdatesInfo, void(bool enable)); }; } // namespace chromeos diff --git a/chrome/browser/chromeos/login/update_screen.cc b/chrome/browser/chromeos/login/update_screen.cc index 7d04b02..f1dc23c 100644 --- a/chrome/browser/chromeos/login/update_screen.cc +++ b/chrome/browser/chromeos/login/update_screen.cc @@ -40,10 +40,13 @@ const char kUpdateDeadlineFile[] = "/tmp/update-check-response-deadline"; void StartUpdateCallback(void* user_data, UpdateResult result, const char* msg) { - if (result != chromeos::UPDATE_RESULT_SUCCESS) { - DCHECK(user_data); - UpdateScreen* screen = static_cast<UpdateScreen*>(user_data); - if (UpdateScreen::HasInstance(screen)) + VLOG(1) << "Callback from RequestUpdateCheck, result " << result; + DCHECK(user_data); + UpdateScreen* screen = static_cast<UpdateScreen*>(user_data); + if (UpdateScreen::HasInstance(screen)) { + if (result == chromeos::UPDATE_RESULT_SUCCESS) + screen->SetIgnoreIdleStatus(false); + else screen->ExitUpdate(UpdateScreen::REASON_UPDATE_INIT_FAILED); } } @@ -64,7 +67,6 @@ bool UpdateScreen::HasInstance(UpdateScreen* inst) { return (found != instance_set.end()); } - UpdateScreen::UpdateScreen(ScreenObserver* screen_observer, UpdateScreenActor* actor) : WizardScreen(screen_observer), @@ -73,6 +75,7 @@ UpdateScreen::UpdateScreen(ScreenObserver* screen_observer, is_downloading_update_(false), is_ignore_update_deadlines_(false), is_shown_(false), + ignore_idle_status_(true), actor_(actor) { GetInstanceSet().insert(this); } @@ -87,6 +90,9 @@ void UpdateScreen::UpdateStatusChanged(UpdateLibrary* library) { if (is_checking_for_update_ && status > UPDATE_STATUS_CHECKING_FOR_UPDATE) { is_checking_for_update_ = false; } + if (ignore_idle_status_ && status > UPDATE_STATUS_IDLE) { + ignore_idle_status_ = false; + } switch (status) { case UPDATE_STATUS_CHECKING_FOR_UPDATE: @@ -103,6 +109,8 @@ void UpdateScreen::UpdateStatusChanged(UpdateLibrary* library) { } else { LOG(INFO) << "Critical update available: " << library->status().new_version; + actor_->ShowPreparingUpdatesInfo(true); + actor_->ShowCurtain(false); } break; case UPDATE_STATUS_DOWNLOADING: @@ -119,9 +127,10 @@ void UpdateScreen::UpdateStatusChanged(UpdateLibrary* library) { } else { LOG(INFO) << "Critical update available: " << library->status().new_version; + actor_->ShowPreparingUpdatesInfo(false); + actor_->ShowCurtain(false); } } - actor_->ShowCurtain(false); int download_progress = static_cast<int>( library->status().download_progress * kDownloadProgressIncrement); actor_->SetProgress(kBeforeDownloadProgress + download_progress); @@ -152,6 +161,12 @@ void UpdateScreen::UpdateStatusChanged(UpdateLibrary* library) { } break; case UPDATE_STATUS_IDLE: + if (ignore_idle_status_) { + // It is first IDLE status that is sent before we initiated the check. + break; + } + // else no break + case UPDATE_STATUS_ERROR: case UPDATE_STATUS_REPORTING_ERROR_EVENT: ExitUpdate(REASON_UPDATE_ENDED); @@ -255,6 +270,10 @@ void UpdateScreen::SetRebootCheckDelay(int seconds) { reboot_check_delay_ = seconds; } +void UpdateScreen::SetIgnoreIdleStatus(bool ignore_idle_status) { + ignore_idle_status_ = ignore_idle_status; +} + bool UpdateScreen::HasCriticalUpdate() { if (is_ignore_update_deadlines_) return true; diff --git a/chrome/browser/chromeos/login/update_screen.h b/chrome/browser/chromeos/login/update_screen.h index f3d36cb..2329b2a 100644 --- a/chrome/browser/chromeos/login/update_screen.h +++ b/chrome/browser/chromeos/login/update_screen.h @@ -47,6 +47,8 @@ class UpdateScreen: public UpdateLibrary::Observer, // Returns true if this instance is still active (i.e. has not been deleted). static bool HasInstance(UpdateScreen* inst); + void SetIgnoreIdleStatus(bool ignore_idle_status); + enum ExitReason { REASON_UPDATE_CANCELED, REASON_UPDATE_INIT_FAILED, @@ -91,10 +93,12 @@ class UpdateScreen: public UpdateLibrary::Observer, // Flag that is used to detect when update download has just started. bool is_downloading_update_; // If true, update deadlines are ignored. - // Note, this is true by default. See "http://crosbug.com/10068". + // Note, this is false by default. bool is_ignore_update_deadlines_; // Whether the update screen is shown. bool is_shown_; + // Ignore fist IDLE status that is sent before update screen initiated check. + bool ignore_idle_status_; // Keeps actor which is delegated with all showing operations. UpdateScreenActor* actor_; diff --git a/chrome/browser/chromeos/login/update_screen_actor.h b/chrome/browser/chromeos/login/update_screen_actor.h index 0d053e9..aa34584 100644 --- a/chrome/browser/chromeos/login/update_screen_actor.h +++ b/chrome/browser/chromeos/login/update_screen_actor.h @@ -31,6 +31,9 @@ class UpdateScreenActor { // Shows screen curtains. virtual void ShowCurtain(bool enable) = 0; + + // Shows label for "Preparing updates" state. + virtual void ShowPreparingUpdatesInfo(bool visible) = 0; }; } // namespace chromeos diff --git a/chrome/browser/chromeos/login/update_screen_browsertest.cc b/chrome/browser/chromeos/login/update_screen_browsertest.cc index 308eb55..f51b9ac 100644 --- a/chrome/browser/chromeos/login/update_screen_browsertest.cc +++ b/chrome/browser/chromeos/login/update_screen_browsertest.cc @@ -101,9 +101,20 @@ IN_PROC_BROWSER_TEST_F(UpdateScreenTest, TestBasic) { } IN_PROC_BROWSER_TEST_F(UpdateScreenTest, TestNoUpdate) { + update_screen_->SetIgnoreIdleStatus(true); UpdateLibrary::Status status; status.status = UPDATE_STATUS_IDLE; EXPECT_CALL(*mock_update_library_, status()) + .Times(1) + .WillRepeatedly(ReturnRef(status)); + update_screen_->UpdateStatusChanged(mock_update_library_); + status.status = UPDATE_STATUS_CHECKING_FOR_UPDATE; + EXPECT_CALL(*mock_update_library_, status()) + .Times(1) + .WillRepeatedly(ReturnRef(status)); + update_screen_->UpdateStatusChanged(mock_update_library_); + status.status = UPDATE_STATUS_IDLE; + EXPECT_CALL(*mock_update_library_, status()) .Times(AtLeast(1)) .WillRepeatedly(ReturnRef(status)); EXPECT_CALL(*mock_screen_observer_, OnExit(ScreenObserver::UPDATE_NOUPDATE)) diff --git a/chrome/browser/chromeos/login/update_view.cc b/chrome/browser/chromeos/login/update_view.cc index ee34cd6..541dee7 100644 --- a/chrome/browser/chromeos/login/update_view.cc +++ b/chrome/browser/chromeos/login/update_view.cc @@ -58,11 +58,13 @@ namespace chromeos { UpdateView::UpdateView(chromeos::ScreenObserver* observer) : installing_updates_label_(NULL), + preparing_updates_label_(NULL), reboot_label_(NULL), manual_reboot_label_(NULL), progress_bar_(NULL), show_curtain_(true), show_manual_reboot_label_(false), + show_preparing_updates_label_(false), observer_(observer) { } @@ -76,8 +78,10 @@ void UpdateView::Init() { set_background(views::Background::CreateBackgroundPainter(true, painter)); InitLabel(&installing_updates_label_); + InitLabel(&preparing_updates_label_); InitLabel(&reboot_label_); InitLabel(&manual_reboot_label_); + preparing_updates_label_->SetVisible(false); manual_reboot_label_->SetVisible(false); manual_reboot_label_->SetColor(kManualRebootLabelColor); @@ -108,6 +112,8 @@ void UpdateView::UpdateLocalizedStrings() { installing_updates_label_->SetText(UTF16ToWide(l10n_util::GetStringFUTF16( IDS_INSTALLING_UPDATE, l10n_util::GetStringUTF16(IDS_PRODUCT_OS_NAME)))); + preparing_updates_label_->SetText( + UTF16ToWide(l10n_util::GetStringUTF16(IDS_UPDATE_AVAILABLE))); reboot_label_->SetText( UTF16ToWide(l10n_util::GetStringUTF16(IDS_INSTALLING_UPDATE_DESC))); manual_reboot_label_->SetText( @@ -129,6 +135,11 @@ void UpdateView::ShowManualRebootInfo() { UpdateVisibility(); } +void UpdateView::ShowPreparingUpdatesInfo(bool visible) { + show_preparing_updates_label_ = visible; + UpdateVisibility(); +} + void UpdateView::ShowCurtain(bool show_curtain) { if (show_curtain_ != show_curtain) { show_curtain_ = show_curtain; @@ -155,6 +166,7 @@ void UpdateView::Layout() { int vertical_center = GetInsets().top() + max_height / 2; installing_updates_label_->SizeToFit(max_width); + preparing_updates_label_->SizeToFit(max_width); reboot_label_->SizeToFit(max_width); manual_reboot_label_->SizeToFit(max_width); @@ -168,6 +180,8 @@ void UpdateView::Layout() { progress_bar_->y() - kInstallingUpdatesLabelYBottomFromProgressBar - installing_updates_label_->height()); + preparing_updates_label_->SetX(installing_updates_label_->x()); + preparing_updates_label_->SetY(installing_updates_label_->y()); reboot_label_->SetX(right_margin); reboot_label_->SetY( progress_bar_->y() + @@ -209,8 +223,12 @@ void UpdateView::InitLabel(views::Label** label) { } void UpdateView::UpdateVisibility() { - installing_updates_label_->SetVisible( - !show_curtain_&& !show_manual_reboot_label_); + installing_updates_label_->SetVisible(!show_curtain_ && + !show_manual_reboot_label_ && + !show_preparing_updates_label_); + preparing_updates_label_->SetVisible(!show_curtain_ && + !show_manual_reboot_label_ && + show_preparing_updates_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_); diff --git a/chrome/browser/chromeos/login/update_view.h b/chrome/browser/chromeos/login/update_view.h index ed40c92..e6551e5 100644 --- a/chrome/browser/chromeos/login/update_view.h +++ b/chrome/browser/chromeos/login/update_view.h @@ -38,6 +38,9 @@ class UpdateView : public views::View { // Usually is not called since we rely on API that will reboot after update. void ShowManualRebootInfo(); + // Shows label for "Preparing updates" state. + void ShowPreparingUpdatesInfo(bool visible); + // Whether curtain window with throbber and label in the center should // be shown. void ShowCurtain(bool show_curtain); @@ -57,6 +60,7 @@ class UpdateView : public views::View { // Dialog controls. views::Label* installing_updates_label_; + views::Label* preparing_updates_label_; views::Label* reboot_label_; views::Label* manual_reboot_label_; views::Label* escape_to_skip_label_; @@ -72,6 +76,9 @@ class UpdateView : public views::View { // Show manual reboot label? bool show_manual_reboot_label_; + // Show preparing updates label? + bool show_preparing_updates_label_; + // Notifications receiver. chromeos::ScreenObserver* observer_; diff --git a/chrome/browser/chromeos/login/views_update_screen_actor.cc b/chrome/browser/chromeos/login/views_update_screen_actor.cc index 5060961..44af298 100644 --- a/chrome/browser/chromeos/login/views_update_screen_actor.cc +++ b/chrome/browser/chromeos/login/views_update_screen_actor.cc @@ -17,7 +17,7 @@ namespace chromeos { ViewsUpdateScreenActor::ViewsUpdateScreenActor(ViewScreenDelegate* delegate) : DefaultViewScreen<chromeos::UpdateView>(delegate, kUpdateScreenWidth, - kUpdateScreenWidth) { + kUpdateScreenHeight) { } void ViewsUpdateScreenActor::PrepareToShow() { @@ -44,4 +44,8 @@ void ViewsUpdateScreenActor::ShowCurtain(bool enable) { view()->ShowCurtain(enable); } +void ViewsUpdateScreenActor::ShowPreparingUpdatesInfo(bool visible) { + view()->ShowPreparingUpdatesInfo(visible); +} + } // namespace chromeos diff --git a/chrome/browser/chromeos/login/views_update_screen_actor.h b/chrome/browser/chromeos/login/views_update_screen_actor.h index 44794db..e60dda1 100644 --- a/chrome/browser/chromeos/login/views_update_screen_actor.h +++ b/chrome/browser/chromeos/login/views_update_screen_actor.h @@ -24,6 +24,7 @@ class ViewsUpdateScreenActor : public DefaultViewScreen<UpdateView>, virtual void ShowManualRebootInfo(); virtual void SetProgress(int progress); virtual void ShowCurtain(bool enable); + virtual void ShowPreparingUpdatesInfo(bool visible); private: DISALLOW_COPY_AND_ASSIGN(ViewsUpdateScreenActor); |