summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/app/generated_resources.grd2
-rw-r--r--chrome/browser/chromeos/login/screen_observer.h2
-rw-r--r--chrome/browser/chromeos/login/update_view.cc120
-rw-r--r--chrome/browser/chromeos/login/update_view.h26
-rw-r--r--chrome/browser/chromeos/login/view_screen.h9
-rw-r--r--chrome/browser/chromeos/login/wizard_controller.cc16
-rw-r--r--chrome/browser/chromeos/login/wizard_controller.h1
-rw-r--r--views/controls/progress_bar.cc4
-rw-r--r--views/controls/progress_bar.h2
9 files changed, 154 insertions, 28 deletions
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd
index cdf142f..5640ccc 100644
--- a/chrome/app/generated_resources.grd
+++ b/chrome/app/generated_resources.grd
@@ -6869,7 +6869,7 @@ Keep your key file in a safe place. You will need it to create new versions of y
<!-- Chrome OS Strings -->
<if expr="pp_ifdef('chromeos')">
<message name="IDS_INSTALLING_UPDATE" desc="Label shown on the updates installation screen">
- Please wait while <ph name="PRODUCT_NAME">$1<ex>Chrome OS</ex></ph> installs an important update.
+ Please wait while <ph name="PRODUCT_NAME">$1<ex>Chrome OS</ex></ph> installs an important update.\nYour computer will restart after this is complete.
</message>
<message name="IDS_NETWORK_SELECTION_TITLE" desc="Welcome title shown on network selection screen">
Welcome to <ph name="PRODUCT_NAME">$1<ex>Chrome OS</ex></ph>
diff --git a/chrome/browser/chromeos/login/screen_observer.h b/chrome/browser/chromeos/login/screen_observer.h
index ec422f7..ad4d99a 100644
--- a/chrome/browser/chromeos/login/screen_observer.h
+++ b/chrome/browser/chromeos/login/screen_observer.h
@@ -28,6 +28,8 @@ class ScreenObserver {
LANGUAGE_CHANGED,
UPDATE_INSTALLED,
UPDATE_NOUPDATE,
+ UPDATE_NETWORK_ERROR,
+ UPDATE_OTHER_ERROR,
};
// 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 fc22728..496ba5c 100644
--- a/chrome/browser/chromeos/login/update_view.cc
+++ b/chrome/browser/chromeos/login/update_view.cc
@@ -16,8 +16,6 @@
#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"
using views::Background;
using views::Label;
@@ -25,18 +23,24 @@ 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.
+
+// Label color.
const SkColor kLabelColor = 0xFF000000;
-// Timer constants.
-const int kProgressTimerInterval = 200;
-const int kProgressIncrement = 9;
+// Update window should appear for at least kMinimalUpdateTime seconds.
+const int kMinimalUpdateTime = 3;
+
+// Progress bar increment step.
+const int kUpdateCheckProgressIncrement = 20;
+const int kUpdateCompleteProgressIncrement = 75;
+
} // namespace
namespace chromeos {
@@ -44,10 +48,16 @@ namespace chromeos {
UpdateView::UpdateView(chromeos::ScreenObserver* observer)
: installing_updates_label_(NULL),
progress_bar_(NULL),
- observer_(observer) {
+ observer_(observer),
+ update_result_(UPGRADE_STARTED),
+ update_error_(GOOGLE_UPDATE_NO_ERROR) {
}
UpdateView::~UpdateView() {
+ // Google Updater is holding a pointer to us until it reports status,
+ // so we need to remove it in case we were stll listening.
+ if (google_updater_.get())
+ google_updater_->set_status_listener(NULL);
}
void UpdateView::Init() {
@@ -62,17 +72,14 @@ void UpdateView::Init() {
installing_updates_label_ = new views::Label();
installing_updates_label_->SetColor(kLabelColor);
installing_updates_label_->SetFont(base_font);
+ installing_updates_label_->SetHorizontalAlignment(views::Label::ALIGN_CENTER);
+ installing_updates_label_->SetMultiLine(true);
progress_bar_ = new views::ProgressBar();
- progress_bar_->SetProgress(0);
UpdateLocalizedStrings();
AddChildView(installing_updates_label_);
AddChildView(progress_bar_);
-
- timer_.Start(base::TimeDelta::FromMilliseconds(kProgressTimerInterval),
- this,
- &UpdateView::OnTimerElapsed);
}
void UpdateView::UpdateLocalizedStrings() {
@@ -100,16 +107,87 @@ void UpdateView::Layout() {
SchedulePaint();
}
-void UpdateView::OnTimerElapsed() {
- int progress = progress_bar_->GetProgress();
- if (progress >= 100) {
- timer_.Stop();
- if (observer_) {
- observer_->OnExit(ScreenObserver::UPDATE_NOUPDATE);
+void UpdateView::StartUpdate() {
+ // Zero progress.
+ progress_bar_->SetProgress(0);
+ // Start the minimal update time timer.
+ DCHECK(!minimal_update_time_timer_.IsRunning());
+ minimal_update_time_timer_.Start(
+ base::TimeDelta::FromSeconds(kMinimalUpdateTime),
+ this,
+ &UpdateView::OnMinimalUpdateTimeElapsed);
+ // Create Google Updater object and check if there is an update available.
+ google_updater_ = new GoogleUpdate();
+ google_updater_->set_status_listener(this);
+ google_updater_->CheckForUpdate(false, NULL);
+}
+
+void UpdateView::ExitUpdate() {
+ progress_bar_->SetProgress(100);
+ if (observer_) {
+ switch (update_result_) {
+ case UPGRADE_ALREADY_UP_TO_DATE:
+ observer_->OnExit(ScreenObserver::UPDATE_NOUPDATE);
+ break;
+ case UPGRADE_SUCCESSFUL:
+ observer_->OnExit(ScreenObserver::UPDATE_INSTALLED);
+ break;
+ case UPGRADE_ERROR:
+ if (update_error_ == GOOGLE_UPDATE_ERROR_UPDATING) {
+ observer_->OnExit(ScreenObserver::UPDATE_NETWORK_ERROR);
+ } else {
+ // TODO(denisromanov): figure out what to do if some other error
+ // has occurred.
+ NOTREACHED();
+ }
+ break;
+ default:
+ NOTREACHED();
}
- } else {
- progress += kProgressIncrement;
- progress_bar_->SetProgress(progress);
+ }
+}
+
+void UpdateView::OnMinimalUpdateTimeElapsed() {
+ if (update_result_ == UPGRADE_SUCCESSFUL ||
+ update_result_ == UPGRADE_ALREADY_UP_TO_DATE ||
+ update_result_ == UPGRADE_ERROR) {
+ ExitUpdate();
+ }
+}
+
+void UpdateView::OnReportResults(GoogleUpdateUpgradeResult result,
+ GoogleUpdateErrorCode error_code,
+ const std::wstring& version) {
+ // Drop the last reference to the object so that it gets cleaned up here.
+ google_updater_ = NULL;
+ // Depending on the result decide what to do next.
+ update_result_ = result;
+ update_error_ = error_code;
+ switch (update_result_) {
+ case UPGRADE_IS_AVAILABLE:
+ // Advance progress bar.
+ progress_bar_->AddProgress(kUpdateCheckProgressIncrement);
+ // Create new Google Updater instance and install the update.
+ google_updater_ = new GoogleUpdate();
+ google_updater_->set_status_listener(this);
+ google_updater_->CheckForUpdate(true, NULL);
+ break;
+ case UPGRADE_SUCCESSFUL:
+ // Advance progress bar.
+ progress_bar_->AddProgress(kUpdateCompleteProgressIncrement);
+ // Fall through.
+ case UPGRADE_ALREADY_UP_TO_DATE:
+ case UPGRADE_ERROR:
+ if (minimal_update_time_timer_.IsRunning()) {
+ // Minimal time required for the update screen to remain visible
+ // has not yet passed.
+ progress_bar_->AddProgress(kUpdateCheckProgressIncrement);
+ } else {
+ ExitUpdate();
+ }
+ break;
+ default:
+ NOTREACHED();
}
}
diff --git a/chrome/browser/chromeos/login/update_view.h b/chrome/browser/chromeos/login/update_view.h
index cac2084..f194af2 100644
--- a/chrome/browser/chromeos/login/update_view.h
+++ b/chrome/browser/chromeos/login/update_view.h
@@ -6,6 +6,7 @@
#define CHROME_BROWSER_CHROMEOS_LOGIN_UPDATE_VIEW_H_
#include "base/timer.h"
+#include "chrome/browser/google_update.h"
#include "views/view.h"
namespace views {
@@ -18,7 +19,8 @@ namespace chromeos {
class ScreenObserver;
// View for the network selection/initial welcome screen.
-class UpdateView : public views::View {
+class UpdateView : public views::View,
+ public GoogleUpdateStatusListener {
public:
explicit UpdateView(chromeos::ScreenObserver* observer);
virtual ~UpdateView();
@@ -30,9 +32,20 @@ class UpdateView : public views::View {
// views::View implementation:
virtual void Layout();
+ // Overridden from GoogleUpdateStatusListener:
+ virtual void OnReportResults(GoogleUpdateUpgradeResult result,
+ GoogleUpdateErrorCode error_code,
+ const std::wstring& version);
+
+ // Method that is called by WizardController to start update.
+ void StartUpdate();
+
private:
+ // Method that reports update results to ScreenObserver.
+ void ExitUpdate();
+
// Timer notification handler.
- void OnTimerElapsed();
+ void OnMinimalUpdateTimeElapsed();
// Dialog controls.
views::Label* installing_updates_label_;
@@ -42,7 +55,14 @@ class UpdateView : public views::View {
chromeos::ScreenObserver* observer_;
// Timer.
- base::RepeatingTimer<UpdateView> timer_;
+ base::OneShotTimer<UpdateView> minimal_update_time_timer_;
+
+ // Update status.
+ GoogleUpdateUpgradeResult update_result_;
+ GoogleUpdateErrorCode update_error_;
+
+ // Google Updater.
+ scoped_refptr<GoogleUpdate> google_updater_;
DISALLOW_COPY_AND_ASSIGN(UpdateView);
};
diff --git a/chrome/browser/chromeos/login/view_screen.h b/chrome/browser/chromeos/login/view_screen.h
index 36a9d4e..2d65b92 100644
--- a/chrome/browser/chromeos/login/view_screen.h
+++ b/chrome/browser/chromeos/login/view_screen.h
@@ -89,6 +89,13 @@ void ViewScreen<V>::InitView() {
typedef DefaultViewScreen<chromeos::LoginManagerView> LoginScreen;
typedef DefaultViewScreen<chromeos::NetworkSelectionView> NetworkScreen;
-typedef DefaultViewScreen<chromeos::UpdateView> UpdateScreen;
+
+class UpdateScreen: public DefaultViewScreen<chromeos::UpdateView> {
+ public:
+ explicit UpdateScreen(WizardScreenDelegate* delegate)
+ : DefaultViewScreen<chromeos::UpdateView>(delegate) {
+ }
+ void StartUpdate() { view()->StartUpdate(); }
+};
#endif // CHROME_BROWSER_CHROMEOS_LOGIN_VIEW_SCREEN_H_
diff --git a/chrome/browser/chromeos/login/wizard_controller.cc b/chrome/browser/chromeos/login/wizard_controller.cc
index 815a1ce..296e7dd 100644
--- a/chrome/browser/chromeos/login/wizard_controller.cc
+++ b/chrome/browser/chromeos/login/wizard_controller.cc
@@ -237,10 +237,12 @@ void WizardController::OnLoginCreateAccount() {
}
void WizardController::OnNetworkConnected() {
- if (is_out_of_box_)
+ if (is_out_of_box_) {
SetCurrentScreen(GetUpdateScreen());
- else
+ update_screen_->StartUpdate();
+ } else {
SetCurrentScreen(GetLoginScreen());
+ }
}
void WizardController::OnAccountCreated() {
@@ -255,6 +257,12 @@ void WizardController::OnUpdateCompleted() {
SetCurrentScreen(GetLoginScreen());
}
+void WizardController::OnUpdateNetworkError() {
+ // If network connection got interrupted while downloading the update,
+ // return to network selection screen.
+ SetCurrentScreen(GetNetworkScreen());
+}
+
///////////////////////////////////////////////////////////////////////////////
// WizardController, private:
void WizardController::OnSwitchLanguage(const std::string& lang) {
@@ -302,6 +310,7 @@ void WizardController::ShowFirstScreen(const std::string& first_screen_name) {
SetCurrentScreen(GetAccountScreen());
} else if (first_screen_name == kUpdateScreenName) {
SetCurrentScreen(GetUpdateScreen());
+ update_screen_->StartUpdate();
} else {
if (is_out_of_box_) {
SetCurrentScreen(GetNetworkScreen());
@@ -334,6 +343,9 @@ void WizardController::OnExit(ExitCodes exit_code) {
case UPDATE_NOUPDATE:
OnUpdateCompleted();
break;
+ case UPDATE_NETWORK_ERROR:
+ OnUpdateNetworkError();
+ break;
default:
NOTREACHED();
}
diff --git a/chrome/browser/chromeos/login/wizard_controller.h b/chrome/browser/chromeos/login/wizard_controller.h
index 13f877b..d65efa1 100644
--- a/chrome/browser/chromeos/login/wizard_controller.h
+++ b/chrome/browser/chromeos/login/wizard_controller.h
@@ -78,6 +78,7 @@ class WizardController : public chromeos::ScreenObserver,
void OnAccountCreated();
void OnLanguageChanged();
void OnUpdateCompleted();
+ void OnUpdateNetworkError();
// Overridden from chromeos::ScreenObserver:
virtual void OnExit(ExitCodes exit_code);
diff --git a/views/controls/progress_bar.cc b/views/controls/progress_bar.cc
index 40cc814..1b1af25 100644
--- a/views/controls/progress_bar.cc
+++ b/views/controls/progress_bar.cc
@@ -162,6 +162,10 @@ int ProgressBar::GetProgress() const {
return progress_;
}
+void ProgressBar::AddProgress(int tick) {
+ SetProgress(progress_ + tick);
+}
+
void ProgressBar::SetTooltipText(const std::wstring& tooltip_text) {
tooltip_text_ = tooltip_text;
}
diff --git a/views/controls/progress_bar.h b/views/controls/progress_bar.h
index 128941f..65d10d7 100644
--- a/views/controls/progress_bar.h
+++ b/views/controls/progress_bar.h
@@ -42,6 +42,8 @@ class ProgressBar : public View {
// Set and get the progress bar progress in range [0, kMaxProgress].
virtual void SetProgress(int progress);
virtual int GetProgress() const;
+ // Add progress to current.
+ virtual void AddProgress(int tick);
// Sets the tooltip text. Default behavior for a progress bar is to show
// no tooltip on mouse hover. Calling this lets you set a custom tooltip.