| 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 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_NEW_USER_VIEW_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_NEW_USER_VIEW_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_NEW_USER_VIEW_H_ | 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_NEW_USER_VIEW_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/task.h" | 11 #include "base/task.h" |
| 12 #include "chrome/browser/chromeos/login/helper.h" |
| 12 #include "chrome/browser/chromeos/login/language_switch_menu.h" | 13 #include "chrome/browser/chromeos/login/language_switch_menu.h" |
| 14 #include "chrome/browser/chromeos/login/user_input.h" |
| 13 #include "views/accelerator.h" | 15 #include "views/accelerator.h" |
| 14 #include "views/controls/button/button.h" | 16 #include "views/controls/button/button.h" |
| 15 #include "views/controls/button/menu_button.h" | 17 #include "views/controls/button/menu_button.h" |
| 16 #include "views/controls/link.h" | 18 #include "views/controls/link.h" |
| 17 #include "views/controls/textfield/textfield.h" | 19 #include "views/controls/textfield/textfield.h" |
| 18 #include "views/view.h" | 20 #include "views/view.h" |
| 19 | 21 |
| 20 namespace views { | 22 namespace views { |
| 21 class Label; | 23 class Label; |
| 22 class NativeButton; | 24 class NativeButton; |
| 23 class Throbber; | |
| 24 } // namespace views | 25 } // namespace views |
| 25 | 26 |
| 26 namespace chromeos { | 27 namespace chromeos { |
| 27 | 28 |
| 28 // View that is used for new user login. It asks for username and password, | 29 // View that is used for new user login. It asks for username and password, |
| 29 // allows to specify language preferences or initiate new account creation. | 30 // allows to specify language preferences or initiate new account creation. |
| 30 class NewUserView : public views::View, | 31 class NewUserView : public ThrobberHostView, |
| 32 public UserInput, |
| 31 public views::Textfield::Controller, | 33 public views::Textfield::Controller, |
| 32 public views::LinkController, | 34 public views::LinkController, |
| 33 public views::ButtonListener { | 35 public views::ButtonListener { |
| 34 public: | 36 public: |
| 35 // Delegate class to get notifications from the view. | 37 // Delegate class to get notifications from the view. |
| 36 class Delegate { | 38 class Delegate { |
| 37 public: | 39 public: |
| 38 virtual ~Delegate() {} | 40 virtual ~Delegate() {} |
| 39 | 41 |
| 40 // User provided |username|, |password| and initiated login. | 42 // User provided |username|, |password| and initiated login. |
| (...skipping 25 matching lines...) Expand all Loading... |
| 66 bool need_guest_link); | 68 bool need_guest_link); |
| 67 | 69 |
| 68 virtual ~NewUserView(); | 70 virtual ~NewUserView(); |
| 69 | 71 |
| 70 // Initialize view layout. | 72 // Initialize view layout. |
| 71 void Init(); | 73 void Init(); |
| 72 | 74 |
| 73 // Update strings from the resources. Executed on language change. | 75 // Update strings from the resources. Executed on language change. |
| 74 void UpdateLocalizedStrings(); | 76 void UpdateLocalizedStrings(); |
| 75 | 77 |
| 76 // Resets password text and sets the enabled state of the password. | |
| 77 void ClearAndEnablePassword(); | |
| 78 | |
| 79 // Resets password and username text and focuses on username. | |
| 80 void ClearAndEnableFields(); | |
| 81 | |
| 82 // Starts throbber shown during login. | |
| 83 void StartThrobber(); | |
| 84 | |
| 85 // Stops throbber shown during login. | |
| 86 void StopThrobber(); | |
| 87 | |
| 88 // Returns bounds of password field in screen coordinates. | 78 // Returns bounds of password field in screen coordinates. |
| 89 gfx::Rect GetPasswordBounds() const; | 79 gfx::Rect GetPasswordBounds() const; |
| 90 | 80 |
| 91 // Returns bounds of username field in screen coordinates. | 81 // Returns bounds of username field in screen coordinates. |
| 92 gfx::Rect GetUsernameBounds() const; | 82 gfx::Rect GetUsernameBounds() const; |
| 93 | 83 |
| 94 // Overridden from views::View: | 84 // Overridden from views::View: |
| 95 virtual gfx::Size GetPreferredSize(); | 85 virtual gfx::Size GetPreferredSize(); |
| 96 virtual void Layout(); | 86 virtual void Layout(); |
| 97 virtual void RequestFocus(); | 87 virtual void RequestFocus(); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 108 virtual bool HandleKeystroke(views::Textfield* sender, | 98 virtual bool HandleKeystroke(views::Textfield* sender, |
| 109 const views::Textfield::Keystroke& keystroke); | 99 const views::Textfield::Keystroke& keystroke); |
| 110 virtual void ContentsChanged(views::Textfield* sender, | 100 virtual void ContentsChanged(views::Textfield* sender, |
| 111 const string16& new_contents); | 101 const string16& new_contents); |
| 112 | 102 |
| 113 // Overridden from views::ButtonListener. | 103 // Overridden from views::ButtonListener. |
| 114 virtual void ButtonPressed(views::Button* sender, const views::Event& event); | 104 virtual void ButtonPressed(views::Button* sender, const views::Event& event); |
| 115 | 105 |
| 116 // Overridden from views::LinkController. | 106 // Overridden from views::LinkController. |
| 117 virtual void LinkActivated(views::Link* source, int event_flags); | 107 virtual void LinkActivated(views::Link* source, int event_flags); |
| 108 virtual bool AcceleratorPressed(const views::Accelerator& accelerator); |
| 118 | 109 |
| 119 virtual bool AcceleratorPressed(const views::Accelerator& accelerator); | 110 // Overridden from ThrobberHostView: |
| 111 virtual gfx::Rect CalculateThrobberBounds(views::Throbber* throbber); |
| 112 |
| 113 // Overridden from UserInput: |
| 114 virtual void EnableInputControls(bool enabled); |
| 115 virtual void ClearAndFocusControls(); |
| 116 virtual void ClearAndFocusPassword(); |
| 117 virtual gfx::Rect GetMainInputScreenBounds() const; |
| 120 | 118 |
| 121 protected: | 119 protected: |
| 122 // views::View overrides: | 120 // views::View overrides: |
| 123 virtual void ViewHierarchyChanged(bool is_add, | 121 virtual void ViewHierarchyChanged(bool is_add, |
| 124 views::View *parent, | 122 views::View *parent, |
| 125 views::View *child); | 123 views::View *child); |
| 126 virtual void NativeViewHierarchyChanged(bool attached, | 124 virtual void NativeViewHierarchyChanged(bool attached, |
| 127 gfx::NativeView native_view, | 125 gfx::NativeView native_view, |
| 128 views::RootView* root_view); | 126 views::RootView* root_view); |
| 129 virtual void OnLocaleChanged(); | 127 virtual void OnLocaleChanged(); |
| 130 void AddChildView(View* view); | 128 void AddChildView(View* view); |
| 131 | 129 |
| 132 private: | 130 private: |
| 133 // Enables/disables input controls (textfields, buttons). | |
| 134 void EnableInputControls(bool enabled); | |
| 135 void FocusFirstField(); | 131 void FocusFirstField(); |
| 136 | 132 |
| 137 // Creates Link control and adds it as a child. | 133 // Creates Link control and adds it as a child. |
| 138 void InitLink(views::Link** link); | 134 void InitLink(views::Link** link); |
| 139 | 135 |
| 140 // Delete and recreate native controls that fail to update preferred size | 136 // Delete and recreate native controls that fail to update preferred size |
| 141 // after text/locale update. | 137 // after text/locale update. |
| 142 void RecreatePeculiarControls(); | 138 void RecreatePeculiarControls(); |
| 143 | 139 |
| 144 // Enable or disable the |sign_in_button_| based on the contents of the | 140 // Enable or disable the |sign_in_button_| based on the contents of the |
| (...skipping 13 matching lines...) Expand all Loading... |
| 158 views::Label* title_label_; | 154 views::Label* title_label_; |
| 159 views::Label* title_hint_label_; | 155 views::Label* title_hint_label_; |
| 160 views::View* splitter_up1_; | 156 views::View* splitter_up1_; |
| 161 views::View* splitter_up2_; | 157 views::View* splitter_up2_; |
| 162 views::View* splitter_down1_; | 158 views::View* splitter_down1_; |
| 163 views::View* splitter_down2_; | 159 views::View* splitter_down2_; |
| 164 views::NativeButton* sign_in_button_; | 160 views::NativeButton* sign_in_button_; |
| 165 views::Link* create_account_link_; | 161 views::Link* create_account_link_; |
| 166 views::Link* guest_link_; | 162 views::Link* guest_link_; |
| 167 views::MenuButton* languages_menubutton_; | 163 views::MenuButton* languages_menubutton_; |
| 168 views::Throbber* throbber_; | |
| 169 | 164 |
| 170 views::Accelerator accel_focus_pass_; | 165 views::Accelerator accel_focus_pass_; |
| 171 views::Accelerator accel_focus_user_; | 166 views::Accelerator accel_focus_user_; |
| 172 views::Accelerator accel_login_off_the_record_; | 167 views::Accelerator accel_login_off_the_record_; |
| 173 views::Accelerator accel_enable_accessibility_; | 168 views::Accelerator accel_enable_accessibility_; |
| 174 | 169 |
| 175 // Notifications receiver. | 170 // Notifications receiver. |
| 176 Delegate* delegate_; | 171 Delegate* delegate_; |
| 177 | 172 |
| 178 ScopedRunnableMethodFactory<NewUserView> focus_grabber_factory_; | 173 ScopedRunnableMethodFactory<NewUserView> focus_grabber_factory_; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 202 | 197 |
| 203 FRIEND_TEST_ALL_PREFIXES(LoginScreenTest, IncognitoLogin); | 198 FRIEND_TEST_ALL_PREFIXES(LoginScreenTest, IncognitoLogin); |
| 204 friend class LoginScreenTest; | 199 friend class LoginScreenTest; |
| 205 | 200 |
| 206 DISALLOW_COPY_AND_ASSIGN(NewUserView); | 201 DISALLOW_COPY_AND_ASSIGN(NewUserView); |
| 207 }; | 202 }; |
| 208 | 203 |
| 209 } // namespace chromeos | 204 } // namespace chromeos |
| 210 | 205 |
| 211 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_NEW_USER_VIEW_H_ | 206 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_NEW_USER_VIEW_H_ |
| OLD | NEW |