Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(414)

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

Issue 8436002: [cros] Remove Views implementation for login/OOBE. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merge Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_USER_CONTROLLER_H_
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_USER_CONTROLLER_H_
7 #pragma once
8
9 #include <string>
10
11 #include "base/compiler_specific.h"
12 #include "base/gtest_prod_util.h"
13 #include "base/string16.h"
14 #include "base/task.h"
15 #include "chrome/browser/chromeos/login/new_user_view.h"
16 #include "chrome/browser/chromeos/login/user_manager.h"
17 #include "chrome/browser/chromeos/login/user_view.h"
18 #include "testing/gtest/include/gtest/gtest_prod.h"
19 #include "views/widget/widget.h"
20 #include "views/widget/widget_delegate.h"
21
22 #if defined(TOOLKIT_USES_GTK)
23 #include "chrome/browser/chromeos/wm_ipc.h"
24 #else
25 #include "third_party/cros_system_api/window_manager/chromeos_wm_ipc_enums.h"
26 #endif
27
28 namespace views {
29 class Widget;
30 }
31
32 namespace chromeos {
33
34 class ThrobberManager;
35
36 // UserController manages the set of windows needed to login a single existing
37 // user or first time login for a new user. ExistingUserController creates
38 // the nececessary set of UserControllers.
39 class UserController : public views::WidgetDelegate,
40 public NewUserView::Delegate,
41 public UserView::Delegate,
42 public views::Widget::Observer {
43 public:
44 class Delegate {
45 public:
46 virtual void CreateAccount() = 0;
47 virtual void Login(UserController* source,
48 const string16& password) = 0;
49 virtual void LoginAsGuest() = 0;
50 virtual void ClearErrors() = 0;
51 virtual void OnUserSelected(UserController* source) = 0;
52 virtual void RemoveUser(UserController* source) = 0;
53
54 // Selects user entry with specified |index|.
55 // Does nothing if current user is already selected.
56 virtual void SelectUser(int index) = 0;
57
58 // Switch to the enterprise enrollment screen (if applicable).
59 virtual void StartEnterpriseEnrollment() = 0;
60
61 protected:
62 virtual ~Delegate() {}
63 };
64
65 // Creates a UserController representing new user or guest login.
66 UserController(Delegate* delegate, bool is_guest);
67
68 // Creates a UserController for the specified user.
69 UserController(Delegate* delegate, const UserManager::User& user);
70
71 virtual ~UserController();
72
73 // Initializes the UserController, creating the set of windows/controls.
74 // |index| is the index of this user, and |total_user_count| the total
75 // number of users.
76 void Init(int index, int total_user_count, bool need_browse_without_signin);
77
78 int user_index() const { return user_index_; }
79 bool is_new_user() const { return is_new_user_; }
80 bool is_guest() const { return is_guest_; }
81 bool is_owner() const { return is_owner_; }
82
83 const UserManager::User& user() const { return user_; }
84
85 // Get widget that contains all controls.
86 views::Widget* controls_widget() { return controls_widget_; }
87
88 // Called when user view is activated (OnUserSelected).
89 void ClearAndEnableFields();
90
91 // Called when user view is activated (OnUserSelected).
92 void ClearAndEnablePassword();
93
94 // Enables or disables tooltip with user's email.
95 void EnableNameTooltip(bool enable);
96
97 // Called when user image has been changed.
98 void OnUserImageChanged(UserManager::User* user);
99
100 // Returns bounds of the main input field in the screen coordinates (e.g.
101 // these bounds could be used to choose positions for the error bubble).
102 gfx::Rect GetMainInputScreenBounds() const;
103
104 // Selects user relative to the current user.
105 void SelectUserRelative(int shift);
106
107 // Starts/Stops throbber.
108 void StartThrobber();
109 void StopThrobber();
110
111 // Update border window parameters to notify window manager about new numbers.
112 // |index| of this user and |total_user_count| of users.
113 void UpdateUserCount(int index, int total_user_count);
114
115 // Returns the label for the user which should be spoken when accessibility is
116 // enabled.
117 std::string GetAccessibleUserLabel();
118
119 // views::WidgetDelegate implementation:
120 virtual views::Widget* GetWidget() OVERRIDE;
121 virtual const views::Widget* GetWidget() const OVERRIDE;
122
123 // NewUserView::Delegate implementation:
124 virtual void OnLogin(const std::string& username,
125 const std::string& password) OVERRIDE;
126 virtual void OnLoginAsGuest() OVERRIDE;
127 virtual void OnCreateAccount() OVERRIDE;
128 virtual void OnStartEnterpriseEnrollment() OVERRIDE;
129 virtual void ClearErrors() OVERRIDE;
130 virtual void NavigateAway() OVERRIDE;
131
132 // UserView::Delegate implementation:
133 virtual void OnRemoveUser() OVERRIDE;
134 virtual bool IsUserSelected() const OVERRIDE;
135
136 // UsernameView::Delegate implementation:
137 virtual void OnLocaleChanged() OVERRIDE;
138
139 // Overridden from views::Widget::Observer.
140 virtual void OnWidgetActivationChanged(views::Widget* widget,
141 bool active) OVERRIDE;
142
143 // Padding between the user windows.
144 static const int kPadding;
145
146 // Max size needed when an entry is not selected.
147 static const int kUnselectedSize;
148 static const int kNewUserUnselectedSize;
149
150 private:
151 FRIEND_TEST_ALL_PREFIXES(UserControllerTest, GetNameTooltipAddUser);
152 FRIEND_TEST_ALL_PREFIXES(UserControllerTest, GetNameTooltipIncognitoUser);
153 FRIEND_TEST_ALL_PREFIXES(UserControllerTest, GetNameTooltipExistingUser);
154
155 class ControlsWidgetDelegate;
156
157 // Performs common setup for login windows.
158 void ConfigureAndShow(views::Widget* widget,
159 int index,
160 chromeos::WmIpcWindowType type,
161 views::View* contents_view);
162 void SetupControlsWidget(int index,
163 int* width,
164 int* height,
165 bool need_guest_link);
166 views::Widget* CreateImageWidget(int index);
167 views::Widget* CreateLabelWidget(int index, WmIpcWindowType type);
168 gfx::Font GetLabelFont();
169 gfx::Font GetUnselectedLabelFont();
170 void CreateBorderWindow(int index,
171 int total_user_count,
172 int controls_width, int controls_height);
173
174 // Returns tooltip text for user name.
175 string16 GetNameTooltip() const;
176
177 // Creates the widget that holds the controls. Caller owns the returned
178 // widget.
179 static views::Widget* CreateControlsWidget(views::WidgetDelegate* delegate,
180 const gfx::Rect& bounds);
181
182 // Creates a Widget that selects the user any time the widget is
183 // clicked. Caller owns the returned widget.
184 static views::Widget* CreateClickNotifyingWidget(UserController* controller,
185 const gfx::Rect& bounds);
186
187 // User index within all the users.
188 int user_index_;
189
190 // Is this user selected now?
191 bool is_user_selected_;
192
193 // Is this the new user pod?
194 const bool is_new_user_;
195
196 // Is this the guest pod?
197 const bool is_guest_;
198
199 // Is this user the owner?
200 const bool is_owner_;
201
202 // Should we show tooltips above user image and label to help distinguish
203 // users with the same display name.
204 bool show_name_tooltip_;
205
206 // If is_new_user_ and is_guest_ are false, this is the user being shown.
207 UserManager::User user_;
208
209 Delegate* delegate_;
210
211 // A window is used to represent the individual chunks.
212 views::Widget* controls_widget_;
213 views::Widget* image_widget_;
214 views::Widget* border_window_;
215 views::Widget* label_widget_;
216 views::Widget* unselected_label_widget_;
217
218 scoped_ptr<ControlsWidgetDelegate> controls_widget_delegate_;
219
220 // View that shows user image on image window.
221 UserView* user_view_;
222
223 // Views that show display name of the user.
224 views::Label* label_view_;
225 views::Label* unselected_label_view_;
226
227 // Input controls which are used for username and password.
228 UserInput* user_input_;
229
230 // Throbber host that can show a throbber.
231 ThrobberHostView* throbber_host_;
232
233 // Whether name tooltip is enabled.
234 bool name_tooltip_enabled_;
235
236 DISALLOW_COPY_AND_ASSIGN(UserController);
237 };
238
239 } // namespace chromeos
240
241 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USER_CONTROLLER_H_
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/update_view.cc ('k') | chrome/browser/chromeos/login/user_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698