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/background_view.h" | 5 #include "chrome/browser/chromeos/login/background_view.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/string16.h" | 10 #include "base/string16.h" |
| 11 #include "base/string_util.h" | 11 #include "base/string_util.h" |
| 12 #include "base/stringprintf.h" | 12 #include "base/stringprintf.h" |
| 13 #include "base/utf_string_conversions.h" | 13 #include "base/utf_string_conversions.h" |
| 14 #include "chrome/browser/browser_process.h" | 14 #include "chrome/browser/browser_process.h" |
| 15 #include "chrome/browser/chromeos/login/login_utils.h" | 15 #include "chrome/browser/chromeos/login/login_utils.h" |
| 16 #include "chrome/browser/chromeos/login/oobe_progress_bar.h" | 16 #include "chrome/browser/chromeos/login/oobe_progress_bar.h" |
| 17 #include "chrome/browser/chromeos/login/proxy_settings_dialog.h" | 17 #include "chrome/browser/chromeos/login/proxy_settings_dialog.h" |
| 18 #include "chrome/browser/chromeos/login/rounded_rect_painter.h" | 18 #include "chrome/browser/chromeos/login/rounded_rect_painter.h" |
| 19 #include "chrome/browser/chromeos/login/shutdown_button.h" | 19 #include "chrome/browser/chromeos/login/shutdown_button.h" |
| 20 #include "chrome/browser/chromeos/login/wizard_controller.h" | 20 #include "chrome/browser/chromeos/login/wizard_controller.h" |
| 21 #include "chrome/browser/chromeos/status/clock_menu_button.h" | 21 #include "chrome/browser/chromeos/status/clock_menu_button.h" |
| 22 #include "chrome/browser/chromeos/status/input_method_menu_button.h" | |
| 23 #include "chrome/browser/chromeos/status/network_menu_button.h" | |
| 24 #include "chrome/browser/chromeos/status/status_area_view.h" | |
| 25 #include "chrome/browser/policy/browser_policy_connector.h" | 22 #include "chrome/browser/policy/browser_policy_connector.h" |
| 26 #include "chrome/browser/profiles/profile_manager.h" | 23 #include "chrome/browser/profiles/profile_manager.h" |
| 27 #include "chrome/browser/ui/views/dom_view.h" | 24 #include "chrome/browser/ui/views/dom_view.h" |
| 28 #include "chrome/browser/ui/views/window.h" | 25 #include "chrome/browser/ui/views/window.h" |
| 29 #include "chrome/common/chrome_version_info.h" | 26 #include "chrome/common/chrome_version_info.h" |
| 30 #include "googleurl/src/gurl.h" | 27 #include "googleurl/src/gurl.h" |
| 31 #include "grit/chromium_strings.h" | 28 #include "grit/chromium_strings.h" |
| 32 #include "grit/generated_resources.h" | 29 #include "grit/generated_resources.h" |
| 33 #include "grit/theme_resources.h" | 30 #include "grit/theme_resources.h" |
| 34 #include "third_party/cros_system_api/window_manager/chromeos_wm_ipc_enums.h" | 31 #include "third_party/cros_system_api/window_manager/chromeos_wm_ipc_enums.h" |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 74 | 71 |
| 75 } // namespace | 72 } // namespace |
| 76 | 73 |
| 77 namespace chromeos { | 74 namespace chromeos { |
| 78 | 75 |
| 79 /////////////////////////////////////////////////////////////////////////////// | 76 /////////////////////////////////////////////////////////////////////////////// |
| 80 // BackgroundView public: | 77 // BackgroundView public: |
| 81 | 78 |
| 82 BackgroundView::BackgroundView() | 79 BackgroundView::BackgroundView() |
| 83 : status_area_(NULL), | 80 : status_area_(NULL), |
| 81 screen_mode_(StatusAreaViewChromeos::LOGIN_MODE_VIEWS), | |
| 84 os_version_label_(NULL), | 82 os_version_label_(NULL), |
| 85 boot_times_label_(NULL), | 83 boot_times_label_(NULL), |
| 86 progress_bar_(NULL), | 84 progress_bar_(NULL), |
| 87 shutdown_button_(NULL), | 85 shutdown_button_(NULL), |
| 88 #if defined(OFFICIAL_BUILD) | 86 #if defined(OFFICIAL_BUILD) |
| 89 is_official_build_(true), | 87 is_official_build_(true), |
| 90 #else | 88 #else |
| 91 is_official_build_(false), | 89 is_official_build_(false), |
| 92 #endif | 90 #endif |
| 93 background_area_(NULL), | 91 background_area_(NULL), |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 209 bool BackgroundView::IsScreenSaverVisible() { | 207 bool BackgroundView::IsScreenSaverVisible() { |
| 210 return ScreenSaverEnabled() && background_area_->IsVisible(); | 208 return ScreenSaverEnabled() && background_area_->IsVisible(); |
| 211 } | 209 } |
| 212 | 210 |
| 213 bool BackgroundView::ScreenSaverEnabled() { | 211 bool BackgroundView::ScreenSaverEnabled() { |
| 214 return background_area_ != NULL; | 212 return background_area_ != NULL; |
| 215 } | 213 } |
| 216 | 214 |
| 217 void BackgroundView::SetDefaultUse24HourClock(bool use_24hour_clock) { | 215 void BackgroundView::SetDefaultUse24HourClock(bool use_24hour_clock) { |
| 218 DCHECK(status_area_); | 216 DCHECK(status_area_); |
| 219 status_area_->clock_view()->SetDefaultUse24HourClock(use_24hour_clock); | 217 ClockMenuButton* clock_view = static_cast<ClockMenuButton*>( |
|
DaveMoore
2011/11/07 15:36:18
I'd rather see GetClockMenuButton() in StatusAreaV
stevenjb
2011/11/08 00:24:22
I think all of this is better off in StatusAreaVie
| |
| 218 status_area_->GetViewByID(VIEW_ID_STATUS_BUTTON_CLOCK)); | |
| 219 if (clock_view) | |
| 220 clock_view->SetDefaultUse24HourClock(use_24hour_clock); | |
| 220 } | 221 } |
| 221 | 222 |
| 222 /////////////////////////////////////////////////////////////////////////////// | 223 /////////////////////////////////////////////////////////////////////////////// |
| 223 // BackgroundView protected: | 224 // BackgroundView protected: |
| 224 | 225 |
| 225 void BackgroundView::Layout() { | 226 void BackgroundView::Layout() { |
| 226 const int kCornerPadding = 5; | 227 const int kCornerPadding = 5; |
| 227 const int kInfoLeftPadding = 10; | 228 const int kInfoLeftPadding = 10; |
| 228 const int kInfoBottomPadding = 10; | 229 const int kInfoBottomPadding = 10; |
| 229 const int kInfoBetweenLinesPadding = 1; | 230 const int kInfoBetweenLinesPadding = 1; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 264 } | 265 } |
| 265 if (background_area_) | 266 if (background_area_) |
| 266 background_area_->SetBoundsRect(this->bounds()); | 267 background_area_->SetBoundsRect(this->bounds()); |
| 267 } | 268 } |
| 268 | 269 |
| 269 void BackgroundView::ChildPreferredSizeChanged(View* child) { | 270 void BackgroundView::ChildPreferredSizeChanged(View* child) { |
| 270 Layout(); | 271 Layout(); |
| 271 SchedulePaint(); | 272 SchedulePaint(); |
| 272 } | 273 } |
| 273 | 274 |
| 274 Profile* BackgroundView::GetProfile() const { | 275 // Overridden from StatusAreaButton::Delegate: |
| 275 return NULL; | 276 |
| 277 bool BackgroundView::ShouldExecuteStatusAreaCommand( | |
| 278 const views::View* button_view, int command_id) const { | |
| 279 if (command_id == StatusAreaViewChromeos::SHOW_NETWORK_OPTIONS) | |
| 280 return true; | |
| 281 return false; | |
| 276 } | 282 } |
| 277 | 283 |
| 278 bool BackgroundView::ShouldOpenButtonOptions( | 284 void BackgroundView::ExecuteStatusAreaCommand( |
| 279 const views::View* button_view) const { | 285 const views::View* button_view, int command_id) { |
| 280 if (button_view == status_area_->network_view()) { | 286 if (command_id == StatusAreaViewChromeos::SHOW_NETWORK_OPTIONS) { |
| 281 return true; | |
| 282 } | |
| 283 if (button_view == status_area_->clock_view() || | |
| 284 button_view == status_area_->input_method_view()) { | |
| 285 return false; | |
| 286 } | |
| 287 return true; | |
| 288 } | |
| 289 | |
| 290 void BackgroundView::OpenButtonOptions(const views::View* button_view) { | |
| 291 if (button_view == status_area_->network_view()) { | |
| 292 if (proxy_settings_dialog_.get() == NULL) { | 287 if (proxy_settings_dialog_.get() == NULL) { |
| 293 proxy_settings_dialog_.reset(new ProxySettingsDialog( | 288 proxy_settings_dialog_.reset(new ProxySettingsDialog( |
| 294 this, GetNativeWindow())); | 289 this, GetNativeWindow())); |
| 295 } | 290 } |
| 296 proxy_settings_dialog_->Show(); | 291 proxy_settings_dialog_->Show(); |
| 297 } | 292 } |
| 298 } | 293 } |
| 299 | 294 |
| 300 StatusAreaHost::ScreenMode BackgroundView::GetScreenMode() const { | 295 int BackgroundView::GetFontStyle(const gfx::Font& font) const { |
| 301 return kViewsLoginMode; | 296 return gfx::Font::BOLD; |
| 302 } | 297 } |
| 303 | 298 |
| 304 StatusAreaHost::TextStyle BackgroundView::GetTextStyle() const { | 299 StatusAreaButton::TextStyle BackgroundView::GetTextStyle() const { |
| 305 return kGrayPlain; | 300 return StatusAreaButton::GRAY_PLAIN; |
| 306 } | 301 } |
| 307 | 302 |
| 308 void BackgroundView::ButtonVisibilityChanged(views::View* button_view) { | 303 void BackgroundView::ButtonVisibilityChanged(views::View* button_view) { |
| 309 status_area_->ButtonVisibilityChanged(button_view); | 304 status_area_->UpdateButtonVisibility(); |
| 310 } | 305 } |
| 311 | 306 |
| 312 // Overridden from LoginHtmlDialog::Delegate: | 307 // Overridden from LoginHtmlDialog::Delegate: |
| 308 | |
| 313 void BackgroundView::OnLocaleChanged() { | 309 void BackgroundView::OnLocaleChanged() { |
| 314 // Proxy settings dialog contains localized strings. | 310 // Proxy settings dialog contains localized strings. |
| 315 proxy_settings_dialog_.reset(); | 311 proxy_settings_dialog_.reset(); |
| 316 InitInfoLabels(); | 312 InitInfoLabels(); |
| 317 SchedulePaint(); | 313 SchedulePaint(); |
| 318 } | 314 } |
| 319 | 315 |
| 320 void BackgroundView::OnOSVersionLabelTextUpdated( | 316 void BackgroundView::OnOSVersionLabelTextUpdated( |
| 321 const std::string& os_version_label_text) { | 317 const std::string& os_version_label_text) { |
| 322 os_version_label_->SetText(UTF8ToUTF16(os_version_label_text)); | 318 os_version_label_->SetText(UTF8ToUTF16(os_version_label_text)); |
| 323 } | 319 } |
| 324 | 320 |
| 325 void BackgroundView::OnBootTimesLabelTextUpdated( | 321 void BackgroundView::OnBootTimesLabelTextUpdated( |
| 326 const std::string& boot_times_label_text) { | 322 const std::string& boot_times_label_text) { |
| 327 boot_times_label_->SetText(UTF8ToUTF16(boot_times_label_text)); | 323 boot_times_label_->SetText(UTF8ToUTF16(boot_times_label_text)); |
| 328 } | 324 } |
| 329 | 325 |
| 330 /////////////////////////////////////////////////////////////////////////////// | 326 /////////////////////////////////////////////////////////////////////////////// |
| 331 // BackgroundView private: | 327 // BackgroundView private: |
| 332 | 328 |
| 333 void BackgroundView::InitStatusArea() { | 329 void BackgroundView::InitStatusArea() { |
| 334 DCHECK(status_area_ == NULL); | 330 DCHECK(status_area_ == NULL); |
| 335 status_area_ = new StatusAreaView(this); | 331 status_area_ = new StatusAreaViewChromeos(); |
| 336 status_area_->Init(); | 332 status_area_->Init(this, screen_mode_); |
| 337 AddChildView(status_area_); | 333 AddChildView(status_area_); |
| 338 } | 334 } |
| 339 | 335 |
| 340 void BackgroundView::InitInfoLabels() { | 336 void BackgroundView::InitInfoLabels() { |
| 341 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 337 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
| 342 | 338 |
| 343 { | 339 { |
| 344 int idx = GetIndexOf(os_version_label_); | 340 int idx = GetIndexOf(os_version_label_); |
| 345 delete os_version_label_; | 341 delete os_version_label_; |
| 346 os_version_label_ = new views::Label(); | 342 os_version_label_ = new views::Label(); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 390 #if defined(TOOLKIT_USES_GTK) | 386 #if defined(TOOLKIT_USES_GTK) |
| 391 std::vector<int> params; | 387 std::vector<int> params; |
| 392 WmIpc::instance()->SetWindowType( | 388 WmIpc::instance()->SetWindowType( |
| 393 GTK_WIDGET(GetNativeWindow()), | 389 GTK_WIDGET(GetNativeWindow()), |
| 394 WM_IPC_WINDOW_LOGIN_BACKGROUND, | 390 WM_IPC_WINDOW_LOGIN_BACKGROUND, |
| 395 ¶ms); | 391 ¶ms); |
| 396 #endif | 392 #endif |
| 397 } | 393 } |
| 398 | 394 |
| 399 } // namespace chromeos | 395 } // namespace chromeos |
| OLD | NEW |