Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/user_controller.h" | 5 #include "chrome/browser/chromeos/login/user_controller.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "app/l10n_util.h" | 10 #include "app/l10n_util.h" |
| 11 #include "app/resource_bundle.h" | 11 #include "app/resource_bundle.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/chromeos/user_cros_settings_provider.h" | 14 #include "chrome/browser/chromeos/user_cros_settings_provider.h" |
| 15 #include "chrome/browser/chromeos/login/existing_user_view.h" | 15 #include "chrome/browser/chromeos/login/existing_user_view.h" |
| 16 #include "chrome/browser/chromeos/login/guest_user_view.h" | 16 #include "chrome/browser/chromeos/login/guest_user_view.h" |
| 17 #include "chrome/browser/chromeos/login/helper.h" | 17 #include "chrome/browser/chromeos/login/helper.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/rounded_view.h" | |
| 20 #include "chrome/browser/chromeos/login/user_view.h" | 19 #include "chrome/browser/chromeos/login/user_view.h" |
| 21 #include "chrome/browser/chromeos/login/username_view.h" | 20 #include "chrome/browser/chromeos/login/username_view.h" |
| 22 #include "chrome/browser/chromeos/login/wizard_controller.h" | 21 #include "chrome/browser/chromeos/login/wizard_controller.h" |
| 23 #include "chrome/common/notification_service.h" | 22 #include "chrome/common/notification_service.h" |
| 24 #include "chrome/common/notification_type.h" | 23 #include "chrome/common/notification_type.h" |
| 25 #include "cros/chromeos_wm_ipc_enums.h" | 24 #include "cros/chromeos_wm_ipc_enums.h" |
| 26 #include "gfx/canvas.h" | 25 #include "gfx/canvas.h" |
| 27 #include "grit/generated_resources.h" | 26 #include "grit/generated_resources.h" |
| 28 #include "grit/theme_resources.h" | 27 #include "grit/theme_resources.h" |
| 29 #include "views/background.h" | 28 #include "views/background.h" |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 80 DISALLOW_COPY_AND_ASSIGN(ClickNotifyingWidget); | 79 DISALLOW_COPY_AND_ASSIGN(ClickNotifyingWidget); |
| 81 }; | 80 }; |
| 82 | 81 |
| 83 void CloseWindow(views::WidgetGtk* window) { | 82 void CloseWindow(views::WidgetGtk* window) { |
| 84 if (!window) | 83 if (!window) |
| 85 return; | 84 return; |
| 86 window->SetWidgetDelegate(NULL); | 85 window->SetWidgetDelegate(NULL); |
| 87 window->Close(); | 86 window->Close(); |
| 88 } | 87 } |
| 89 | 88 |
| 90 // Class that sets up half rounded rectangle (only the bottom corners are | |
| 91 // rounded) as a clip region of the view. | |
| 92 // For more info see the file "chrome/browser/chromeos/login/rounded_view.h". | |
| 93 template<typename C> | |
| 94 class HalfRoundedView : public chromeos::RoundedView<C> { | |
| 95 public: | |
| 96 explicit HalfRoundedView(const std::wstring &text): RoundedView<C>(text) { | |
| 97 } | |
| 98 | |
| 99 protected: | |
| 100 // Overrides ViewFilter. | |
| 101 virtual void DrawFrame(gfx::Canvas* canvas) { | |
| 102 // No frame is needed. | |
| 103 } | |
| 104 | |
| 105 virtual SkRect GetViewRect() const { | |
| 106 gfx::Rect bounds = C::GetLocalBounds(false); | |
| 107 SkRect view_rect; | |
| 108 // The rectangle will be intersected with the bounds, so the correct half | |
| 109 // of the round rectangle will be obtained. | |
| 110 view_rect.iset(bounds.x(), bounds.y() - bounds.width(), | |
| 111 bounds.x() + bounds.width(), | |
| 112 bounds.y() + bounds.height()); | |
| 113 view_rect.inset(2 * rounded_view::kStrokeWidth, | |
| 114 2 * rounded_view::kStrokeWidth); | |
| 115 return view_rect; | |
| 116 } | |
| 117 }; | |
| 118 | |
| 119 } // namespace | 89 } // namespace |
| 120 | 90 |
| 121 using login::kBackgroundColor; | 91 using login::kBackgroundColor; |
| 122 using login::kBorderSize; | 92 using login::kBorderSize; |
| 123 using login::kTextColor; | 93 using login::kTextColor; |
| 124 using login::kUserImageSize; | 94 using login::kUserImageSize; |
| 125 | 95 |
| 126 // static | 96 // static |
| 127 const int UserController::kPadding = 30; | 97 const int UserController::kPadding = 30; |
| 128 | 98 |
| (...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 488 text = l10n_util::GetString(IDS_GUEST); | 458 text = l10n_util::GetString(IDS_GUEST); |
| 489 } else if (is_new_user_) { | 459 } else if (is_new_user_) { |
| 490 // Add user should have label only in activated state. | 460 // Add user should have label only in activated state. |
| 491 // When new user is the only, label is not needed. | 461 // When new user is the only, label is not needed. |
| 492 if (type == WM_IPC_WINDOW_LOGIN_LABEL && index != 0) | 462 if (type == WM_IPC_WINDOW_LOGIN_LABEL && index != 0) |
| 493 text = l10n_util::GetString(IDS_ADD_USER); | 463 text = l10n_util::GetString(IDS_ADD_USER); |
| 494 } else { | 464 } else { |
| 495 text = UTF8ToWide(user_.GetDisplayName()); | 465 text = UTF8ToWide(user_.GetDisplayName()); |
| 496 } | 466 } |
| 497 | 467 |
| 498 views::Label *label = is_new_user_ ? | 468 views::Label *label = NULL; |
| 499 new views::Label(text) : new HalfRoundedView<UsernameView>(text); | 469 |
| 470 if (is_new_user_) { | |
| 471 label = new views::Label(text); | |
| 472 } else if (type == WM_IPC_WINDOW_LOGIN_LABEL) { | |
| 473 label = UsernameView::CreateShapedUsernameView(text, false); | |
| 474 } else { | |
| 475 DCHECK(type == WM_IPC_WINDOW_LOGIN_UNSELECTED_LABEL); | |
| 476 // TODO(altimofeev): switch to the rounded username view. | |
|
Nikita (slow)
2010/12/07 09:32:40
Should file a P2 cleanup issue?
altimofeev
2010/12/10 10:25:25
Actually, it is not a cleanup. The problem is that
| |
| 477 label = UsernameView::CreateShapedUsernameView(text, true); | |
| 478 } | |
| 500 | 479 |
| 501 label->SetColor(kTextColor); | 480 label->SetColor(kTextColor); |
| 502 label->SetFont(font); | 481 label->SetFont(font); |
| 503 | 482 |
| 504 if (type == WM_IPC_WINDOW_LOGIN_LABEL) | 483 if (type == WM_IPC_WINDOW_LOGIN_LABEL) |
| 505 label_view_ = label; | 484 label_view_ = label; |
| 506 else | 485 else |
| 507 unselected_label_view_ = label; | 486 unselected_label_view_ = label; |
| 508 | 487 |
| 509 int width = (type == WM_IPC_WINDOW_LOGIN_LABEL) ? | 488 int width = (type == WM_IPC_WINDOW_LOGIN_LABEL) ? |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 571 | 550 |
| 572 void UserController::SelectUser(int index) { | 551 void UserController::SelectUser(int index) { |
| 573 delegate_->SelectUser(index); | 552 delegate_->SelectUser(index); |
| 574 } | 553 } |
| 575 | 554 |
| 576 void UserController::FocusPasswordField() { | 555 void UserController::FocusPasswordField() { |
| 577 existing_user_view_->FocusPasswordField(); | 556 existing_user_view_->FocusPasswordField(); |
| 578 } | 557 } |
| 579 | 558 |
| 580 } // namespace chromeos | 559 } // namespace chromeos |
| OLD | NEW |