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: cpplist + remove debug 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/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 ThrobberHost,
32 public UserInput,
33 public views::View,
31 public views::Textfield::Controller, 34 public views::Textfield::Controller,
32 public views::LinkController, 35 public views::LinkController,
33 public views::ButtonListener { 36 public views::ButtonListener {
34 public: 37 public:
35 // Delegate class to get notifications from the view. 38 // Delegate class to get notifications from the view.
36 class Delegate { 39 class Delegate {
37 public: 40 public:
38 virtual ~Delegate() {} 41 virtual ~Delegate() {}
39 42
40 // User provided |username|, |password| and initiated login. 43 // User provided |username|, |password| and initiated login.
(...skipping 25 matching lines...)
66 bool need_guest_link); 69 bool need_guest_link);
67 70
68 virtual ~NewUserView(); 71 virtual ~NewUserView();
69 72
70 // Initialize view layout. 73 // Initialize view layout.
71 void Init(); 74 void Init();
72 75
73 // Update strings from the resources. Executed on language change. 76 // Update strings from the resources. Executed on language change.
74 void UpdateLocalizedStrings(); 77 void UpdateLocalizedStrings();
75 78
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. 79 // Returns bounds of password field in screen coordinates.
89 gfx::Rect GetPasswordBounds() const; 80 gfx::Rect GetPasswordBounds() const;
90 81
91 // Returns bounds of username field in screen coordinates. 82 // Returns bounds of username field in screen coordinates.
92 gfx::Rect GetUsernameBounds() const; 83 gfx::Rect GetUsernameBounds() const;
93 84
94 // Overridden from views::View: 85 // Overridden from views::View:
95 virtual gfx::Size GetPreferredSize(); 86 virtual gfx::Size GetPreferredSize();
96 virtual void Layout(); 87 virtual void Layout();
97 virtual void RequestFocus(); 88 virtual void RequestFocus();
(...skipping 10 matching lines...)
108 virtual bool HandleKeystroke(views::Textfield* sender, 99 virtual bool HandleKeystroke(views::Textfield* sender,
109 const views::Textfield::Keystroke& keystroke); 100 const views::Textfield::Keystroke& keystroke);
110 virtual void ContentsChanged(views::Textfield* sender, 101 virtual void ContentsChanged(views::Textfield* sender,
111 const string16& new_contents); 102 const string16& new_contents);
112 103
113 // Overridden from views::ButtonListener. 104 // Overridden from views::ButtonListener.
114 virtual void ButtonPressed(views::Button* sender, const views::Event& event); 105 virtual void ButtonPressed(views::Button* sender, const views::Event& event);
115 106
116 // Overridden from views::LinkController. 107 // Overridden from views::LinkController.
117 virtual void LinkActivated(views::Link* source, int event_flags); 108 virtual void LinkActivated(views::Link* source, int event_flags);
109 virtual bool AcceleratorPressed(const views::Accelerator& accelerator);
118 110
119 virtual bool AcceleratorPressed(const views::Accelerator& accelerator); 111 // Overridden from ThrobberHost:
112 virtual gfx::Rect CalculateThrobberBounds(views::Throbber* throbber);
113
114 // Overridden from UserInput:
115 virtual void EnableInputControls(bool enabled);
116 virtual void ClearAndFocusControls();
117 virtual void ClearAndFocusPassword();
118 virtual gfx::Rect GetMainInputScreenBounds() const;
120 119
121 protected: 120 protected:
122 // views::View overrides: 121 // views::View overrides:
123 virtual void ViewHierarchyChanged(bool is_add, 122 virtual void ViewHierarchyChanged(bool is_add,
124 views::View *parent, 123 views::View *parent,
125 views::View *child); 124 views::View *child);
126 virtual void NativeViewHierarchyChanged(bool attached, 125 virtual void NativeViewHierarchyChanged(bool attached,
127 gfx::NativeView native_view, 126 gfx::NativeView native_view,
128 views::RootView* root_view); 127 views::RootView* root_view);
129 virtual void OnLocaleChanged(); 128 virtual void OnLocaleChanged();
130 void AddChildView(View* view); 129 void AddChildView(View* view);
131 130
132 private: 131 private:
133 // Enables/disables input controls (textfields, buttons).
134 void EnableInputControls(bool enabled);
135 void FocusFirstField(); 132 void FocusFirstField();
136 133
137 // Creates Link control and adds it as a child. 134 // Creates Link control and adds it as a child.
138 void InitLink(views::Link** link); 135 void InitLink(views::Link** link);
139 136
140 // Delete and recreate native controls that fail to update preferred size 137 // Delete and recreate native controls that fail to update preferred size
141 // after text/locale update. 138 // after text/locale update.
142 void RecreatePeculiarControls(); 139 void RecreatePeculiarControls();
143 140
144 // Enable or disable the |sign_in_button_| based on the contents of the 141 // Enable or disable the |sign_in_button_| based on the contents of the
(...skipping 13 matching lines...)
158 views::Label* title_label_; 155 views::Label* title_label_;
159 views::Label* title_hint_label_; 156 views::Label* title_hint_label_;
160 views::View* splitter_up1_; 157 views::View* splitter_up1_;
161 views::View* splitter_up2_; 158 views::View* splitter_up2_;
162 views::View* splitter_down1_; 159 views::View* splitter_down1_;
163 views::View* splitter_down2_; 160 views::View* splitter_down2_;
164 views::NativeButton* sign_in_button_; 161 views::NativeButton* sign_in_button_;
165 views::Link* create_account_link_; 162 views::Link* create_account_link_;
166 views::Link* guest_link_; 163 views::Link* guest_link_;
167 views::MenuButton* languages_menubutton_; 164 views::MenuButton* languages_menubutton_;
168 views::Throbber* throbber_;
169 165
170 views::Accelerator accel_focus_pass_; 166 views::Accelerator accel_focus_pass_;
171 views::Accelerator accel_focus_user_; 167 views::Accelerator accel_focus_user_;
172 views::Accelerator accel_login_off_the_record_; 168 views::Accelerator accel_login_off_the_record_;
173 views::Accelerator accel_enable_accessibility_; 169 views::Accelerator accel_enable_accessibility_;
174 170
175 // Notifications receiver. 171 // Notifications receiver.
176 Delegate* delegate_; 172 Delegate* delegate_;
177 173
178 ScopedRunnableMethodFactory<NewUserView> focus_grabber_factory_; 174 ScopedRunnableMethodFactory<NewUserView> focus_grabber_factory_;
(...skipping 23 matching lines...)
202 198
203 FRIEND_TEST_ALL_PREFIXES(LoginScreenTest, IncognitoLogin); 199 FRIEND_TEST_ALL_PREFIXES(LoginScreenTest, IncognitoLogin);
204 friend class LoginScreenTest; 200 friend class LoginScreenTest;
205 201
206 DISALLOW_COPY_AND_ASSIGN(NewUserView); 202 DISALLOW_COPY_AND_ASSIGN(NewUserView);
207 }; 203 };
208 204
209 } // namespace chromeos 205 } // namespace chromeos
210 206
211 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_NEW_USER_VIEW_H_ 207 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_NEW_USER_VIEW_H_
OLDNEW

Powered by Google App Engine