diff options
author | avayvod@chromium.org <avayvod@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-03 10:09:39 +0000 |
---|---|---|
committer | avayvod@chromium.org <avayvod@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-03 10:09:39 +0000 |
commit | b15ffb1890bbfdfcb9c646e122dec09829bcaade (patch) | |
tree | 13b5383de488610d6c3583f7304128c4bc12e50c | |
parent | 4c93d22d5828aefb286b9e36f3f189e39fc09730 (diff) | |
download | chromium_src-b15ffb1890bbfdfcb9c646e122dec09829bcaade.zip chromium_src-b15ffb1890bbfdfcb9c646e122dec09829bcaade.tar.gz chromium_src-b15ffb1890bbfdfcb9c646e122dec09829bcaade.tar.bz2 |
Landing http://codereview.chromium.org/3032043/show for Denis (dilmah).
BUG=http://crosbug.com/4411
TEST=On login screen change the language through new user pod and verify that for existing user pods text is translated to the new language.
Review URL: http://codereview.chromium.org/3047044
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@54731 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/chromeos/login/existing_user_view.cc | 98 | ||||
-rw-r--r-- | chrome/browser/chromeos/login/existing_user_view.h | 54 | ||||
-rw-r--r-- | chrome/browser/chromeos/login/user_controller.cc | 110 | ||||
-rw-r--r-- | chrome/browser/chromeos/login/user_controller.h | 10 | ||||
-rw-r--r-- | chrome/browser/chromeos/login/user_view.cc | 4 | ||||
-rw-r--r-- | chrome/browser/chromeos/login/user_view.h | 1 | ||||
-rw-r--r-- | chrome/chrome_browser.gypi | 2 |
7 files changed, 181 insertions, 98 deletions
diff --git a/chrome/browser/chromeos/login/existing_user_view.cc b/chrome/browser/chromeos/login/existing_user_view.cc new file mode 100644 index 0000000..45c4176 --- /dev/null +++ b/chrome/browser/chromeos/login/existing_user_view.cc @@ -0,0 +1,98 @@ +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/chromeos/login/existing_user_view.h" + +#include "app/l10n_util.h" +#include "chrome/browser/chromeos/login/helper.h" +#include "chrome/browser/chromeos/login/user_controller.h" +#include "grit/generated_resources.h" +#include "views/grid_layout.h" + +namespace chromeos { + +using login::kBorderSize; +using views::GridLayout; + +// NativeButton that will always return focus to password field. +class UserEntryNativeButton : public views::NativeButton { + public: + UserEntryNativeButton(UserController* controller, + views::ButtonListener* listener, + const std::wstring& label) + : NativeButton(listener, label), + controller_(controller) {} + + // Overridden from View: + virtual void DidGainFocus() { + controller_->FocusPasswordField(); + } + + private: + UserController* controller_; + + DISALLOW_COPY_AND_ASSIGN(UserEntryNativeButton); +}; + +// Textfield with custom processing for Tab/Shift+Tab to select entries. +class UserEntryTextfield : public views::Textfield { + public: + UserEntryTextfield(UserController* controller, + views::Textfield::StyleFlags style) + : Textfield(style), + controller_(controller) {} + + // Overridden from View: + virtual bool OnKeyPressed(const views::KeyEvent& e) { + if (e.GetKeyCode() == base::VKEY_TAB) { + int index = controller_->user_index() + (e.IsShiftDown() ? -1 : 1); + controller_->SelectUser(index); + return true; + } else { + return false; + } + } + + // Overridden from views::Textfield: + virtual bool SkipDefaultKeyEventProcessing(const views::KeyEvent& e) { + if (e.GetKeyCode() == base::VKEY_TAB) + return true; + else + return views::Textfield::SkipDefaultKeyEventProcessing(e); + } + + private: + UserController* controller_; + + DISALLOW_COPY_AND_ASSIGN(UserEntryTextfield); +}; + +void ExistingUserView::RecreateFields() { + delete password_field_; + password_field_ = new UserEntryTextfield(user_controller_, + views::Textfield::STYLE_PASSWORD); + password_field_->set_text_to_display_when_empty( + l10n_util::GetStringUTF16(IDS_LOGIN_EMPTY_PASSWORD_TEXT)); + password_field_->SetController(user_controller_); + delete submit_button_; + submit_button_ = new UserEntryNativeButton( + user_controller_, user_controller_, + l10n_util::GetString(IDS_LOGIN_BUTTON)); + submit_button_->SetFocusable(false); + GridLayout* layout = new GridLayout(this); + views::ColumnSet* column_set = layout->AddColumnSet(0); + column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 1, + GridLayout::USE_PREF, 0, 0); + column_set->AddPaddingColumn(0, kBorderSize); + column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 0, + GridLayout::USE_PREF, 0, 0); + layout->StartRow(0, 0); + layout->AddView(password_field_); + layout->AddView(submit_button_); + SetLayoutManager(layout); + layout->Layout(this); + SchedulePaint(); +} + +} // namespace chromeos diff --git a/chrome/browser/chromeos/login/existing_user_view.h b/chrome/browser/chromeos/login/existing_user_view.h new file mode 100644 index 0000000..0d62f62 --- /dev/null +++ b/chrome/browser/chromeos/login/existing_user_view.h @@ -0,0 +1,54 @@ +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_CHROMEOS_LOGIN_EXISTING_USER_VIEW_H_ +#define CHROME_BROWSER_CHROMEOS_LOGIN_EXISTING_USER_VIEW_H_ +#pragma once + +#include "views/controls/button/native_button.h" +#include "views/controls/textfield/textfield.h" +#include "views/view.h" + +namespace chromeos { + +class UserController; + +class ExistingUserView : public views::View { + public: + explicit ExistingUserView(UserController* uc) + : password_field_(NULL), + submit_button_(NULL), + user_controller_(uc) {} + + void RecreateFields(); + + views::Textfield* password_field() { + return password_field_; + } + + views::NativeButton* submit_button() { + return submit_button_; + } + + protected: + // views::View overrides: + virtual void OnLocaleChanged() { + RecreateFields(); + } + + // For editing the password. + views::Textfield* password_field_; + + // Button to start login. + views::NativeButton* submit_button_; + + UserController* user_controller_; + + DISALLOW_COPY_AND_ASSIGN(ExistingUserView); +}; + +} // chromeos + +#endif // CHROME_BROWSER_CHROMEOS_LOGIN_EXISTING_USER_VIEW_H_ + diff --git a/chrome/browser/chromeos/login/user_controller.cc b/chrome/browser/chromeos/login/user_controller.cc index e7de077..5dee1ac 100644 --- a/chrome/browser/chromeos/login/user_controller.cc +++ b/chrome/browser/chromeos/login/user_controller.cc @@ -10,18 +10,19 @@ #include "app/l10n_util.h" #include "app/resource_bundle.h" #include "base/utf_string_conversions.h" +#include "chrome/browser/chromeos/login/existing_user_view.h" #include "chrome/browser/chromeos/login/helper.h" #include "chrome/browser/chromeos/login/user_view.h" #include "chrome/browser/chromeos/login/wizard_controller.h" #include "chrome/common/notification_service.h" #include "chrome/common/notification_type.h" +#include "cros/chromeos_wm_ipc_enums.h" #include "gfx/canvas.h" #include "grit/generated_resources.h" #include "grit/theme_resources.h" -#include "cros/chromeos_wm_ipc_enums.h" #include "views/background.h" -#include "views/controls/label.h" #include "views/controls/button/native_button.h" +#include "views/controls/label.h" #include "views/grid_layout.h" #include "views/widget/root_view.h" #include "views/widget/widget_gtk.h" @@ -82,63 +83,6 @@ std::string GetNameTooltip(const UserManager::User& user) { domain.c_str()); } -// NativeButton that will always return focus to password field. -class UserEntryNativeButton : public views::NativeButton { - public: - UserEntryNativeButton(UserController* controller, - views::ButtonListener* listener, - const std::wstring& label) - : NativeButton(listener, label), - controller_(controller) {} - - // Overridden from View: - virtual void DidGainFocus() { - controller_->FocusPasswordField(); - } - - private: - UserController* controller_; - - DISALLOW_COPY_AND_ASSIGN(UserEntryNativeButton); -}; - -// Textfield with custom processing for Tab/Shift+Tab to select entries. -class UserEntryTextfield : public views::Textfield { - public: - explicit UserEntryTextfield(UserController* controller) - : Textfield(), - controller_(controller) {} - - UserEntryTextfield(UserController* controller, - views::Textfield::StyleFlags style) - : Textfield(style), - controller_(controller) {} - - // Overridden from View: - virtual bool OnKeyPressed(const views::KeyEvent& e) { - if (e.GetKeyCode() == base::VKEY_TAB) { - int index = controller_->user_index() + (e.IsShiftDown() ? -1 : 1); - controller_->SelectUser(index); - return true; - } else { - return false; - } - } - - // Overridden from views::Textfield: - virtual bool SkipDefaultKeyEventProcessing(const views::KeyEvent& e) { - if (e.GetKeyCode() == base::VKEY_TAB) - return true; - else - return views::Textfield::SkipDefaultKeyEventProcessing(e); - } - - private: - UserController* controller_; - - DISALLOW_COPY_AND_ASSIGN(UserEntryTextfield); -}; - } // namespace using login::kBackgroundColor; @@ -158,8 +102,6 @@ UserController::UserController(Delegate* delegate) is_guest_(true), show_name_tooltip_(false), delegate_(delegate), - password_field_(NULL), - submit_button_(NULL), controls_window_(NULL), image_window_(NULL), border_window_(NULL), @@ -167,6 +109,7 @@ UserController::UserController(Delegate* delegate) unselected_label_window_(NULL), user_view_(NULL), new_user_view_(NULL), + existing_user_view_(NULL), label_view_(NULL), unselected_label_view_(NULL) { registrar_.Add( @@ -183,8 +126,6 @@ UserController::UserController(Delegate* delegate, show_name_tooltip_(false), user_(user), delegate_(delegate), - password_field_(NULL), - submit_button_(NULL), controls_window_(NULL), image_window_(NULL), border_window_(NULL), @@ -192,6 +133,7 @@ UserController::UserController(Delegate* delegate, unselected_label_window_(NULL), user_view_(NULL), new_user_view_(NULL), + existing_user_view_(NULL), label_view_(NULL), unselected_label_view_(NULL) { registrar_.Add( @@ -220,8 +162,8 @@ void UserController::Init(int index, int total_user_count) { void UserController::SetPasswordEnabled(bool enable) { DCHECK(!is_guest_); - password_field_->SetEnabled(enable); - submit_button_->SetEnabled(enable); + existing_user_view_->password_field()->SetEnabled(enable); + existing_user_view_->submit_button()->SetEnabled(enable); enable ? user_view_->StopThrobber() : user_view_->StartThrobber(); } @@ -229,7 +171,7 @@ void UserController::ClearAndEnablePassword() { if (is_guest_) { new_user_view_->ClearAndEnablePassword(); } else { - password_field_->SetText(string16()); + existing_user_view_->password_field()->SetText(string16()); SetPasswordEnabled(true); FocusPasswordField(); } @@ -293,7 +235,7 @@ void UserController::Login() { // Delegate will reenable as necessary. SetPasswordEnabled(false); - delegate_->Login(this, password_field_->text()); + delegate_->Login(this, existing_user_view_->password_field()->text()); } void UserController::IsActiveChanged(bool active) { @@ -337,27 +279,9 @@ WidgetGtk* UserController::CreateControlsWindow(int index, int* height) { new_user_view_->Init(); control_view = new_user_view_; } else { - password_field_ = new UserEntryTextfield(this, - views::Textfield::STYLE_PASSWORD); - password_field_->set_text_to_display_when_empty( - l10n_util::GetStringUTF16(IDS_LOGIN_EMPTY_PASSWORD_TEXT)); - password_field_->SetController(this); - submit_button_ = new UserEntryNativeButton( - this, this, l10n_util::GetString(IDS_LOGIN_BUTTON)); - submit_button_->SetFocusable(false); - control_view = new views::View(); - GridLayout* layout = new GridLayout(control_view); - control_view->SetLayoutManager(layout); - views::ColumnSet* column_set = layout->AddColumnSet(0); - column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 1, - GridLayout::USE_PREF, 0, 0); - column_set->AddPaddingColumn(0, kBorderSize); - column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 0, - GridLayout::USE_PREF, 0, 0); - - layout->StartRow(0, 0); - layout->AddView(password_field_); - layout->AddView(submit_button_); + existing_user_view_ = new ExistingUserView(this); + existing_user_view_->RecreateFields(); + control_view = existing_user_view_; } *height = kControlsHeight; @@ -395,7 +319,7 @@ WidgetGtk* UserController::CreateImageWindow(int index) { void UserController::CreateBorderWindow(int index, int total_user_count, int controls_height) { - // Guest login controls window is much higher than exsisting user's controls + // Guest login controls window is much higher than existing user's controls // window so window manager will place the control instead of image window. int width = kUserImageSize + kBorderSize * 2; int height = kBorderSize * 2 + controls_height; @@ -458,9 +382,11 @@ gfx::Rect UserController::GetScreenBounds() const { if (is_guest_) { return new_user_view_->GetPasswordBounds(); } else { - gfx::Rect screen_bounds(password_field_->bounds()); + gfx::Rect screen_bounds(existing_user_view_->password_field()->bounds()); gfx::Point origin(screen_bounds.origin()); - views::View::ConvertPointToScreen(password_field_->GetParent(), &origin); + views::View::ConvertPointToScreen( + existing_user_view_->password_field()->GetParent(), + &origin); screen_bounds.set_origin(origin); return screen_bounds; } @@ -497,7 +423,7 @@ void UserController::SelectUser(int index) { } void UserController::FocusPasswordField() { - password_field_->RequestFocus(); + existing_user_view_->password_field()->RequestFocus(); } } // namespace chromeos diff --git a/chrome/browser/chromeos/login/user_controller.h b/chrome/browser/chromeos/login/user_controller.h index 82ac8a9..18b88a3 100644 --- a/chrome/browser/chromeos/login/user_controller.h +++ b/chrome/browser/chromeos/login/user_controller.h @@ -27,6 +27,7 @@ class WidgetGtk; namespace chromeos { class UserView; +class ExistingUserView; // UserController manages the set of windows needed to login a single existing // user or first time login for a new user. ExistingUserController creates @@ -179,12 +180,6 @@ class UserController : public views::ButtonListener, Delegate* delegate_; - // For editing the password. - views::Textfield* password_field_; - - // Button to start login. - views::NativeButton* submit_button_; - // A window is used to represent the individual chunks. views::WidgetGtk* controls_window_; views::WidgetGtk* image_window_; @@ -198,6 +193,9 @@ class UserController : public views::ButtonListener, // View that is used for new user login. NewUserView* new_user_view_; + // View that is used for existing user login. + ExistingUserView* existing_user_view_; + // Views that show display name of the user. views::Label* label_view_; views::Label* unselected_label_view_; diff --git a/chrome/browser/chromeos/login/user_view.cc b/chrome/browser/chromeos/login/user_view.cc index 10db8b0..f880bd3 100644 --- a/chrome/browser/chromeos/login/user_view.cc +++ b/chrome/browser/chromeos/login/user_view.cc @@ -229,4 +229,8 @@ void UserView::ExecuteCommand(int command_id) { } } +void UserView::OnLocaleChanged() { + BuildMenu(); +} + } // namespace chromeos diff --git a/chrome/browser/chromeos/login/user_view.h b/chrome/browser/chromeos/login/user_view.h index 616ea94..5b4b33f 100644 --- a/chrome/browser/chromeos/login/user_view.h +++ b/chrome/browser/chromeos/login/user_view.h @@ -53,6 +53,7 @@ class UserView : public views::View, // view::View overrides. virtual gfx::Size GetPreferredSize(); + virtual void OnLocaleChanged(); // Sets the user's image. void SetImage(const SkBitmap& image); diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index bf49a5c..6e434c6 100644 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -463,6 +463,8 @@ 'browser/chromeos/login/eula_view.h', 'browser/chromeos/login/existing_user_controller.cc', 'browser/chromeos/login/existing_user_controller.h', + 'browser/chromeos/login/existing_user_view.cc', + 'browser/chromeos/login/existing_user_view.h', 'browser/chromeos/login/image_decoder.cc', 'browser/chromeos/login/image_decoder.h', 'browser/chromeos/login/image_downloader.cc', |