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/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 "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 "grit/generated_resources.h" | 11 #include "grit/generated_resources.h" |
| 11 #include "views/focus/focus_manager.h" | 12 #include "views/focus/focus_manager.h" |
| 12 #include "views/grid_layout.h" | 13 #include "views/grid_layout.h" |
| 13 | 14 |
| 14 namespace chromeos { | 15 namespace chromeos { |
| 15 | 16 |
| 16 using login::kBorderSize; | 17 using login::kBorderSize; |
| 17 using views::GridLayout; | 18 using views::GridLayout; |
| 18 | 19 |
| 19 // NativeButton that will always return focus to password field. | 20 // NativeButton that will always return focus to password field. |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 62 else | 63 else |
| 63 return views::Textfield::SkipDefaultKeyEventProcessing(e); | 64 return views::Textfield::SkipDefaultKeyEventProcessing(e); |
| 64 } | 65 } |
| 65 | 66 |
| 66 private: | 67 private: |
| 67 UserController* controller_; | 68 UserController* controller_; |
| 68 | 69 |
| 69 DISALLOW_COPY_AND_ASSIGN(UserEntryTextfield); | 70 DISALLOW_COPY_AND_ASSIGN(UserEntryTextfield); |
| 70 }; | 71 }; |
| 71 | 72 |
| 73 | |
| 72 ExistingUserView::ExistingUserView(UserController* uc) | 74 ExistingUserView::ExistingUserView(UserController* uc) |
| 73 : accel_login_off_the_record_( | 75 : password_field_(NULL), |
| 74 views::Accelerator(app::VKEY_B, false, false, true)), | |
| 75 password_field_(NULL), | |
| 76 submit_button_(NULL), | 76 submit_button_(NULL), |
| 77 user_controller_(uc) { | 77 user_controller_(uc), |
| 78 accel_enable_accessibility_( | |
| 79 WizardAccessibilityHelper::GetAccelerator()) { | |
| 78 AddAccelerator(accel_login_off_the_record_); | 80 AddAccelerator(accel_login_off_the_record_); |
| 79 } | 81 } |
| 80 | 82 |
| 81 void ExistingUserView::RecreateFields() { | 83 void ExistingUserView::RecreateFields() { |
| 82 if (password_field_ == NULL) { | 84 if (password_field_ == NULL) { |
| 83 password_field_ = new UserEntryTextfield(user_controller_, | 85 password_field_ = new UserEntryTextfield(user_controller_, |
| 84 views::Textfield::STYLE_PASSWORD); | 86 views::Textfield::STYLE_PASSWORD); |
| 85 password_field_->SetFocusable(true); | 87 password_field_->SetFocusable(true); |
| 86 password_field_->SetController(user_controller_); | 88 password_field_->SetController(user_controller_); |
| 87 } | 89 } |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 101 GridLayout::USE_PREF, 0, 0); | 103 GridLayout::USE_PREF, 0, 0); |
| 102 column_set->AddPaddingColumn(0, kBorderSize); | 104 column_set->AddPaddingColumn(0, kBorderSize); |
| 103 column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 0, | 105 column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 0, |
| 104 GridLayout::USE_PREF, 0, 0); | 106 GridLayout::USE_PREF, 0, 0); |
| 105 layout->StartRow(0, 0); | 107 layout->StartRow(0, 0); |
| 106 layout->AddView(password_field_); | 108 layout->AddView(password_field_); |
| 107 layout->AddView(submit_button_); | 109 layout->AddView(submit_button_); |
| 108 SetLayoutManager(layout); | 110 SetLayoutManager(layout); |
| 109 layout->Layout(this); | 111 layout->Layout(this); |
| 110 SchedulePaint(); | 112 SchedulePaint(); |
| 113 AddAccelerator(accel_enable_accessibility_); | |
|
Nikita (slow)
2010/09/29 14:10:23
I'm moving this call to ctor.
RecreateFields is ca
| |
| 114 } | |
| 115 | |
| 116 bool ExistingUserView::AcceleratorPressed( | |
| 117 const views::Accelerator& accelerator) { | |
| 118 if (accelerator == accel_login_off_the_record_) { | |
| 119 user_controller_->OnLoginOffTheRecord(); | |
| 120 return true; | |
| 121 } else if (accelerator == accel_enable_accessibility_) { | |
| 122 WizardAccessibilityHelper::GetInstance()->EnableAccessibility(this); | |
| 123 return true; | |
| 124 } | |
| 125 return false; | |
| 126 } | |
| 127 | |
| 128 void ExistingUserView::ViewHierarchyChanged(bool is_add, | |
| 129 views::View* parent, | |
| 130 views::View* child) { | |
| 131 if (is_add && this == child) | |
| 132 WizardAccessibilityHelper::GetInstance()->MaybeEnableAccessibility(this); | |
| 111 } | 133 } |
| 112 | 134 |
| 113 void ExistingUserView::FocusPasswordField() { | 135 void ExistingUserView::FocusPasswordField() { |
| 114 if (GetFocusManager()) { | 136 if (GetFocusManager()) { |
| 115 password_field()->RequestFocus(); | 137 password_field()->RequestFocus(); |
| 116 } | 138 } |
| 117 } | 139 } |
| 118 | 140 |
| 119 void ExistingUserView::OnLocaleChanged() { | 141 void ExistingUserView::OnLocaleChanged() { |
| 120 RecreateFields(); | 142 RecreateFields(); |
| 121 } | 143 } |
| 122 | |
| 123 | |
| 124 bool ExistingUserView::AcceleratorPressed( | |
| 125 const views::Accelerator& accelerator) { | |
| 126 if (accelerator == accel_login_off_the_record_) { | |
| 127 user_controller_->OnLoginOffTheRecord(); | |
| 128 return true; | |
| 129 } | |
| 130 return false; | |
| 131 } | |
| 132 | |
| 133 } // namespace chromeos | 144 } // namespace chromeos |
| OLD | NEW |