Chromium Code Reviews

Side by Side Diff: chrome/browser/chromeos/login/new_user_view.h

Issue 5709001: Place the spinner in the right corner of the controls window. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/chrome/browser/chromeos/login
Patch Set: code review Created 10 years ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | | Annotate | Revision Log
OLDNEW
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...)
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...)
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 UserInput:
111 virtual void EnableInputControls(bool enabled);
112 virtual void ClearAndFocusControls();
113 virtual void ClearAndFocusPassword();
114 virtual gfx::Rect GetMainInputScreenBounds() const;
115 virtual bool UseCustomBoundsForThrobber(const gfx::Size& throbber,
116 gfx::Rect* bounds);
120 117
121 protected: 118 protected:
122 // views::View overrides: 119 // views::View overrides:
123 virtual void ViewHierarchyChanged(bool is_add, 120 virtual void ViewHierarchyChanged(bool is_add,
124 views::View *parent, 121 views::View *parent,
125 views::View *child); 122 views::View *child);
126 virtual void NativeViewHierarchyChanged(bool attached, 123 virtual void NativeViewHierarchyChanged(bool attached,
127 gfx::NativeView native_view, 124 gfx::NativeView native_view,
128 views::RootView* root_view); 125 views::RootView* root_view);
129 virtual void OnLocaleChanged(); 126 virtual void OnLocaleChanged();
130 void AddChildView(View* view); 127 void AddChildView(View* view);
131 128
132 private: 129 private:
133 // Enables/disables input controls (textfields, buttons).
134 void EnableInputControls(bool enabled);
135 void FocusFirstField(); 130 void FocusFirstField();
136 131
137 // Creates Link control and adds it as a child. 132 // Creates Link control and adds it as a child.
138 void InitLink(views::Link** link); 133 void InitLink(views::Link** link);
139 134
140 // Delete and recreate native controls that fail to update preferred size 135 // Delete and recreate native controls that fail to update preferred size
141 // after text/locale update. 136 // after text/locale update.
142 void RecreatePeculiarControls(); 137 void RecreatePeculiarControls();
143 138
144 // Enable or disable the |sign_in_button_| based on the contents of the 139 // Enable or disable the |sign_in_button_| based on the contents of the
(...skipping 13 matching lines...)
158 views::Label* title_label_; 153 views::Label* title_label_;
159 views::Label* title_hint_label_; 154 views::Label* title_hint_label_;
160 views::View* splitter_up1_; 155 views::View* splitter_up1_;
161 views::View* splitter_up2_; 156 views::View* splitter_up2_;
162 views::View* splitter_down1_; 157 views::View* splitter_down1_;
163 views::View* splitter_down2_; 158 views::View* splitter_down2_;
164 views::NativeButton* sign_in_button_; 159 views::NativeButton* sign_in_button_;
165 views::Link* create_account_link_; 160 views::Link* create_account_link_;
166 views::Link* guest_link_; 161 views::Link* guest_link_;
167 views::MenuButton* languages_menubutton_; 162 views::MenuButton* languages_menubutton_;
168 views::Throbber* throbber_;
169 163
170 views::Accelerator accel_focus_pass_; 164 views::Accelerator accel_focus_pass_;
171 views::Accelerator accel_focus_user_; 165 views::Accelerator accel_focus_user_;
172 views::Accelerator accel_login_off_the_record_; 166 views::Accelerator accel_login_off_the_record_;
173 views::Accelerator accel_enable_accessibility_; 167 views::Accelerator accel_enable_accessibility_;
174 168
175 // Notifications receiver. 169 // Notifications receiver.
176 Delegate* delegate_; 170 Delegate* delegate_;
177 171
178 ScopedRunnableMethodFactory<NewUserView> focus_grabber_factory_; 172 ScopedRunnableMethodFactory<NewUserView> focus_grabber_factory_;
(...skipping 14 matching lines...)
193 bool need_guest_link_; 187 bool need_guest_link_;
194 188
195 // Whether create account link is needed. Set to false for now but we may 189 // Whether create account link is needed. Set to false for now but we may
196 // need it back in near future. 190 // need it back in near future.
197 bool need_create_account_; 191 bool need_create_account_;
198 192
199 // Ordinal position of controls inside view layout. 193 // Ordinal position of controls inside view layout.
200 int languages_menubutton_order_; 194 int languages_menubutton_order_;
201 int sign_in_button_order_; 195 int sign_in_button_order_;
202 196
197 // Throbber's center y-position.
198 int throbber_center_y_;
199
200 // Throbber right position.
201 int throbber_right_;
202
203 FRIEND_TEST_ALL_PREFIXES(LoginScreenTest, IncognitoLogin); 203 FRIEND_TEST_ALL_PREFIXES(LoginScreenTest, IncognitoLogin);
204 friend class LoginScreenTest; 204 friend class LoginScreenTest;
205 205
206 DISALLOW_COPY_AND_ASSIGN(NewUserView); 206 DISALLOW_COPY_AND_ASSIGN(NewUserView);
207 }; 207 };
208 208
209 } // namespace chromeos 209 } // namespace chromeos
210 210
211 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_NEW_USER_VIEW_H_ 211 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_NEW_USER_VIEW_H_
OLDNEW

Powered by Google App Engine