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" |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 35 #include "third_party/cros/chromeos_wm_ipc_enums.h" | 35 #include "third_party/cros/chromeos_wm_ipc_enums.h" |
| 36 #include "ui/base/l10n/l10n_util.h" | 36 #include "ui/base/l10n/l10n_util.h" |
| 37 #include "ui/base/resource/resource_bundle.h" | 37 #include "ui/base/resource/resource_bundle.h" |
| 38 #include "ui/base/x/x11_util.h" | 38 #include "ui/base/x/x11_util.h" |
| 39 #include "ui/gfx/gtk_util.h" | 39 #include "ui/gfx/gtk_util.h" |
| 40 #include "views/controls/button/text_button.h" | 40 #include "views/controls/button/text_button.h" |
| 41 #include "views/controls/label.h" | 41 #include "views/controls/label.h" |
| 42 #include "views/screen.h" | 42 #include "views/screen.h" |
| 43 #include "views/window/window.h" | 43 #include "views/window/window.h" |
| 44 | 44 |
| 45 // X Windows headers have "#define Status int". That interferes with | |
| 46 // NetworkLibrary header which defines enum "Status". | |
| 47 #include <X11/cursorfont.h> // NOLINT | |
| 48 #include <X11/Xcursor/Xcursor.h> // NOLINT | |
| 49 | |
| 50 using views::Widget; | 45 using views::Widget; |
| 51 | 46 |
| 52 namespace { | 47 namespace { |
| 53 | 48 |
| 54 const SkColor kVersionColor = 0xff5c739f; | 49 const SkColor kVersionColor = 0xff5c739f; |
| 55 | 50 |
| 56 // Returns the corresponding step id for step constant. | 51 // Returns the corresponding step id for step constant. |
| 57 int GetStepId(size_t step) { | 52 int GetStepId(size_t step) { |
| 58 switch (step) { | 53 switch (step) { |
| 59 case chromeos::BackgroundView::SELECT_NETWORK: | 54 case chromeos::BackgroundView::SELECT_NETWORK: |
| 60 return IDS_OOBE_SELECT_NETWORK; | 55 return IDS_OOBE_SELECT_NETWORK; |
| 61 case chromeos::BackgroundView::EULA: | 56 case chromeos::BackgroundView::EULA: |
| 62 return IDS_OOBE_EULA; | 57 return IDS_OOBE_EULA; |
| 63 case chromeos::BackgroundView::SIGNIN: | 58 case chromeos::BackgroundView::SIGNIN: |
| 64 return IDS_OOBE_SIGNIN; | 59 return IDS_OOBE_SIGNIN; |
| 65 case chromeos::BackgroundView::REGISTRATION: | 60 case chromeos::BackgroundView::REGISTRATION: |
| 66 return IDS_OOBE_REGISTRATION; | 61 return IDS_OOBE_REGISTRATION; |
| 67 case chromeos::BackgroundView::PICTURE: | 62 case chromeos::BackgroundView::PICTURE: |
| 68 return IDS_OOBE_PICTURE; | 63 return IDS_OOBE_PICTURE; |
| 69 default: | 64 default: |
| 70 NOTREACHED(); | 65 NOTREACHED(); |
| 71 return 0; | 66 return 0; |
| 72 } | 67 } |
| 73 } | 68 } |
| 74 | 69 |
| 75 // This gets rid of the ugly X default cursor. | |
| 76 static void ResetXCursor() { | |
| 77 // TODO(sky): nuke this once new window manager is in place. | |
| 78 Display* display = ui::GetXDisplay(); | |
| 79 Cursor cursor = XCreateFontCursor(display, XC_left_ptr); | |
| 80 XID root_window = ui::GetX11RootWindow(); | |
| 81 XSetWindowAttributes attr; | |
| 82 attr.cursor = cursor; | |
| 83 XChangeWindowAttributes(display, root_window, CWCursor, &attr); | |
| 84 } | |
| 85 | |
| 86 } // namespace | 70 } // namespace |
| 87 | 71 |
| 88 namespace chromeos { | 72 namespace chromeos { |
| 89 | 73 |
| 90 /////////////////////////////////////////////////////////////////////////////// | 74 /////////////////////////////////////////////////////////////////////////////// |
| 91 // BackgroundView public: | 75 // BackgroundView public: |
| 92 | 76 |
| 93 BackgroundView::BackgroundView() | 77 BackgroundView::BackgroundView() |
| 94 : status_area_(NULL), | 78 : status_area_(NULL), |
| 95 os_version_label_(NULL), | 79 os_version_label_(NULL), |
| 96 boot_times_label_(NULL), | 80 boot_times_label_(NULL), |
| 97 progress_bar_(NULL), | 81 progress_bar_(NULL), |
| 98 shutdown_button_(NULL), | 82 shutdown_button_(NULL), |
| 99 did_paint_(false), | |
| 100 #if defined(OFFICIAL_BUILD) | 83 #if defined(OFFICIAL_BUILD) |
| 101 is_official_build_(true), | 84 is_official_build_(true), |
| 102 #else | 85 #else |
| 103 is_official_build_(false), | 86 is_official_build_(false), |
| 104 #endif | 87 #endif |
| 105 background_area_(NULL) { | 88 background_area_(NULL) { |
| 106 } | 89 } |
| 107 | 90 |
| 108 BackgroundView::~BackgroundView() {} | 91 BackgroundView::~BackgroundView() {} |
| 109 | 92 |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 136 shutdown_button_ = NULL; | 119 shutdown_button_ = NULL; |
| 137 SchedulePaint(); | 120 SchedulePaint(); |
| 138 } | 121 } |
| 139 } | 122 } |
| 140 | 123 |
| 141 // static | 124 // static |
| 142 views::Widget* BackgroundView::CreateWindowContainingView( | 125 views::Widget* BackgroundView::CreateWindowContainingView( |
| 143 const gfx::Rect& bounds, | 126 const gfx::Rect& bounds, |
| 144 const GURL& background_url, | 127 const GURL& background_url, |
| 145 BackgroundView** view) { | 128 BackgroundView** view) { |
| 146 ResetXCursor(); | |
| 147 | |
| 148 Widget* window = new Widget; | 129 Widget* window = new Widget; |
| 149 Widget::InitParams params(Widget::InitParams::TYPE_WINDOW); | 130 Widget::InitParams params(Widget::InitParams::TYPE_WINDOW); |
| 150 params.bounds = bounds; | 131 params.bounds = bounds; |
| 151 window->Init(params); | 132 window->Init(params); |
| 152 *view = new BackgroundView(); | 133 *view = new BackgroundView(); |
| 153 (*view)->Init(background_url); | 134 (*view)->Init(background_url); |
| 154 | 135 |
| 155 if ((*view)->ScreenSaverEnabled()) | 136 if ((*view)->ScreenSaverEnabled()) |
| 156 (*view)->ShowScreenSaver(); | 137 (*view)->ShowScreenSaver(); |
| 157 | 138 |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 221 return ScreenSaverEnabled() && background_area_->IsVisible(); | 202 return ScreenSaverEnabled() && background_area_->IsVisible(); |
| 222 } | 203 } |
| 223 | 204 |
| 224 bool BackgroundView::ScreenSaverEnabled() { | 205 bool BackgroundView::ScreenSaverEnabled() { |
| 225 return background_area_ != NULL; | 206 return background_area_ != NULL; |
| 226 } | 207 } |
| 227 | 208 |
| 228 /////////////////////////////////////////////////////////////////////////////// | 209 /////////////////////////////////////////////////////////////////////////////// |
| 229 // BackgroundView protected: | 210 // BackgroundView protected: |
| 230 | 211 |
| 231 void BackgroundView::OnPaint(gfx::Canvas* canvas) { | |
| 232 views::View::OnPaint(canvas); | |
| 233 if (!did_paint_) { | |
| 234 did_paint_ = true; | |
| 235 UpdateWindowType(); | |
| 236 } | |
| 237 } | |
| 238 | |
| 239 void BackgroundView::Layout() { | 212 void BackgroundView::Layout() { |
| 240 const int kCornerPadding = 5; | 213 const int kCornerPadding = 5; |
| 241 const int kInfoLeftPadding = 10; | 214 const int kInfoLeftPadding = 10; |
| 242 const int kInfoBottomPadding = 10; | 215 const int kInfoBottomPadding = 10; |
| 243 const int kInfoBetweenLinesPadding = 1; | 216 const int kInfoBetweenLinesPadding = 1; |
| 244 const int kProgressBarBottomPadding = 20; | 217 const int kProgressBarBottomPadding = 20; |
| 245 const int kProgressBarWidth = 750; | 218 const int kProgressBarWidth = 750; |
| 246 const int kProgressBarHeight = 70; | 219 const int kProgressBarHeight = 70; |
| 247 gfx::Size status_area_size = status_area_->GetPreferredSize(); | 220 gfx::Size status_area_size = status_area_->GetPreferredSize(); |
| 248 status_area_->SetBounds( | 221 status_area_->SetBounds( |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 409 if (WizardController::IsRegisterScreenDefined()) | 382 if (WizardController::IsRegisterScreenDefined()) |
| 410 steps.push_back(GetStepId(REGISTRATION)); | 383 steps.push_back(GetStepId(REGISTRATION)); |
| 411 #endif | 384 #endif |
| 412 steps.push_back(GetStepId(PICTURE)); | 385 steps.push_back(GetStepId(PICTURE)); |
| 413 progress_bar_ = new OobeProgressBar(steps); | 386 progress_bar_ = new OobeProgressBar(steps); |
| 414 AddChildView(progress_bar_); | 387 AddChildView(progress_bar_); |
| 415 } | 388 } |
| 416 | 389 |
| 417 void BackgroundView::UpdateWindowType() { | 390 void BackgroundView::UpdateWindowType() { |
| 418 std::vector<int> params; | 391 std::vector<int> params; |
| 419 params.push_back(did_paint_ ? 1 : 0); | |
|
sky
2011/05/23 15:16:39
Did you also update the window manager side of thi
rharrison
2011/05/25 02:58:55
The window manager does not appear to do anything
| |
| 420 WmIpc::instance()->SetWindowType( | 392 WmIpc::instance()->SetWindowType( |
| 421 GTK_WIDGET(GetNativeWindow()), | 393 GTK_WIDGET(GetNativeWindow()), |
| 422 WM_IPC_WINDOW_LOGIN_BACKGROUND, | 394 WM_IPC_WINDOW_LOGIN_BACKGROUND, |
| 423 ¶ms); | 395 ¶ms); |
| 424 } | 396 } |
| 425 | 397 |
| 426 void BackgroundView::UpdateVersionLabel() { | 398 void BackgroundView::UpdateVersionLabel() { |
| 427 if (!CrosLibrary::Get()->EnsureLoaded()) { | 399 if (!CrosLibrary::Get()->EnsureLoaded()) { |
| 428 os_version_label_->SetText( | 400 os_version_label_->SetText( |
| 429 ASCIIToWide(CrosLibrary::Get()->load_error_string())); | 401 ASCIIToWide(CrosLibrary::Get()->load_error_string())); |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 538 boot_times_label_->SetText(ASCIIToWide(boot_times_text)); | 510 boot_times_label_->SetText(ASCIIToWide(boot_times_text)); |
| 539 } | 511 } |
| 540 | 512 |
| 541 void BackgroundView::OnPolicyStateChanged( | 513 void BackgroundView::OnPolicyStateChanged( |
| 542 policy::CloudPolicySubsystem::PolicySubsystemState state, | 514 policy::CloudPolicySubsystem::PolicySubsystemState state, |
| 543 policy::CloudPolicySubsystem::ErrorDetails error_details) { | 515 policy::CloudPolicySubsystem::ErrorDetails error_details) { |
| 544 UpdateEnterpriseInfo(); | 516 UpdateEnterpriseInfo(); |
| 545 } | 517 } |
| 546 | 518 |
| 547 } // namespace chromeos | 519 } // namespace chromeos |
| OLD | NEW |