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

Side by Side Diff: chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h

Issue 1165323004: We should use UserID object to identify users instead of username. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 months 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
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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_UI_WEBUI_CHROMEOS_LOGIN_SIGNIN_SCREEN_HANDLER_H_ 5 #ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_SIGNIN_SCREEN_HANDLER_H_
6 #define CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_SIGNIN_SCREEN_HANDLER_H_ 6 #define CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_SIGNIN_SCREEN_HANDLER_H_
7 7
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
(...skipping 24 matching lines...) Expand all
35 #include "ui/base/ime/chromeos/input_method_manager.h" 35 #include "ui/base/ime/chromeos/input_method_manager.h"
36 #include "ui/events/event_handler.h" 36 #include "ui/events/event_handler.h"
37 37
38 class EasyUnlockService; 38 class EasyUnlockService;
39 39
40 namespace base { 40 namespace base {
41 class DictionaryValue; 41 class DictionaryValue;
42 class ListValue; 42 class ListValue;
43 } 43 }
44 44
45 namespace user_manager {
46 class UserID;
47 } // namespace user_manager
48
45 namespace chromeos { 49 namespace chromeos {
46 50
47 class CaptivePortalWindowProxy; 51 class CaptivePortalWindowProxy;
48 class CoreOobeActor; 52 class CoreOobeActor;
49 class ErrorScreensHistogramHelper; 53 class ErrorScreensHistogramHelper;
50 class GaiaScreenHandler; 54 class GaiaScreenHandler;
51 class NativeWindowDelegate; 55 class NativeWindowDelegate;
52 class SupervisedUserCreationScreenHandler; 56 class SupervisedUserCreationScreenHandler;
53 class User; 57 class User;
54 class UserContext; 58 class UserContext;
(...skipping 15 matching lines...) Expand all
70 74
71 std::string email_; 75 std::string email_;
72 bool oobe_ui_; 76 bool oobe_ui_;
73 }; 77 };
74 78
75 // An interface for WebUILoginDisplay to call SigninScreenHandler. 79 // An interface for WebUILoginDisplay to call SigninScreenHandler.
76 class LoginDisplayWebUIHandler { 80 class LoginDisplayWebUIHandler {
77 public: 81 public:
78 virtual void ClearAndEnablePassword() = 0; 82 virtual void ClearAndEnablePassword() = 0;
79 virtual void ClearUserPodPassword() = 0; 83 virtual void ClearUserPodPassword() = 0;
80 virtual void OnUserRemoved(const std::string& username) = 0; 84 virtual void OnUserRemoved(const user_manager::UserID& user_id) = 0;
81 virtual void OnUserImageChanged(const user_manager::User& user) = 0; 85 virtual void OnUserImageChanged(const user_manager::User& user) = 0;
82 virtual void OnPreferencesChanged() = 0; 86 virtual void OnPreferencesChanged() = 0;
83 virtual void ResetSigninScreenHandlerDelegate() = 0; 87 virtual void ResetSigninScreenHandlerDelegate() = 0;
84 virtual void ShowError(int login_attempts, 88 virtual void ShowError(int login_attempts,
85 const std::string& error_text, 89 const std::string& error_text,
86 const std::string& help_link_text, 90 const std::string& help_link_text,
87 HelpAppLauncher::HelpTopic help_topic_id) = 0; 91 HelpAppLauncher::HelpTopic help_topic_id) = 0;
88 virtual void ShowErrorScreen(LoginDisplay::SigninError error_id) = 0; 92 virtual void ShowErrorScreen(LoginDisplay::SigninError error_id) = 0;
89 virtual void ShowGaiaPasswordChanged(const std::string& username) = 0; 93 virtual void ShowGaiaPasswordChanged(const user_manager::UserID& user_id) = 0;
90 virtual void ShowSigninUI(const std::string& email) = 0; 94 virtual void ShowSigninUI(const user_manager::UserID& user_id) = 0;
91 virtual void ShowPasswordChangedDialog(bool show_password_error, 95 virtual void ShowPasswordChangedDialog(bool show_password_error,
92 const std::string& email) = 0; 96 const user_manager::UserID& user_id) = 0;
93 // Show sign-in screen for the given credentials. 97 // Show sign-in screen for the given credentials.
94 virtual void ShowSigninScreenForCreds(const std::string& username, 98 virtual void ShowSigninScreenForCreds(const user_manager::UserID& user_id,
95 const std::string& password) = 0; 99 const std::string& password) = 0;
96 virtual void ShowWhitelistCheckFailedError() = 0; 100 virtual void ShowWhitelistCheckFailedError() = 0;
97 virtual void LoadUsers(const base::ListValue& users_list, 101 virtual void LoadUsers(const base::ListValue& users_list,
98 bool show_guest) = 0; 102 bool show_guest) = 0;
99 protected: 103 protected:
100 virtual ~LoginDisplayWebUIHandler() {} 104 virtual ~LoginDisplayWebUIHandler() {}
101 }; 105 };
102 106
103 // An interface for SigninScreenHandler to call WebUILoginDisplay. 107 // An interface for SigninScreenHandler to call WebUILoginDisplay.
104 class SigninScreenHandlerDelegate { 108 class SigninScreenHandlerDelegate {
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 160
157 // Sets the displayed email for the next login attempt. If it succeeds, 161 // Sets the displayed email for the next login attempt. If it succeeds,
158 // user's displayed email value will be updated to |email|. 162 // user's displayed email value will be updated to |email|.
159 virtual void SetDisplayEmail(const std::string& email) = 0; 163 virtual void SetDisplayEmail(const std::string& email) = 0;
160 164
161 // --------------- Rest of the methods. 165 // --------------- Rest of the methods.
162 // Cancels user adding. 166 // Cancels user adding.
163 virtual void CancelUserAdding() = 0; 167 virtual void CancelUserAdding() = 0;
164 168
165 // Load wallpaper for given |username|. 169 // Load wallpaper for given |username|.
166 virtual void LoadWallpaper(const std::string& username) = 0; 170 virtual void LoadWallpaper(const user_manager::UserID& user_id) = 0;
167 171
168 // Loads the default sign-in wallpaper. 172 // Loads the default sign-in wallpaper.
169 virtual void LoadSigninWallpaper() = 0; 173 virtual void LoadSigninWallpaper() = 0;
170 174
171 // Attempts to remove given user. 175 // Attempts to remove given user.
172 virtual void RemoveUser(const std::string& username) = 0; 176 virtual void RemoveUser(const user_manager::UserID& user_id) = 0;
173 177
174 // Let the delegate know about the handler it is supposed to be using. 178 // Let the delegate know about the handler it is supposed to be using.
175 virtual void SetWebUIHandler(LoginDisplayWebUIHandler* webui_handler) = 0; 179 virtual void SetWebUIHandler(LoginDisplayWebUIHandler* webui_handler) = 0;
176 180
177 // Returns users list to be shown. 181 // Returns users list to be shown.
178 virtual const user_manager::UserList& GetUsers() const = 0; 182 virtual const user_manager::UserList& GetUsers() const = 0;
179 183
180 // Whether login as guest is available. 184 // Whether login as guest is available.
181 virtual bool IsShowGuest() const = 0; 185 virtual bool IsShowGuest() const = 0;
182 186
183 // Weather to show the user pods or only GAIA sign in. 187 // Weather to show the user pods or only GAIA sign in.
184 // Public sessions are always shown. 188 // Public sessions are always shown.
185 virtual bool IsShowUsers() const = 0; 189 virtual bool IsShowUsers() const = 0;
186 190
187 // Whether user sign in has completed. 191 // Whether user sign in has completed.
188 virtual bool IsUserSigninCompleted() const = 0; 192 virtual bool IsUserSigninCompleted() const = 0;
189 193
190 // Request to (re)load user list. 194 // Request to (re)load user list.
191 virtual void HandleGetUsers() = 0; 195 virtual void HandleGetUsers() = 0;
192 196
193 // Runs an OAuth token validation check for user. 197 // Runs an OAuth token validation check for user.
194 virtual void CheckUserStatus(const std::string& user_id) = 0; 198 virtual void CheckUserStatus(const user_manager::UserID& user_id) = 0;
195 199
196 protected: 200 protected:
197 virtual ~SigninScreenHandlerDelegate() {} 201 virtual ~SigninScreenHandlerDelegate() {}
198 }; 202 };
199 203
200 // A class that handles the WebUI hooks in sign-in screen in OobeDisplay 204 // A class that handles the WebUI hooks in sign-in screen in OobeDisplay
201 // and LoginDisplay. 205 // and LoginDisplay.
202 class SigninScreenHandler 206 class SigninScreenHandler
203 : public BaseScreenHandler, 207 : public BaseScreenHandler,
204 public LoginDisplayWebUIHandler, 208 public LoginDisplayWebUIHandler,
205 public content::NotificationObserver, 209 public content::NotificationObserver,
206 public NetworkStateInformer::NetworkStateInformerObserver, 210 public NetworkStateInformer::NetworkStateInformerObserver,
207 public input_method::ImeKeyboard::Observer, 211 public input_method::ImeKeyboard::Observer,
208 public TouchViewControllerDelegate::Observer, 212 public TouchViewControllerDelegate::Observer,
209 public OobeUI::Observer { 213 public OobeUI::Observer {
210 public: 214 public:
211 SigninScreenHandler( 215 SigninScreenHandler(
212 const scoped_refptr<NetworkStateInformer>& network_state_informer, 216 const scoped_refptr<NetworkStateInformer>& network_state_informer,
213 NetworkErrorModel* network_error_model, 217 NetworkErrorModel* network_error_model,
214 CoreOobeActor* core_oobe_actor, 218 CoreOobeActor* core_oobe_actor,
215 GaiaScreenHandler* gaia_screen_handler); 219 GaiaScreenHandler* gaia_screen_handler);
216 ~SigninScreenHandler() override; 220 ~SigninScreenHandler() override;
217 221
218 static std::string GetUserLRUInputMethod(const std::string& username); 222 static std::string GetUserLRUInputMethod(const user_manager::UserID& user_id);
219 223
220 // Update current input method (namely keyboard layout) in the given IME state 224 // Update current input method (namely keyboard layout) in the given IME state
221 // to LRU by this user. 225 // to LRU by this user.
222 static void SetUserInputMethod( 226 static void SetUserInputMethod(
223 const std::string& username, 227 const user_manager::UserID& user_id,
224 input_method::InputMethodManager::State* ime_state); 228 input_method::InputMethodManager::State* ime_state);
225 229
226 // Shows the sign in screen. 230 // Shows the sign in screen.
227 void Show(const LoginScreenContext& context); 231 void Show(const LoginScreenContext& context);
228 232
229 // Sets delegate to be used by the handler. It is guaranteed that valid 233 // Sets delegate to be used by the handler. It is guaranteed that valid
230 // delegate is set before Show() method will be called. 234 // delegate is set before Show() method will be called.
231 void SetDelegate(SigninScreenHandlerDelegate* delegate); 235 void SetDelegate(SigninScreenHandlerDelegate* delegate);
232 236
233 void SetNativeWindowDelegate(NativeWindowDelegate* native_window_delegate); 237 void SetNativeWindowDelegate(NativeWindowDelegate* native_window_delegate);
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 ::login::LocalizedValuesBuilder* builder) override; 285 ::login::LocalizedValuesBuilder* builder) override;
282 void Initialize() override; 286 void Initialize() override;
283 gfx::NativeWindow GetNativeWindow() override; 287 gfx::NativeWindow GetNativeWindow() override;
284 288
285 // WebUIMessageHandler implementation: 289 // WebUIMessageHandler implementation:
286 void RegisterMessages() override; 290 void RegisterMessages() override;
287 291
288 // LoginDisplayWebUIHandler implementation: 292 // LoginDisplayWebUIHandler implementation:
289 void ClearAndEnablePassword() override; 293 void ClearAndEnablePassword() override;
290 void ClearUserPodPassword() override; 294 void ClearUserPodPassword() override;
291 void OnUserRemoved(const std::string& username) override; 295 void OnUserRemoved(const user_manager::UserID& user_id) override;
292 void OnUserImageChanged(const user_manager::User& user) override; 296 void OnUserImageChanged(const user_manager::User& user) override;
293 void OnPreferencesChanged() override; 297 void OnPreferencesChanged() override;
294 void ResetSigninScreenHandlerDelegate() override; 298 void ResetSigninScreenHandlerDelegate() override;
295 void ShowError(int login_attempts, 299 void ShowError(int login_attempts,
296 const std::string& error_text, 300 const std::string& error_text,
297 const std::string& help_link_text, 301 const std::string& help_link_text,
298 HelpAppLauncher::HelpTopic help_topic_id) override; 302 HelpAppLauncher::HelpTopic help_topic_id) override;
299 void ShowGaiaPasswordChanged(const std::string& username) override; 303 void ShowGaiaPasswordChanged(const user_manager::UserID& user_id) override;
300 void ShowSigninUI(const std::string& email) override; 304 void ShowSigninUI(const user_manager::UserID& user_id) override;
301 void ShowPasswordChangedDialog(bool show_password_error, 305 void ShowPasswordChangedDialog(bool show_password_error,
302 const std::string& email) override; 306 const user_manager::UserID& user_id) override;
303 void ShowErrorScreen(LoginDisplay::SigninError error_id) override; 307 void ShowErrorScreen(LoginDisplay::SigninError error_id) override;
304 void ShowSigninScreenForCreds(const std::string& username, 308 void ShowSigninScreenForCreds(const user_manager::UserID& user_id,
305 const std::string& password) override; 309 const std::string& password) override;
306 void ShowWhitelistCheckFailedError() override; 310 void ShowWhitelistCheckFailedError() override;
307 void LoadUsers(const base::ListValue& users_list, bool show_guest) override; 311 void LoadUsers(const base::ListValue& users_list, bool show_guest) override;
308 312
309 // content::NotificationObserver implementation: 313 // content::NotificationObserver implementation:
310 void Observe(int type, 314 void Observe(int type,
311 const content::NotificationSource& source, 315 const content::NotificationSource& source,
312 const content::NotificationDetails& details) override; 316 const content::NotificationDetails& details) override;
313 317
314 // TouchViewControllerDelegate::Observer implementation: 318 // TouchViewControllerDelegate::Observer implementation:
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 const std::string& locale); 370 const std::string& locale);
367 void HandleCancelConsumerManagementEnrollment(); 371 void HandleCancelConsumerManagementEnrollment();
368 void HandleGetTouchViewState(); 372 void HandleGetTouchViewState();
369 void HandleLogRemoveUserWarningShown(); 373 void HandleLogRemoveUserWarningShown();
370 void HandleFirstIncorrectPasswordAttempt(const std::string& email); 374 void HandleFirstIncorrectPasswordAttempt(const std::string& email);
371 void HandleMaxIncorrectPasswordAttempts(const std::string& email); 375 void HandleMaxIncorrectPasswordAttempts(const std::string& email);
372 376
373 // Sends the list of |keyboard_layouts| available for the |locale| that is 377 // Sends the list of |keyboard_layouts| available for the |locale| that is
374 // currently selected for the public session identified by |user_id|. 378 // currently selected for the public session identified by |user_id|.
375 void SendPublicSessionKeyboardLayouts( 379 void SendPublicSessionKeyboardLayouts(
376 const std::string& user_id, 380 const user_manager::UserID& user_id,
377 const std::string& locale, 381 const std::string& locale,
378 scoped_ptr<base::ListValue> keyboard_layouts); 382 scoped_ptr<base::ListValue> keyboard_layouts);
379 383
380 // Returns true iff 384 // Returns true iff
381 // (i) log in is restricted to some user list, 385 // (i) log in is restricted to some user list,
382 // (ii) all users in the restricted list are present. 386 // (ii) all users in the restricted list are present.
383 bool AllWhitelistedUsersPresent(); 387 bool AllWhitelistedUsersPresent();
384 388
385 // Cancels password changed flow - switches back to login screen. 389 // Cancels password changed flow - switches back to login screen.
386 // Called as a callback after cookies are cleared. 390 // Called as a callback after cookies are cleared.
(...skipping 28 matching lines...) Expand all
415 419
416 // input_method::ImeKeyboard::Observer implementation: 420 // input_method::ImeKeyboard::Observer implementation:
417 void OnCapsLockChanged(bool enabled) override; 421 void OnCapsLockChanged(bool enabled) override;
418 422
419 // Returns OobeUI object of NULL. 423 // Returns OobeUI object of NULL.
420 OobeUI* GetOobeUI() const; 424 OobeUI* GetOobeUI() const;
421 425
422 // Gets the easy unlock service associated with the user. Can return NULL if 426 // Gets the easy unlock service associated with the user. Can return NULL if
423 // user cannot be found, or there is not associated service. 427 // user cannot be found, or there is not associated service.
424 EasyUnlockService* GetEasyUnlockServiceForUser( 428 EasyUnlockService* GetEasyUnlockServiceForUser(
425 const std::string& username) const; 429 const user_manager::UserID& user_id) const;
426 430
427 // Current UI state of the signin screen. 431 // Current UI state of the signin screen.
428 UIState ui_state_ = UI_STATE_UNKNOWN; 432 UIState ui_state_ = UI_STATE_UNKNOWN;
429 433
430 // A delegate that glues this handler with backend LoginDisplay. 434 // A delegate that glues this handler with backend LoginDisplay.
431 SigninScreenHandlerDelegate* delegate_ = nullptr; 435 SigninScreenHandlerDelegate* delegate_ = nullptr;
432 436
433 // A delegate used to get gfx::NativeWindow. 437 // A delegate used to get gfx::NativeWindow.
434 NativeWindowDelegate* native_window_delegate_ = nullptr; 438 NativeWindowDelegate* native_window_delegate_ = nullptr;
435 439
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
496 scoped_ptr<ErrorScreensHistogramHelper> histogram_helper_; 500 scoped_ptr<ErrorScreensHistogramHelper> histogram_helper_;
497 501
498 base::WeakPtrFactory<SigninScreenHandler> weak_factory_; 502 base::WeakPtrFactory<SigninScreenHandler> weak_factory_;
499 503
500 DISALLOW_COPY_AND_ASSIGN(SigninScreenHandler); 504 DISALLOW_COPY_AND_ASSIGN(SigninScreenHandler);
501 }; 505 };
502 506
503 } // namespace chromeos 507 } // namespace chromeos
504 508
505 #endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_SIGNIN_SCREEN_HANDLER_H_ 509 #endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_SIGNIN_SCREEN_HANDLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698