| Index: chrome/browser/chromeos/login/user_controller.cc
|
| diff --git a/chrome/browser/chromeos/login/user_controller.cc b/chrome/browser/chromeos/login/user_controller.cc
|
| index 639909cc74cbb1fd7b894b010d4b1ccff4522f0e..ce03c43049f989c1c217b49cd5b789f29854356a 100644
|
| --- a/chrome/browser/chromeos/login/user_controller.cc
|
| +++ b/chrome/browser/chromeos/login/user_controller.cc
|
| @@ -29,6 +29,7 @@
|
| #include "views/background.h"
|
| #include "views/controls/button/native_button.h"
|
| #include "views/controls/label.h"
|
| +#include "views/controls/throbber.h"
|
| #include "views/grid_layout.h"
|
| #include "views/painter.h"
|
| #include "views/screen.h"
|
| @@ -70,7 +71,7 @@ class ClickNotifyingWidget : public views::WidgetGtk {
|
| private:
|
| gboolean OnButtonPress(GtkWidget* widget, GdkEventButton* event) {
|
| if (!controller_->is_user_selected())
|
| - controller_->SelectUser(controller_->user_index());
|
| + controller_->SelectUserRelative(0);
|
|
|
| return views::WidgetGtk::OnButtonPress(widget, event);
|
| }
|
| @@ -144,11 +145,9 @@ UserController::UserController(Delegate* delegate, bool is_guest)
|
| label_window_(NULL),
|
| unselected_label_window_(NULL),
|
| user_view_(NULL),
|
| - new_user_view_(NULL),
|
| - existing_user_view_(NULL),
|
| - guest_user_view_(NULL),
|
| label_view_(NULL),
|
| unselected_label_view_(NULL),
|
| + throbber_manager_(new ThrobberManager()),
|
| method_factory_(this) {
|
| registrar_.Add(
|
| this,
|
| @@ -174,11 +173,9 @@ UserController::UserController(Delegate* delegate,
|
| label_window_(NULL),
|
| unselected_label_window_(NULL),
|
| user_view_(NULL),
|
| - new_user_view_(NULL),
|
| - existing_user_view_(NULL),
|
| - guest_user_view_(NULL),
|
| label_view_(NULL),
|
| unselected_label_view_(NULL),
|
| + throbber_manager_(new ThrobberManager()),
|
| method_factory_(this) {
|
| DCHECK(!user.email().empty());
|
| registrar_.Add(
|
| @@ -213,18 +210,23 @@ void UserController::Init(int index,
|
| CreateLabelWindow(index, WM_IPC_WINDOW_LOGIN_UNSELECTED_LABEL);
|
| }
|
|
|
| -void UserController::SetPasswordEnabled(bool enable) {
|
| - DCHECK(!is_new_user_);
|
| - existing_user_view_->password_field()->SetEnabled(enable);
|
| - if (enable) {
|
| - user_view_->StopThrobber();
|
| - delegate_->SetStatusAreaEnabled(enable);
|
| +void UserController::StartThrobber() {
|
| + views::Throbber* throbber = CreateDefaultSmoothedThrobber();
|
| + gfx::Rect bounds;
|
| + if (user_input_->UseCustomBoundsForThrobber(
|
| + throbber->GetPreferredSize(), &bounds)) {
|
| + throbber_manager_->CreateAndStart(controls_window_, throbber, bounds);
|
| } else {
|
| - delegate_->SetStatusAreaEnabled(enable);
|
| - user_view_->StartThrobber();
|
| + throbber_manager_->CreateAndStart(controls_window_,
|
| + throbber,
|
| + login::kThrobberRightMargin);
|
| }
|
| }
|
|
|
| +void UserController::StopThrobber() {
|
| + throbber_manager_->StopAndClose();
|
| +}
|
| +
|
| std::wstring UserController::GetNameTooltip() const {
|
| if (is_new_user_)
|
| return l10n_util::GetString(IDS_ADD_USER);
|
| @@ -247,25 +249,22 @@ std::wstring UserController::GetNameTooltip() const {
|
| domain.c_str()));
|
| }
|
|
|
| +void UserController::ClearAndEnableFields() {
|
| + user_input_->ClearAndFocusControls();
|
| + user_input_->EnableInputControls(true);
|
| + SetStatusAreaEnabled(true);
|
| + StopThrobber();
|
| +}
|
| +
|
| void UserController::ClearAndEnablePassword() {
|
| - if (is_new_user_) {
|
| - // TODO(avayvod): This code seems not reachable to me.
|
| - new_user_view_->ClearAndEnablePassword();
|
| - } else {
|
| - existing_user_view_->password_field()->SetText(string16());
|
| - SetPasswordEnabled(true);
|
| - FocusPasswordField();
|
| - }
|
| + user_input_->ClearAndFocusPassword();
|
| + user_input_->EnableInputControls(true);
|
| + SetStatusAreaEnabled(true);
|
| + StopThrobber();
|
| }
|
|
|
| -void UserController::ClearAndEnableFields() {
|
| - if (is_new_user_) {
|
| - new_user_view_->ClearAndEnableFields();
|
| - } else if (is_guest_) {
|
| - guest_user_view_->FocusSignInButton();
|
| - } else {
|
| - ClearAndEnablePassword();
|
| - }
|
| +gfx::Rect UserController::GetMainInputScreenBounds() const {
|
| + return user_input_->GetMainInputScreenBounds();
|
| }
|
|
|
| void UserController::EnableNameTooltip(bool enable) {
|
| @@ -281,32 +280,6 @@ void UserController::EnableNameTooltip(bool enable) {
|
| unselected_label_view_->SetTooltipText(tooltip_text);
|
| }
|
|
|
| -void UserController::ButtonPressed(views::Button* sender,
|
| - const views::Event& event) {
|
| - Login();
|
| -}
|
| -
|
| -bool UserController::HandleKeystroke(
|
| - views::Textfield* sender,
|
| - const views::Textfield::Keystroke& keystroke) {
|
| - if (keystroke.GetKeyboardCode() == app::VKEY_RETURN) {
|
| - Login();
|
| - return true;
|
| - } else if (keystroke.GetKeyboardCode() == app::VKEY_LEFT) {
|
| - SelectUser(user_index() - 1);
|
| - return true;
|
| - } else if (keystroke.GetKeyboardCode() == app::VKEY_RIGHT) {
|
| - SelectUser(user_index() + 1);
|
| - return true;
|
| - }
|
| - delegate_->ClearErrors();
|
| - return false;
|
| -}
|
| -
|
| -void UserController::ContentsChanged(views::Textfield* sender,
|
| - const string16& new_contents) {
|
| -}
|
| -
|
| void UserController::Observe(
|
| NotificationType type,
|
| const NotificationSource& source,
|
| @@ -323,17 +296,6 @@ void UserController::Observe(
|
| user_view_->SetImage(user_.image(), user_.image());
|
| }
|
|
|
| -void UserController::Login() {
|
| - if (is_guest_) {
|
| - delegate_->LoginOffTheRecord();
|
| - } else {
|
| - // Delegate will reenable as necessary.
|
| - SetPasswordEnabled(false);
|
| -
|
| - delegate_->Login(this, existing_user_view_->password_field()->text());
|
| - }
|
| -}
|
| -
|
| void UserController::IsActiveChanged(bool active) {
|
| is_user_selected_ = active;
|
| if (active) {
|
| @@ -375,25 +337,27 @@ WidgetGtk* UserController::CreateControlsWindow(
|
| bool need_browse_without_signin) {
|
| views::View* control_view;
|
| if (is_new_user_) {
|
| - new_user_view_ =
|
| + NewUserView* new_user_view =
|
| new NewUserView(this, true, need_browse_without_signin);
|
| - new_user_view_->Init();
|
| - control_view = new_user_view_;
|
| + new_user_view->Init();
|
| + control_view = new_user_view;
|
| + user_input_ = new_user_view;
|
| } else if (is_guest_) {
|
| - guest_user_view_ = new GuestUserView(this);
|
| - guest_user_view_->RecreateFields();
|
| - control_view = guest_user_view_;
|
| + GuestUserView* guest_user_view = new GuestUserView(this);
|
| + guest_user_view->RecreateFields();
|
| + control_view = guest_user_view;
|
| + user_input_ = guest_user_view;
|
| } else {
|
| - existing_user_view_ = new ExistingUserView(this);
|
| - existing_user_view_->RecreateFields();
|
| - control_view = existing_user_view_;
|
| + ExistingUserView* existing_user_view = new ExistingUserView(this);
|
| + existing_user_view->RecreateFields();
|
| + control_view = existing_user_view;
|
| + user_input_ = existing_user_view;
|
| }
|
|
|
| *height = kControlsHeight;
|
| *width = kUserImageSize;
|
| if (is_new_user_) {
|
| - DCHECK(new_user_view_);
|
| - gfx::Size size = new_user_view_->GetPreferredSize();
|
| + gfx::Size size = control_view->GetPreferredSize();
|
| *width = size.width();
|
| *height = size.height();
|
| }
|
| @@ -523,16 +487,15 @@ WidgetGtk* UserController::CreateLabelWindow(int index,
|
| return window;
|
| }
|
|
|
| -gfx::Rect UserController::GetScreenBounds() const {
|
| - if (is_new_user_)
|
| - return new_user_view_->GetUsernameBounds();
|
| - else
|
| - return existing_user_view_->password_field()->GetScreenBounds();
|
| -}
|
| -
|
| void UserController::OnLogin(const std::string& username,
|
| const std::string& password) {
|
| - user_.set_email(username);
|
| + if (is_new_user_)
|
| + user_.set_email(username);
|
| +
|
| + user_input_->EnableInputControls(false);
|
| + SetStatusAreaEnabled(false);
|
| + StartThrobber();
|
| +
|
| delegate_->Login(this, UTF8ToUTF16(password));
|
| }
|
|
|
| @@ -541,6 +504,10 @@ void UserController::OnCreateAccount() {
|
| }
|
|
|
| void UserController::OnLoginOffTheRecord() {
|
| + user_input_->EnableInputControls(false);
|
| + SetStatusAreaEnabled(false);
|
| + StartThrobber();
|
| +
|
| delegate_->LoginOffTheRecord();
|
| }
|
|
|
| @@ -549,7 +516,7 @@ void UserController::ClearErrors() {
|
| }
|
|
|
| void UserController::NavigateAway() {
|
| - SelectUser(user_index() - 1);
|
| + SelectUserRelative(-1);
|
| }
|
|
|
| void UserController::OnRemoveUser() {
|
| @@ -569,12 +536,8 @@ void UserController::OnRemoveUser() {
|
| delegate_->RemoveUser(this);
|
| }
|
|
|
| -void UserController::SelectUser(int index) {
|
| - delegate_->SelectUser(index);
|
| -}
|
| -
|
| -void UserController::FocusPasswordField() {
|
| - existing_user_view_->FocusPasswordField();
|
| +void UserController::SelectUserRelative(int shift) {
|
| + delegate_->SelectUser(user_index() + shift);
|
| }
|
|
|
| } // namespace chromeos
|
|
|