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

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

Issue 5709001: Place the spinner in the right corner of the controls window. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/chrome/browser/chromeos/login
Patch Set: Merged with trunk. Created 10 years 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) 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/guest_user_view.h" 5 #include "chrome/browser/chromeos/login/guest_user_view.h"
6 6
7 #include "app/l10n_util.h" 7 #include "app/l10n_util.h"
8 #include "chrome/browser/chromeos/login/helper.h" 8 #include "chrome/browser/chromeos/login/helper.h"
9 #include "chrome/browser/chromeos/login/user_controller.h" 9 #include "chrome/browser/chromeos/login/user_controller.h"
10 #include "chrome/browser/chromeos/login/wizard_accessibility_helper.h" 10 #include "chrome/browser/chromeos/login/wizard_accessibility_helper.h"
11 #include "grit/generated_resources.h" 11 #include "grit/generated_resources.h"
12 12
13 namespace chromeos { 13 namespace chromeos {
14 14
15 // Button with custom processing for Tab/Shift+Tab to select entries. 15 // Button with custom processing for Tab/Shift+Tab to select entries.
16 class UserEntryButton : public login::WideButton { 16 class UserEntryButton : public login::WideButton {
17 public: 17 public:
18 UserEntryButton(UserController* controller, 18 UserEntryButton(views::ButtonListener* button_listener,
19 UserController* user_controller,
19 const std::wstring& label) 20 const std::wstring& label)
20 : WideButton(controller, label), 21 : WideButton(button_listener, label),
21 controller_(controller) {} 22 user_controller_(user_controller) {}
22 23
23 // Overridden from views::View: 24 // Overridden from views::View:
24 virtual bool OnKeyPressed(const views::KeyEvent& e) { 25 virtual bool OnKeyPressed(const views::KeyEvent& e) {
25 if (e.GetKeyCode() == app::VKEY_TAB) { 26 if (e.GetKeyCode() == app::VKEY_TAB) {
26 int index = controller_->user_index() + (e.IsShiftDown() ? -1 : 1); 27 user_controller_->SelectUserRelative(e.IsShiftDown() ? -1 : 1);
27 controller_->SelectUser(index);
28 return true; 28 return true;
29 } 29 }
30 return WideButton::OnKeyPressed(e); 30 return WideButton::OnKeyPressed(e);
31 } 31 }
32 32
33 virtual bool SkipDefaultKeyEventProcessing(const views::KeyEvent& e) { 33 virtual bool SkipDefaultKeyEventProcessing(const views::KeyEvent& e) {
34 if (e.GetKeyCode() == app::VKEY_TAB) 34 if (e.GetKeyCode() == app::VKEY_TAB)
35 return true; 35 return true;
36 return WideButton::SkipDefaultKeyEventProcessing(e); 36 return WideButton::SkipDefaultKeyEventProcessing(e);
37 } 37 }
38 38
39 private: 39 private:
40 UserController* controller_; 40 UserController* user_controller_;
41 41
42 DISALLOW_COPY_AND_ASSIGN(UserEntryButton); 42 DISALLOW_COPY_AND_ASSIGN(UserEntryButton);
43 }; 43 };
44 44
45 45
46 GuestUserView::GuestUserView(UserController* uc) 46 GuestUserView::GuestUserView(UserController* uc)
47 : submit_button_(NULL), 47 : submit_button_(NULL),
48 user_controller_(uc), 48 user_controller_(uc),
49 accel_enable_accessibility_( 49 accel_enable_accessibility_(
50 WizardAccessibilityHelper::GetAccelerator()), 50 WizardAccessibilityHelper::GetAccelerator()),
51 accel_login_off_the_record_( 51 accel_login_off_the_record_(
52 views::Accelerator(app::VKEY_B, false, false, true)), 52 views::Accelerator(app::VKEY_B, false, false, true)),
53 accel_previous_pod_by_arrow_( 53 accel_previous_pod_by_arrow_(
54 views::Accelerator(app::VKEY_LEFT, false, false, false)), 54 views::Accelerator(app::VKEY_LEFT, false, false, false)),
55 accel_next_pod_by_arrow_( 55 accel_next_pod_by_arrow_(
56 views::Accelerator(app::VKEY_RIGHT, false, false, false)) { 56 views::Accelerator(app::VKEY_RIGHT, false, false, false)) {
57 AddAccelerator(accel_enable_accessibility_); 57 AddAccelerator(accel_enable_accessibility_);
58 AddAccelerator(accel_login_off_the_record_); 58 AddAccelerator(accel_login_off_the_record_);
59 AddAccelerator(accel_previous_pod_by_arrow_); 59 AddAccelerator(accel_previous_pod_by_arrow_);
60 AddAccelerator(accel_next_pod_by_arrow_); 60 AddAccelerator(accel_next_pod_by_arrow_);
61 } 61 }
62 62
63 void GuestUserView::RecreateFields() { 63 void GuestUserView::RecreateFields() {
64 delete submit_button_; 64 delete submit_button_;
65 submit_button_ = new UserEntryButton( 65 submit_button_ = new UserEntryButton(
66 this,
66 user_controller_, 67 user_controller_,
67 l10n_util::GetString(IDS_ENTER_GUEST_SESSION_BUTTON)); 68 l10n_util::GetString(IDS_ENTER_GUEST_SESSION_BUTTON));
68 AddChildView(submit_button_); 69 AddChildView(submit_button_);
69 Layout(); 70 Layout();
70 SchedulePaint(); 71 SchedulePaint();
71 } 72 }
72 73
73 void GuestUserView::FocusSignInButton() { 74 void GuestUserView::FocusSignInButton() {
74 if (GetFocusManager()) 75 submit_button_->RequestFocus();
75 submit_button_->RequestFocus();
76 } 76 }
77 77
78 bool GuestUserView::AcceleratorPressed( 78 bool GuestUserView::AcceleratorPressed(
79 const views::Accelerator& accelerator) { 79 const views::Accelerator& accelerator) {
80 if (accelerator == accel_login_off_the_record_) 80 if (accelerator == accel_login_off_the_record_)
81 user_controller_->OnLoginOffTheRecord(); 81 user_controller_->OnLoginOffTheRecord();
82 else if (accelerator == accel_enable_accessibility_) 82 else if (accelerator == accel_enable_accessibility_)
83 WizardAccessibilityHelper::GetInstance()->EnableAccessibility(this); 83 WizardAccessibilityHelper::GetInstance()->EnableAccessibility(this);
84 else if (accelerator == accel_previous_pod_by_arrow_) 84 else if (accelerator == accel_previous_pod_by_arrow_)
85 user_controller_->SelectUser(user_controller_->user_index() - 1); 85 user_controller_->SelectUserRelative(-1);
86 else if (accelerator == accel_next_pod_by_arrow_) 86 else if (accelerator == accel_next_pod_by_arrow_)
87 user_controller_->SelectUser(user_controller_->user_index() + 1); 87 user_controller_->SelectUserRelative(1);
88 else 88 else
89 return false; 89 return false;
90 return true; 90 return true;
91 } 91 }
92 92
93 void GuestUserView::ButtonPressed(
94 views::Button* sender, const views::Event& event) {
95 user_controller_->OnLoginOffTheRecord();
whywhat 2010/12/09 16:20:18 DCHECK or maybe even CHECK for button being what w
altimofeev 2010/12/10 16:37:40 DCHECK has been added.
96 }
97
98 void GuestUserView::EnableInputControls(bool enabled) {
99 submit_button_->SetEnabled(enabled);
100 }
101
93 void GuestUserView::ViewHierarchyChanged(bool is_add, 102 void GuestUserView::ViewHierarchyChanged(bool is_add,
94 views::View* parent, 103 views::View* parent,
95 views::View* child) { 104 views::View* child) {
96 if (is_add && this == child) 105 if (is_add && this == child)
97 WizardAccessibilityHelper::GetInstance()->MaybeEnableAccessibility(this); 106 WizardAccessibilityHelper::GetInstance()->MaybeEnableAccessibility(this);
98 } 107 }
99 108
100 void GuestUserView::OnLocaleChanged() { 109 void GuestUserView::OnLocaleChanged() {
101 RecreateFields(); 110 RecreateFields();
102 } 111 }
103 112
104 void GuestUserView::Layout() { 113 void GuestUserView::Layout() {
105 gfx::Size submit_button_size = submit_button_->GetPreferredSize(); 114 gfx::Size submit_button_size = submit_button_->GetPreferredSize();
106 int submit_button_x = (width() - submit_button_size.width()) / 2; 115 int submit_button_x = (width() - submit_button_size.width()) / 2;
107 int submit_button_y = (height() - submit_button_size.height()) / 2; 116 int submit_button_y = (height() - submit_button_size.height()) / 2;
108 submit_button_->SetBounds(submit_button_x, 117 submit_button_->SetBounds(submit_button_x,
109 submit_button_y, 118 submit_button_y,
110 submit_button_size.width(), 119 submit_button_size.width(),
111 submit_button_size.height()); 120 submit_button_size.height());
112 } 121 }
113 122
123 void GuestUserView::ClearAndFocusControls() {
124 }
125
126 void GuestUserView::ClearAndFocusPassword() {
127 }
128
129 gfx::Rect GuestUserView::GetControlWithErrorBounds() const {
130 NOTREACHED();
131 return gfx::Rect();
132 }
133
134 bool GuestUserView::UseCustomBoundsForThrobber (
135 const gfx::Size& /*throbber*/, gfx::Rect* /*bounds*/) const {
136 return false;
137 }
138
114 } // namespace chromeos 139 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698