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/language_switch_menu.h" | 12 #include "chrome/browser/chromeos/login/language_switch_menu.h" |
13 #include "chrome/browser/chromeos/login/user_input.h" | |
13 #include "views/accelerator.h" | 14 #include "views/accelerator.h" |
14 #include "views/controls/button/button.h" | 15 #include "views/controls/button/button.h" |
15 #include "views/controls/button/menu_button.h" | 16 #include "views/controls/button/menu_button.h" |
16 #include "views/controls/link.h" | 17 #include "views/controls/link.h" |
17 #include "views/controls/textfield/textfield.h" | 18 #include "views/controls/textfield/textfield.h" |
18 #include "views/view.h" | 19 #include "views/view.h" |
19 | 20 |
20 namespace views { | 21 namespace views { |
21 class Label; | 22 class Label; |
22 class NativeButton; | 23 class NativeButton; |
23 class Throbber; | 24 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 UserInput, |
32 public views::View, | |
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 13 matching lines...) Expand all Loading... | |
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); |
118 | 108 |
119 virtual bool AcceleratorPressed(const views::Accelerator& accelerator); | 109 virtual bool AcceleratorPressed(const views::Accelerator& accelerator); |
120 | 110 |
111 // Implements UserInput: | |
112 virtual void EnableInputControls(bool enabled); | |
113 | |
whywhat
2010/12/09 16:20:18
Blank lines here are not needed.
altimofeev
2010/12/10 16:37:40
Done.
| |
114 virtual void ClearAndFocusControls(); | |
115 | |
116 virtual void ClearAndFocusPassword(); | |
117 | |
118 virtual gfx::Rect GetControlWithErrorBounds() const; | |
119 | |
120 virtual bool UseCustomBoundsForThrobber(const gfx::Size& throbber, | |
121 gfx::Rect* bounds) const; | |
122 | |
121 protected: | 123 protected: |
122 // views::View overrides: | 124 // views::View overrides: |
123 virtual void ViewHierarchyChanged(bool is_add, | 125 virtual void ViewHierarchyChanged(bool is_add, |
124 views::View *parent, | 126 views::View *parent, |
125 views::View *child); | 127 views::View *child); |
126 virtual void NativeViewHierarchyChanged(bool attached, | 128 virtual void NativeViewHierarchyChanged(bool attached, |
127 gfx::NativeView native_view, | 129 gfx::NativeView native_view, |
128 views::RootView* root_view); | 130 views::RootView* root_view); |
129 virtual void OnLocaleChanged(); | 131 virtual void OnLocaleChanged(); |
130 void AddChildView(View* view); | 132 void AddChildView(View* view); |
131 | 133 |
132 private: | 134 private: |
133 // Enables/disables input controls (textfields, buttons). | |
134 void EnableInputControls(bool enabled); | |
135 void FocusFirstField(); | 135 void FocusFirstField(); |
136 | 136 |
137 // Creates Link control and adds it as a child. | 137 // Creates Link control and adds it as a child. |
138 void InitLink(views::Link** link); | 138 void InitLink(views::Link** link); |
139 | 139 |
140 // Delete and recreate native controls that fail to update preferred size | 140 // Delete and recreate native controls that fail to update preferred size |
141 // after text/locale update. | 141 // after text/locale update. |
142 void RecreatePeculiarControls(); | 142 void RecreatePeculiarControls(); |
143 | 143 |
144 // Enable or disable the |sign_in_button_| based on the contents of the | 144 // 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_; | 158 views::Label* title_label_; |
159 views::Label* title_hint_label_; | 159 views::Label* title_hint_label_; |
160 views::View* splitter_up1_; | 160 views::View* splitter_up1_; |
161 views::View* splitter_up2_; | 161 views::View* splitter_up2_; |
162 views::View* splitter_down1_; | 162 views::View* splitter_down1_; |
163 views::View* splitter_down2_; | 163 views::View* splitter_down2_; |
164 views::NativeButton* sign_in_button_; | 164 views::NativeButton* sign_in_button_; |
165 views::Link* create_account_link_; | 165 views::Link* create_account_link_; |
166 views::Link* guest_link_; | 166 views::Link* guest_link_; |
167 views::MenuButton* languages_menubutton_; | 167 views::MenuButton* languages_menubutton_; |
168 views::Throbber* throbber_; | |
169 | 168 |
170 views::Accelerator accel_focus_pass_; | 169 views::Accelerator accel_focus_pass_; |
171 views::Accelerator accel_focus_user_; | 170 views::Accelerator accel_focus_user_; |
172 views::Accelerator accel_login_off_the_record_; | 171 views::Accelerator accel_login_off_the_record_; |
173 views::Accelerator accel_enable_accessibility_; | 172 views::Accelerator accel_enable_accessibility_; |
174 | 173 |
175 // Notifications receiver. | 174 // Notifications receiver. |
176 Delegate* delegate_; | 175 Delegate* delegate_; |
177 | 176 |
178 ScopedRunnableMethodFactory<NewUserView> focus_grabber_factory_; | 177 ScopedRunnableMethodFactory<NewUserView> focus_grabber_factory_; |
(...skipping 14 matching lines...) Expand all Loading... | |
193 bool need_guest_link_; | 192 bool need_guest_link_; |
194 | 193 |
195 // Whether create account link is needed. Set to false for now but we may | 194 // Whether create account link is needed. Set to false for now but we may |
196 // need it back in near future. | 195 // need it back in near future. |
197 bool need_create_account_; | 196 bool need_create_account_; |
198 | 197 |
199 // Ordinal position of controls inside view layout. | 198 // Ordinal position of controls inside view layout. |
200 int languages_menubutton_order_; | 199 int languages_menubutton_order_; |
201 int sign_in_button_order_; | 200 int sign_in_button_order_; |
202 | 201 |
202 // Throbber's center y-position. | |
203 int throbber_center_y_; | |
204 | |
205 // Throbber right position. | |
206 int throbber_right_; | |
207 | |
203 FRIEND_TEST_ALL_PREFIXES(LoginScreenTest, IncognitoLogin); | 208 FRIEND_TEST_ALL_PREFIXES(LoginScreenTest, IncognitoLogin); |
204 friend class LoginScreenTest; | 209 friend class LoginScreenTest; |
205 | 210 |
206 DISALLOW_COPY_AND_ASSIGN(NewUserView); | 211 DISALLOW_COPY_AND_ASSIGN(NewUserView); |
207 }; | 212 }; |
208 | 213 |
209 } // namespace chromeos | 214 } // namespace chromeos |
210 | 215 |
211 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_NEW_USER_VIEW_H_ | 216 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_NEW_USER_VIEW_H_ |
OLD | NEW |