Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: chrome/browser/chromeos/login/update_view.cc

Issue 7057055: Show progress bar as soon as update state changed to UPDATE_STATUS_UPDATE_AVAILABLE (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixed test again Created 9 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/chromeos/login/update_view.h" 5 #include "chrome/browser/chromeos/login/update_view.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "chrome/browser/chromeos/login/helper.h" 10 #include "chrome/browser/chromeos/login/helper.h"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 const SkColor kLabelColor = 0xFF000000; 51 const SkColor kLabelColor = 0xFF000000;
52 const SkColor kSkipLabelColor = 0xFFAA0000; 52 const SkColor kSkipLabelColor = 0xFFAA0000;
53 const SkColor kManualRebootLabelColor = 0xFFAA0000; 53 const SkColor kManualRebootLabelColor = 0xFFAA0000;
54 54
55 } // namespace 55 } // namespace
56 56
57 namespace chromeos { 57 namespace chromeos {
58 58
59 UpdateView::UpdateView(chromeos::ScreenObserver* observer) 59 UpdateView::UpdateView(chromeos::ScreenObserver* observer)
60 : installing_updates_label_(NULL), 60 : installing_updates_label_(NULL),
61 preparing_updates_label_(NULL),
61 reboot_label_(NULL), 62 reboot_label_(NULL),
62 manual_reboot_label_(NULL), 63 manual_reboot_label_(NULL),
63 progress_bar_(NULL), 64 progress_bar_(NULL),
64 show_curtain_(true), 65 show_curtain_(true),
65 show_manual_reboot_label_(false), 66 show_manual_reboot_label_(false),
67 show_preparing_updates_label_(false),
66 observer_(observer) { 68 observer_(observer) {
67 } 69 }
68 70
69 UpdateView::~UpdateView() { 71 UpdateView::~UpdateView() {
70 } 72 }
71 73
72 void UpdateView::Init() { 74 void UpdateView::Init() {
73 // Use rounded-rect background. 75 // Use rounded-rect background.
74 views::Painter* painter = chromeos::CreateWizardPainter( 76 views::Painter* painter = chromeos::CreateWizardPainter(
75 &chromeos::BorderDefinition::kScreenBorder); 77 &chromeos::BorderDefinition::kScreenBorder);
76 set_background(views::Background::CreateBackgroundPainter(true, painter)); 78 set_background(views::Background::CreateBackgroundPainter(true, painter));
77 79
78 InitLabel(&installing_updates_label_); 80 InitLabel(&installing_updates_label_);
81 InitLabel(&preparing_updates_label_);
79 InitLabel(&reboot_label_); 82 InitLabel(&reboot_label_);
80 InitLabel(&manual_reboot_label_); 83 InitLabel(&manual_reboot_label_);
84 preparing_updates_label_->SetVisible(false);
81 manual_reboot_label_->SetVisible(false); 85 manual_reboot_label_->SetVisible(false);
82 manual_reboot_label_->SetColor(kManualRebootLabelColor); 86 manual_reboot_label_->SetColor(kManualRebootLabelColor);
83 87
84 progress_bar_ = new views::ProgressBar(); 88 progress_bar_ = new views::ProgressBar();
85 AddChildView(progress_bar_); 89 AddChildView(progress_bar_);
86 90
87 // Curtain view. 91 // Curtain view.
88 InitLabel(&checking_label_); 92 InitLabel(&checking_label_);
89 throbber_ = CreateDefaultThrobber(); 93 throbber_ = CreateDefaultThrobber();
90 AddChildView(throbber_); 94 AddChildView(throbber_);
(...skipping 10 matching lines...) Expand all
101 } 105 }
102 106
103 void UpdateView::Reset() { 107 void UpdateView::Reset() {
104 progress_bar_->SetProgress(0); 108 progress_bar_->SetProgress(0);
105 } 109 }
106 110
107 void UpdateView::UpdateLocalizedStrings() { 111 void UpdateView::UpdateLocalizedStrings() {
108 installing_updates_label_->SetText(UTF16ToWide(l10n_util::GetStringFUTF16( 112 installing_updates_label_->SetText(UTF16ToWide(l10n_util::GetStringFUTF16(
109 IDS_INSTALLING_UPDATE, 113 IDS_INSTALLING_UPDATE,
110 l10n_util::GetStringUTF16(IDS_PRODUCT_OS_NAME)))); 114 l10n_util::GetStringUTF16(IDS_PRODUCT_OS_NAME))));
115 preparing_updates_label_->SetText(
116 UTF16ToWide(l10n_util::GetStringUTF16(IDS_UPDATE_AVAILABLE)));
111 reboot_label_->SetText( 117 reboot_label_->SetText(
112 UTF16ToWide(l10n_util::GetStringUTF16(IDS_INSTALLING_UPDATE_DESC))); 118 UTF16ToWide(l10n_util::GetStringUTF16(IDS_INSTALLING_UPDATE_DESC)));
113 manual_reboot_label_->SetText( 119 manual_reboot_label_->SetText(
114 UTF16ToWide(l10n_util::GetStringUTF16(IDS_UPDATE_COMPLETED))); 120 UTF16ToWide(l10n_util::GetStringUTF16(IDS_UPDATE_COMPLETED)));
115 checking_label_->SetText( 121 checking_label_->SetText(
116 UTF16ToWide(l10n_util::GetStringUTF16(IDS_CHECKING_FOR_UPDATES))); 122 UTF16ToWide(l10n_util::GetStringUTF16(IDS_CHECKING_FOR_UPDATES)));
117 } 123 }
118 124
119 void UpdateView::AddProgress(int ticks) { 125 void UpdateView::AddProgress(int ticks) {
120 progress_bar_->AddProgress(ticks); 126 progress_bar_->AddProgress(ticks);
121 } 127 }
122 128
123 void UpdateView::SetProgress(int progress) { 129 void UpdateView::SetProgress(int progress) {
124 progress_bar_->SetProgress(progress); 130 progress_bar_->SetProgress(progress);
125 } 131 }
126 132
127 void UpdateView::ShowManualRebootInfo() { 133 void UpdateView::ShowManualRebootInfo() {
128 show_manual_reboot_label_ = true; 134 show_manual_reboot_label_ = true;
129 UpdateVisibility(); 135 UpdateVisibility();
130 } 136 }
131 137
138 void UpdateView::ShowPreparingUpdatesInfo(bool visible) {
139 show_preparing_updates_label_ = visible;
140 UpdateVisibility();
141 }
142
132 void UpdateView::ShowCurtain(bool show_curtain) { 143 void UpdateView::ShowCurtain(bool show_curtain) {
133 if (show_curtain_ != show_curtain) { 144 if (show_curtain_ != show_curtain) {
134 show_curtain_ = show_curtain; 145 show_curtain_ = show_curtain;
135 UpdateVisibility(); 146 UpdateVisibility();
136 } 147 }
137 } 148 }
138 149
139 // Sets the bounds of the view, placing center of the view at the given 150 // Sets the bounds of the view, placing center of the view at the given
140 // coordinates (|x| and |y|). 151 // coordinates (|x| and |y|).
141 static void setViewBounds(views::View* view, int x, int y) { 152 static void setViewBounds(views::View* view, int x, int y) {
142 int preferred_width = view->GetPreferredSize().width(); 153 int preferred_width = view->GetPreferredSize().width();
143 int preferred_height = view->GetPreferredSize().height(); 154 int preferred_height = view->GetPreferredSize().height();
144 view->SetBounds( 155 view->SetBounds(
145 x - preferred_width / 2, 156 x - preferred_width / 2,
146 y - preferred_height / 2, 157 y - preferred_height / 2,
147 preferred_width, 158 preferred_width,
148 preferred_height); 159 preferred_height);
149 } 160 }
150 161
151 void UpdateView::Layout() { 162 void UpdateView::Layout() {
152 int max_width = width() - GetInsets().width() - 2 * kHorizontalSpacing; 163 int max_width = width() - GetInsets().width() - 2 * kHorizontalSpacing;
153 int right_margin = GetInsets().right() + kHorizontalSpacing; 164 int right_margin = GetInsets().right() + kHorizontalSpacing;
154 int max_height = height() - GetInsets().height(); 165 int max_height = height() - GetInsets().height();
155 int vertical_center = GetInsets().top() + max_height / 2; 166 int vertical_center = GetInsets().top() + max_height / 2;
156 167
157 installing_updates_label_->SizeToFit(max_width); 168 installing_updates_label_->SizeToFit(max_width);
169 preparing_updates_label_->SizeToFit(max_width);
158 reboot_label_->SizeToFit(max_width); 170 reboot_label_->SizeToFit(max_width);
159 manual_reboot_label_->SizeToFit(max_width); 171 manual_reboot_label_->SizeToFit(max_width);
160 172
161 progress_bar_->SetBounds(right_margin, 173 progress_bar_->SetBounds(right_margin,
162 vertical_center - kProgressBarHeight / 2, 174 vertical_center - kProgressBarHeight / 2,
163 max_width, 175 max_width,
164 kProgressBarHeight); 176 kProgressBarHeight);
165 177
166 installing_updates_label_->SetX(right_margin); 178 installing_updates_label_->SetX(right_margin);
167 installing_updates_label_->SetY( 179 installing_updates_label_->SetY(
168 progress_bar_->y() - 180 progress_bar_->y() -
169 kInstallingUpdatesLabelYBottomFromProgressBar - 181 kInstallingUpdatesLabelYBottomFromProgressBar -
170 installing_updates_label_->height()); 182 installing_updates_label_->height());
183 preparing_updates_label_->SetX(installing_updates_label_->x());
184 preparing_updates_label_->SetY(installing_updates_label_->y());
171 reboot_label_->SetX(right_margin); 185 reboot_label_->SetX(right_margin);
172 reboot_label_->SetY( 186 reboot_label_->SetY(
173 progress_bar_->y() + 187 progress_bar_->y() +
174 progress_bar_->height() + 188 progress_bar_->height() +
175 kRebootLabelYFromProgressBar); 189 kRebootLabelYFromProgressBar);
176 manual_reboot_label_->SetX(reboot_label_->x()); 190 manual_reboot_label_->SetX(reboot_label_->x());
177 manual_reboot_label_->SetY(reboot_label_->y()); 191 manual_reboot_label_->SetY(reboot_label_->y());
178 // Curtain layout is independed. 192 // Curtain layout is independed.
179 int x_center = width() / 2; 193 int x_center = width() / 2;
180 int throbber_width = throbber_->GetPreferredSize().width(); 194 int throbber_width = throbber_->GetPreferredSize().width();
(...skipping 21 matching lines...) Expand all
202 (*label)->SetMultiLine(true); 216 (*label)->SetMultiLine(true);
203 217
204 ResourceBundle& res_bundle = ResourceBundle::GetSharedInstance(); 218 ResourceBundle& res_bundle = ResourceBundle::GetSharedInstance();
205 gfx::Font label_font = res_bundle.GetFont(ResourceBundle::MediumFont); 219 gfx::Font label_font = res_bundle.GetFont(ResourceBundle::MediumFont);
206 (*label)->SetFont(label_font); 220 (*label)->SetFont(label_font);
207 221
208 AddChildView(*label); 222 AddChildView(*label);
209 } 223 }
210 224
211 void UpdateView::UpdateVisibility() { 225 void UpdateView::UpdateVisibility() {
212 installing_updates_label_->SetVisible( 226 installing_updates_label_->SetVisible(!show_curtain_ &&
213 !show_curtain_&& !show_manual_reboot_label_); 227 !show_manual_reboot_label_ &&
228 !show_preparing_updates_label_);
229 preparing_updates_label_->SetVisible(!show_curtain_ &&
230 !show_manual_reboot_label_ &&
231 show_preparing_updates_label_);
214 reboot_label_->SetVisible(!show_curtain_&& !show_manual_reboot_label_); 232 reboot_label_->SetVisible(!show_curtain_&& !show_manual_reboot_label_);
215 manual_reboot_label_->SetVisible(!show_curtain_ && show_manual_reboot_label_); 233 manual_reboot_label_->SetVisible(!show_curtain_ && show_manual_reboot_label_);
216 progress_bar_->SetVisible(!show_curtain_); 234 progress_bar_->SetVisible(!show_curtain_);
217 235
218 checking_label_->SetVisible(show_curtain_); 236 checking_label_->SetVisible(show_curtain_);
219 throbber_->SetVisible(show_curtain_); 237 throbber_->SetVisible(show_curtain_);
220 if (show_curtain_) { 238 if (show_curtain_) {
221 throbber_->Start(); 239 throbber_->Start();
222 } else { 240 } else {
223 throbber_->Stop(); 241 throbber_->Stop();
224 } 242 }
225 } 243 }
226 244
227 } // namespace chromeos 245 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/update_view.h ('k') | chrome/browser/chromeos/login/views_update_screen_actor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698