Chromium Code Reviews| Index: chrome/browser/chromeos/login/existing_user_view.cc |
| diff --git a/chrome/browser/chromeos/login/existing_user_view.cc b/chrome/browser/chromeos/login/existing_user_view.cc |
| index d5bb4c3933362cb2c3f275c0d0e8358d974983ad..134b47b55e2772bb2363b26501f7aa0641f39e0e 100644 |
| --- a/chrome/browser/chromeos/login/existing_user_view.cc |
| +++ b/chrome/browser/chromeos/login/existing_user_view.cc |
| @@ -5,6 +5,7 @@ |
| #include "chrome/browser/chromeos/login/existing_user_view.h" |
| #include "app/l10n_util.h" |
| +#include "base/utf_string_conversions.h" |
| #include "chrome/browser/chromeos/login/helper.h" |
| #include "chrome/browser/chromeos/login/user_controller.h" |
| #include "chrome/browser/chromeos/login/textfield_with_margin.h" |
| @@ -34,8 +35,7 @@ class UserEntryTextfield : public TextfieldWithMargin { |
| // Overridden from views::View: |
| virtual bool OnKeyPressed(const views::KeyEvent& e) { |
| if (e.GetKeyCode() == app::VKEY_TAB) { |
| - int index = controller_->user_index() + (e.IsShiftDown() ? -1 : 1); |
| - controller_->SelectUser(index); |
| + controller_->SelectUserRelative(e.IsShiftDown() ? -1 : 1); |
| return true; |
| } else { |
| return false; |
| @@ -56,11 +56,11 @@ class UserEntryTextfield : public TextfieldWithMargin { |
| }; |
| -ExistingUserView::ExistingUserView(UserController* uc) |
| - : accel_login_off_the_record_( |
| - views::Accelerator(app::VKEY_B, false, false, true)), |
| +ExistingUserView::ExistingUserView(UserController* user_controller) |
| + : user_controller_(user_controller), |
| password_field_(NULL), |
| - user_controller_(uc), |
| + accel_login_off_the_record_( |
| + views::Accelerator(app::VKEY_B, false, false, true)), |
| accel_enable_accessibility_( |
| WizardAccessibilityHelper::GetAccelerator()) { |
| AddAccelerator(accel_login_off_the_record_); |
| @@ -76,7 +76,7 @@ void ExistingUserView::RecreateFields() { |
| views::Background::CreateVerticalGradientBackground( |
| kBackgroundColorTop, kBackgroundColorBottom)); |
| password_field_->SetFocusable(true); |
| - password_field_->SetController(user_controller_); |
| + password_field_->SetController(this); |
| AddChildView(password_field_); |
| } |
| password_field_->set_text_to_display_when_empty( |
| @@ -97,6 +97,40 @@ bool ExistingUserView::AcceleratorPressed( |
| return false; |
| } |
| +bool ExistingUserView::HandleKeystroke( |
| + views::Textfield* sender, |
| + const views::Textfield::Keystroke& keystroke) { |
| + if (keystroke.GetKeyboardCode() == app::VKEY_RETURN) { |
| + user_controller_->OnLogin("", UTF16ToUTF8(password_field_->text())); |
|
whywhat
2010/12/13 07:57:35
Maybe std::string() is better here for empty usern
altimofeev
2010/12/13 15:42:45
I think "" is more representative. Empty string is
|
| + } else if (keystroke.GetKeyboardCode() == app::VKEY_LEFT) { |
| + user_controller_->SelectUserRelative(-1); |
| + } else if (keystroke.GetKeyboardCode() == app::VKEY_RIGHT) { |
| + user_controller_->SelectUserRelative(1); |
| + } else { |
| + user_controller_->ClearErrors(); |
| + return false; |
| + } |
| + |
| + return true; |
| +} |
| + |
| +void ExistingUserView::ContentsChanged(views::Textfield* sender, |
| + const string16& new_contents) { |
| +} |
| + |
| +void ExistingUserView::EnableInputControls(bool enabled) { |
| + password_field_->SetEnabled(enabled); |
| +} |
| + |
| +void ExistingUserView::ClearAndFocusControls() { |
| + ClearAndFocusPassword(); |
| +} |
| + |
| +void ExistingUserView::ClearAndFocusPassword() { |
| + password_field_->SetText(string16()); |
| + FocusPasswordField(); |
| +} |
| + |
| void ExistingUserView::ViewHierarchyChanged(bool is_add, |
| views::View* parent, |
| views::View* child) { |
| @@ -105,9 +139,16 @@ void ExistingUserView::ViewHierarchyChanged(bool is_add, |
| } |
| void ExistingUserView::FocusPasswordField() { |
| - if (GetFocusManager()) { |
| - password_field()->RequestFocus(); |
| - } |
| + password_field_->RequestFocus(); |
| +} |
| + |
| +gfx::Rect ExistingUserView::GetMainInputScreenBounds() const { |
| + return password_field_->GetScreenBounds(); |
| +} |
| + |
| +bool ExistingUserView::UseCustomBoundsForThrobber( |
| + const gfx::Size& throbber, gfx::Rect* bounds) { |
| + return false; |
| } |
| void ExistingUserView::OnLocaleChanged() { |