diff options
author | nkostylev@google.com <nkostylev@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-02 09:00:27 +0000 |
---|---|---|
committer | nkostylev@google.com <nkostylev@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-02 09:00:27 +0000 |
commit | 796d0c6845a8eb6442e04035dc1b59d21555d7f3 (patch) | |
tree | b9f7ebf4afbb13b68efa990de2532faf06bd6465 /chrome | |
parent | 4f08ba89fe50630fc8545d5a2bff21320ee0f5da (diff) | |
download | chromium_src-796d0c6845a8eb6442e04035dc1b59d21555d7f3.zip chromium_src-796d0c6845a8eb6442e04035dc1b59d21555d7f3.tar.gz chromium_src-796d0c6845a8eb6442e04035dc1b59d21555d7f3.tar.bz2 |
Update screen refactoring, exit on successful update.
BUG= http://crosbug.com/4002
TEST=Manual: execute OOBE, make sure that update is available, wait for update to complete. If update_engine returns successful update code OOBE will proceed.
Review URL: http://codereview.chromium.org/2807013
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@51509 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/chromeos/login/update_screen.cc | 6 | ||||
-rw-r--r-- | chrome/browser/chromeos/login/update_view.cc | 57 | ||||
-rw-r--r-- | chrome/browser/chromeos/login/update_view.h | 3 |
3 files changed, 39 insertions, 27 deletions
diff --git a/chrome/browser/chromeos/login/update_screen.cc b/chrome/browser/chromeos/login/update_screen.cc index 282ff53..8e9a05a 100644 --- a/chrome/browser/chromeos/login/update_screen.cc +++ b/chrome/browser/chromeos/login/update_screen.cc @@ -66,7 +66,11 @@ void UpdateScreen::OnReportResults(GoogleUpdateUpgradeResult result, break; case UPGRADE_SUCCESSFUL: view()->AddProgress(kUpdateCompleteProgressIncrement); - // Fall through. + minimal_update_time_timer_.Stop(); + checking_for_update_ = false; + // TODO(nkostylev): Call reboot API. http://crosbug.com/4002 + ExitUpdate(); + break; case UPGRADE_ALREADY_UP_TO_DATE: checking_for_update_ = false; view()->AddProgress(kAfterUpdateCheckProgressIncrement); diff --git a/chrome/browser/chromeos/login/update_view.cc b/chrome/browser/chromeos/login/update_view.cc index 1e633d7..9facdbe 100644 --- a/chrome/browser/chromeos/login/update_view.cc +++ b/chrome/browser/chromeos/login/update_view.cc @@ -33,6 +33,8 @@ const int kProgressBarY = 250; const int kEscapeToSkipLabelY = 290; // Progress bar width. const int kProgressBarWidth = 450; +// Horizontal spacing (ex. min left and right margins for label on the screen). +const int kHorizontalSpacing = 25; // Label color. const SkColor kLabelColor = 0xFF000000; @@ -61,17 +63,13 @@ void UpdateView::Init() { 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); + InitLabel(&installing_updates_label_); installing_updates_label_->SetFont(base_font); - installing_updates_label_->SetHorizontalAlignment(views::Label::ALIGN_CENTER); - installing_updates_label_->SetMultiLine(true); progress_bar_ = new views::ProgressBar(); + AddChildView(progress_bar_); UpdateLocalizedStrings(); - AddChildView(installing_updates_label_); - AddChildView(progress_bar_); #if !defined(OFFICIAL_BUILD) escape_to_skip_label_ = new views::Label(); @@ -100,30 +98,29 @@ void UpdateView::AddProgress(int ticks) { progress_bar_->AddProgress(ticks); } -void UpdateView::Layout() { - 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( +// Sets the bounds of the view, placing it at the center of the screen +// with the |y| coordinate provided. |width| could specify desired view width +// otherwise preferred width/height are used. +// |x_center| specifies screen center. +static void setViewBounds( + views::View* view, int x_center, int y, int width = -1) { + int preferred_width = (width >= 0) ? width : view->GetPreferredSize().width(); + int preferred_height = view->GetPreferredSize().height(); + view->SetBounds( 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, + y, preferred_width, preferred_height); +} + +void UpdateView::Layout() { + int x_center = width() / 2; + int max_width = width() - GetInsets().width() - 2 * kHorizontalSpacing; + installing_updates_label_->SizeToFit(max_width); + setViewBounds(installing_updates_label_, x_center, kInstallingUpdatesLabelY); + setViewBounds(progress_bar_, x_center, kProgressBarY, kProgressBarWidth); #if !defined(OFFICIAL_BUILD) - preferred_width = escape_to_skip_label_->GetPreferredSize().width(); - preferred_height = escape_to_skip_label_->GetPreferredSize().height(); - escape_to_skip_label_->SetBounds( - x_center - preferred_width / 2, - kEscapeToSkipLabelY, - preferred_width, - preferred_height); + setViewBounds(escape_to_skip_label_, x_center, kEscapeToSkipLabelY); #endif SchedulePaint(); } @@ -141,4 +138,12 @@ bool UpdateView::AcceleratorPressed(const views::Accelerator& a) { return false; } +void UpdateView::InitLabel(views::Label** label) { + *label = new views::Label(); + (*label)->SetColor(kLabelColor); + (*label)->SetHorizontalAlignment(views::Label::ALIGN_CENTER); + (*label)->SetMultiLine(true); + AddChildView(*label); +} + } // namespace chromeos diff --git a/chrome/browser/chromeos/login/update_view.h b/chrome/browser/chromeos/login/update_view.h index 19a6a34..b5b09fb 100644 --- a/chrome/browser/chromeos/login/update_view.h +++ b/chrome/browser/chromeos/login/update_view.h @@ -40,6 +40,9 @@ class UpdateView : public views::View { virtual bool AcceleratorPressed(const views::Accelerator& a); private: + // Creates Label control and adds it as a child. + void InitLabel(views::Label** label); + // Keyboard accelerator to allow cancelling update by hitting escape. views::Accelerator escape_accelerator_; |