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/existing_user_view.h" | 5 #include "chrome/browser/chromeos/login/existing_user_view.h" |
6 | 6 |
7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.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/textfield_with_margin.h" | 10 #include "chrome/browser/chromeos/login/textfield_with_margin.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 // Textfield with custom processing for Tab/Shift+Tab to select entries. | 26 // Textfield with custom processing for Tab/Shift+Tab to select entries. |
27 class UserEntryTextfield : public TextfieldWithMargin { | 27 class UserEntryTextfield : public TextfieldWithMargin { |
28 public: | 28 public: |
29 UserEntryTextfield(UserController* controller, | 29 UserEntryTextfield(UserController* controller, |
30 views::Textfield::StyleFlags style) | 30 views::Textfield::StyleFlags style) |
31 : TextfieldWithMargin(style), | 31 : TextfieldWithMargin(style), |
32 controller_(controller) {} | 32 controller_(controller) {} |
33 | 33 |
34 // Overridden from views::View: | 34 // Overridden from views::View: |
35 virtual bool OnKeyPressed(const views::KeyEvent& e) { | 35 virtual bool OnKeyPressed(const views::KeyEvent& e) { |
36 if (e.GetKeyCode() == app::VKEY_TAB) { | 36 if (e.GetKeyCode() == ui::VKEY_TAB) { |
37 controller_->SelectUserRelative(e.IsShiftDown() ? -1 : 1); | 37 controller_->SelectUserRelative(e.IsShiftDown() ? -1 : 1); |
38 return true; | 38 return true; |
39 } else if (e.GetKeyCode() == app::VKEY_LEFT) { | 39 } else if (e.GetKeyCode() == ui::VKEY_LEFT) { |
40 controller_->SelectUserRelative(-1); | 40 controller_->SelectUserRelative(-1); |
41 return true; | 41 return true; |
42 } else if (e.GetKeyCode() == app::VKEY_RIGHT) { | 42 } else if (e.GetKeyCode() == ui::VKEY_RIGHT) { |
43 controller_->SelectUserRelative(1); | 43 controller_->SelectUserRelative(1); |
44 return true; | 44 return true; |
45 } else { | 45 } else { |
46 return false; | 46 return false; |
47 } | 47 } |
48 } | 48 } |
49 | 49 |
50 virtual bool SkipDefaultKeyEventProcessing(const views::KeyEvent& e) { | 50 virtual bool SkipDefaultKeyEventProcessing(const views::KeyEvent& e) { |
51 if (e.GetKeyCode() == app::VKEY_TAB) | 51 if (e.GetKeyCode() == ui::VKEY_TAB) |
52 return true; | 52 return true; |
53 else | 53 else |
54 return views::Textfield::SkipDefaultKeyEventProcessing(e); | 54 return views::Textfield::SkipDefaultKeyEventProcessing(e); |
55 } | 55 } |
56 | 56 |
57 private: | 57 private: |
58 UserController* controller_; | 58 UserController* controller_; |
59 | 59 |
60 DISALLOW_COPY_AND_ASSIGN(UserEntryTextfield); | 60 DISALLOW_COPY_AND_ASSIGN(UserEntryTextfield); |
61 }; | 61 }; |
62 | 62 |
63 | 63 |
64 ExistingUserView::ExistingUserView(UserController* user_controller) | 64 ExistingUserView::ExistingUserView(UserController* user_controller) |
65 : user_controller_(user_controller), | 65 : user_controller_(user_controller), |
66 password_field_(NULL), | 66 password_field_(NULL), |
67 accel_login_off_the_record_( | 67 accel_login_off_the_record_( |
68 views::Accelerator(app::VKEY_B, false, false, true)), | 68 views::Accelerator(ui::VKEY_B, false, false, true)), |
69 accel_toggle_accessibility_( | 69 accel_toggle_accessibility_( |
70 WizardAccessibilityHelper::GetAccelerator()) { | 70 WizardAccessibilityHelper::GetAccelerator()) { |
71 AddAccelerator(accel_login_off_the_record_); | 71 AddAccelerator(accel_login_off_the_record_); |
72 AddAccelerator(accel_toggle_accessibility_); | 72 AddAccelerator(accel_toggle_accessibility_); |
73 } | 73 } |
74 | 74 |
75 void ExistingUserView::RecreateFields() { | 75 void ExistingUserView::RecreateFields() { |
76 if (password_field_ == NULL) { | 76 if (password_field_ == NULL) { |
77 SetLayoutManager(new views::FillLayout); | 77 SetLayoutManager(new views::FillLayout); |
78 password_field_ = new UserEntryTextfield(user_controller_, | 78 password_field_ = new UserEntryTextfield(user_controller_, |
(...skipping 18 matching lines...) Expand all Loading... |
97 return true; | 97 return true; |
98 } else if (accelerator == accel_toggle_accessibility_) { | 98 } else if (accelerator == accel_toggle_accessibility_) { |
99 WizardAccessibilityHelper::GetInstance()->ToggleAccessibility(this); | 99 WizardAccessibilityHelper::GetInstance()->ToggleAccessibility(this); |
100 return true; | 100 return true; |
101 } | 101 } |
102 return false; | 102 return false; |
103 } | 103 } |
104 | 104 |
105 bool ExistingUserView::HandleKeyEvent(views::Textfield* sender, | 105 bool ExistingUserView::HandleKeyEvent(views::Textfield* sender, |
106 const views::KeyEvent& key_event) { | 106 const views::KeyEvent& key_event) { |
107 if (key_event.GetKeyCode() == app::VKEY_RETURN) { | 107 if (key_event.GetKeyCode() == ui::VKEY_RETURN) { |
108 if (!password_field_->text().empty()) | 108 if (!password_field_->text().empty()) |
109 user_controller_->OnLogin("", UTF16ToUTF8(password_field_->text())); | 109 user_controller_->OnLogin("", UTF16ToUTF8(password_field_->text())); |
110 } else { | 110 } else { |
111 user_controller_->ClearErrors(); | 111 user_controller_->ClearErrors(); |
112 return false; | 112 return false; |
113 } | 113 } |
114 return true; | 114 return true; |
115 } | 115 } |
116 | 116 |
117 void ExistingUserView::ContentsChanged(views::Textfield* sender, | 117 void ExistingUserView::ContentsChanged(views::Textfield* sender, |
(...skipping 26 matching lines...) Expand all Loading... |
144 | 144 |
145 gfx::Rect ExistingUserView::GetMainInputScreenBounds() const { | 145 gfx::Rect ExistingUserView::GetMainInputScreenBounds() const { |
146 return password_field_->GetScreenBounds(); | 146 return password_field_->GetScreenBounds(); |
147 } | 147 } |
148 | 148 |
149 void ExistingUserView::OnLocaleChanged() { | 149 void ExistingUserView::OnLocaleChanged() { |
150 RecreateFields(); | 150 RecreateFields(); |
151 } | 151 } |
152 | 152 |
153 } // namespace chromeos | 153 } // namespace chromeos |
OLD | NEW |