Skip to content
Snippets Groups Projects
Commit 796d0c68 authored by nkostylev@google.com's avatar nkostylev@google.com
Browse files

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
parent 4f08ba89
No related branches found
No related tags found
No related merge requests found
......@@ -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);
......
......@@ -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
......@@ -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_;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment