Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
| 12 #include "chrome/browser/chromeos/login/helper.h" | 12 #include "chrome/browser/chromeos/login/helper.h" |
| 13 #include "chrome/browser/chromeos/login/rounded_rect_painter.h" | 13 #include "chrome/browser/chromeos/login/rounded_rect_painter.h" |
| 14 #include "chrome/browser/chromeos/login/wizard_accessibility_helper.h" | 14 #include "chrome/browser/chromeos/login/wizard_accessibility_helper.h" |
| 15 #include "grit/chromium_strings.h" | 15 #include "grit/chromium_strings.h" |
| 16 #include "grit/generated_resources.h" | 16 #include "grit/generated_resources.h" |
| 17 #include "ui/base/l10n/l10n_util.h" | 17 #include "ui/base/l10n/l10n_util.h" |
| 18 #include "ui/base/resource/resource_bundle.h" | 18 #include "ui/base/resource/resource_bundle.h" |
| 19 #include "ui/gfx/color_utils.h" | |
| 19 #include "views/border.h" | 20 #include "views/border.h" |
| 20 #include "views/controls/label.h" | 21 #include "views/controls/label.h" |
| 21 #include "views/controls/progress_bar.h" | 22 #include "views/controls/progress_bar.h" |
| 22 #include "views/controls/throbber.h" | 23 #include "views/controls/throbber.h" |
| 23 #include "views/focus/focus_manager.h" | 24 #include "views/focus/focus_manager.h" |
| 24 #include "views/widget/widget.h" | 25 #include "views/widget/widget.h" |
| 25 | 26 |
| 26 using std::max; | 27 using std::max; |
| 27 using views::Background; | 28 using views::Background; |
| 28 using views::Label; | 29 using views::Label; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 72 } | 73 } |
| 73 | 74 |
| 74 UpdateView::~UpdateView() { | 75 UpdateView::~UpdateView() { |
| 75 } | 76 } |
| 76 | 77 |
| 77 void UpdateView::Init() { | 78 void UpdateView::Init() { |
| 78 // Use rounded-rect background. | 79 // Use rounded-rect background. |
| 79 views::Painter* painter = chromeos::CreateWizardPainter( | 80 views::Painter* painter = chromeos::CreateWizardPainter( |
| 80 &chromeos::BorderDefinition::kScreenBorder); | 81 &chromeos::BorderDefinition::kScreenBorder); |
| 81 set_background(views::Background::CreateBackgroundPainter(true, painter)); | 82 set_background(views::Background::CreateBackgroundPainter(true, painter)); |
| 83 SkColor background_color = color_utils::AlphaBlend( | |
| 84 BorderDefinition::kScreenBorder.top_color, | |
| 85 BorderDefinition::kScreenBorder.bottom_color, 128); | |
| 82 | 86 |
| 83 InitLabel(&installing_updates_label_); | 87 InitLabel(&installing_updates_label_, background_color); |
| 84 InitLabel(&preparing_updates_label_); | 88 InitLabel(&preparing_updates_label_, background_color); |
| 85 InitLabel(&reboot_label_); | 89 InitLabel(&reboot_label_, background_color); |
| 86 InitLabel(&manual_reboot_label_); | 90 InitLabel(&manual_reboot_label_, background_color); |
| 87 preparing_updates_label_->SetVisible(false); | 91 preparing_updates_label_->SetVisible(false); |
| 88 manual_reboot_label_->SetVisible(false); | 92 manual_reboot_label_->SetVisible(false); |
| 89 manual_reboot_label_->SetColor(kManualRebootLabelColor); | 93 manual_reboot_label_->SetEnabledColor(kManualRebootLabelColor); |
| 90 | 94 |
| 91 progress_bar_ = new views::ProgressBar(); | 95 progress_bar_ = new views::ProgressBar(); |
| 92 AddChildView(progress_bar_); | 96 AddChildView(progress_bar_); |
| 93 progress_bar_->SetDisplayRange(0.0, 100.0); | 97 progress_bar_->SetDisplayRange(0.0, 100.0); |
| 94 | 98 |
| 95 // Curtain view. | 99 // Curtain view. |
| 96 InitLabel(&checking_label_); | 100 InitLabel(&checking_label_, background_color); |
| 97 throbber_ = CreateDefaultThrobber(); | 101 throbber_ = CreateDefaultThrobber(); |
| 98 AddChildView(throbber_); | 102 AddChildView(throbber_); |
| 99 | 103 |
| 100 #if !defined(OFFICIAL_BUILD) | 104 #if !defined(OFFICIAL_BUILD) |
| 101 InitLabel(&escape_to_skip_label_); | 105 InitLabel(&escape_to_skip_label_, background_color); |
| 102 escape_to_skip_label_->SetColor(kSkipLabelColor); | 106 escape_to_skip_label_->SetEnabledColor(kSkipLabelColor); |
| 103 escape_to_skip_label_->SetText( | 107 escape_to_skip_label_->SetText( |
| 104 ASCIIToUTF16("Press ESCAPE to skip (Non-official builds only)")); | 108 ASCIIToUTF16("Press ESCAPE to skip (Non-official builds only)")); |
| 105 #endif | 109 #endif |
| 106 | 110 |
| 107 UpdateLocalizedStrings(); | 111 UpdateLocalizedStrings(); |
| 108 UpdateVisibility(); | 112 UpdateVisibility(); |
| 109 } | 113 } |
| 110 | 114 |
| 111 void UpdateView::Reset() { | 115 void UpdateView::Reset() { |
| 112 progress_bar_->SetValue(0.0); | 116 progress_bar_->SetValue(0.0); |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 207 checking_label_, x_center + (throbber_width + 1) / 2 + space_half, | 211 checking_label_, x_center + (throbber_width + 1) / 2 + space_half, |
| 208 vertical_center); | 212 vertical_center); |
| 209 #if !defined(OFFICIAL_BUILD) | 213 #if !defined(OFFICIAL_BUILD) |
| 210 escape_to_skip_label_->SizeToFit(max_width); | 214 escape_to_skip_label_->SizeToFit(max_width); |
| 211 escape_to_skip_label_->SetX(right_margin); | 215 escape_to_skip_label_->SetX(right_margin); |
| 212 escape_to_skip_label_->SetY(kEscapeToSkipLabelY); | 216 escape_to_skip_label_->SetY(kEscapeToSkipLabelY); |
| 213 #endif | 217 #endif |
| 214 SchedulePaint(); | 218 SchedulePaint(); |
| 215 } | 219 } |
| 216 | 220 |
| 217 void UpdateView::InitLabel(views::Label** label) { | 221 void UpdateView::InitLabel(views::Label** label, SkColor background_color) { |
|
sky
2011/10/11 14:54:10
nit: out params should be last.
| |
| 218 *label = new views::Label(); | 222 *label = new views::Label(); |
| 219 (*label)->SetColor(kLabelColor); | 223 (*label)->SetBackgroundColor(background_color); |
| 224 (*label)->SetEnabledColor(kLabelColor); | |
| 220 (*label)->SetHorizontalAlignment(views::Label::ALIGN_LEFT); | 225 (*label)->SetHorizontalAlignment(views::Label::ALIGN_LEFT); |
| 221 (*label)->SetMultiLine(true); | 226 (*label)->SetMultiLine(true); |
| 222 | 227 |
| 223 ResourceBundle& res_bundle = ResourceBundle::GetSharedInstance(); | 228 ResourceBundle& res_bundle = ResourceBundle::GetSharedInstance(); |
| 224 gfx::Font label_font = res_bundle.GetFont(ResourceBundle::MediumFont); | 229 gfx::Font label_font = res_bundle.GetFont(ResourceBundle::MediumFont); |
| 225 (*label)->SetFont(label_font); | 230 (*label)->SetFont(label_font); |
| 226 | 231 |
| 227 AddChildView(*label); | 232 AddChildView(*label); |
| 228 } | 233 } |
| 229 | 234 |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 259 } else { | 264 } else { |
| 260 NOTREACHED(); | 265 NOTREACHED(); |
| 261 } | 266 } |
| 262 const std::string text = | 267 const std::string text = |
| 263 label_spoken ? UTF16ToUTF8(label_spoken->GetText()) : std::string(); | 268 label_spoken ? UTF16ToUTF8(label_spoken->GetText()) : std::string(); |
| 264 WizardAccessibilityHelper::GetInstance()->MaybeSpeak(text.c_str(), false, | 269 WizardAccessibilityHelper::GetInstance()->MaybeSpeak(text.c_str(), false, |
| 265 true); | 270 true); |
| 266 } | 271 } |
| 267 | 272 |
| 268 } // namespace chromeos | 273 } // namespace chromeos |
| OLD | NEW |