blob: cddca03de2f4bc4e50fe77643607591d00bcf753 [file] [log] [blame]
[email protected]83d82d42014-05-16 02:04:421// Copyright 2014 The Chromium Authors. All rights reserved.
[email protected]bab1bceb2010-02-02 18:25:052// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
[email protected]83d82d42014-05-16 02:04:425#ifndef CHROME_BROWSER_CHROMEOS_LOGIN_USERS_USER_MANAGER_H_
6#define CHROME_BROWSER_CHROMEOS_LOGIN_USERS_USER_MANAGER_H_
[email protected]bab1bceb2010-02-02 18:25:057
8#include <string>
[email protected]bab1bceb2010-02-02 18:25:059
[email protected]fcb10a482013-11-13 20:08:4310#include "chrome/browser/chromeos/base/locale_util.h"
[email protected]1a2a6d52013-02-22 19:20:5311#include "chrome/browser/chromeos/login/user_flow.h"
[email protected]83d82d42014-05-16 02:04:4212#include "chrome/browser/chromeos/login/users/user.h"
[email protected]bab1bceb2010-02-02 18:25:0513
[email protected]b1de2c72013-02-06 02:45:4714class PrefRegistrySimple;
[email protected]c2a7e682011-03-16 13:03:1815
[email protected]8f0d8ecd12010-04-20 11:51:3016namespace chromeos {
[email protected]39db06702011-11-10 16:31:2417
[email protected]2c857e62014-02-06 11:49:0718class MultiProfileUserController;
[email protected]773a8142011-03-02 16:44:1119class RemoveUserDelegate;
[email protected]c4e418f2012-10-15 15:53:4520class UserImageManager;
[email protected]202f0142013-10-18 12:12:4821class SupervisedUserManager;
[email protected]8f0d8ecd12010-04-20 11:51:3022
[email protected]eddc251a2012-03-06 15:44:1423// Base class for UserManagerImpl - provides a mechanism for discovering users
24// who have logged into this Chrome OS device before and updating that list.
25class UserManager {
[email protected]bab1bceb2010-02-02 18:25:0526 public:
[email protected]61a9fb32011-08-03 21:00:5127 // Interface that observers of UserManager must implement in order
28 // to receive notification when local state preferences is changed
29 class Observer {
30 public:
[email protected]64f784cc2013-02-16 02:14:2131 // Called when the local state preferences is changed.
[email protected]f8622a42013-06-07 14:12:3632 virtual void LocalStateChanged(UserManager* user_manager);
[email protected]61a9fb32011-08-03 21:00:5133
34 protected:
[email protected]7cad6b0d2013-04-25 20:29:3235 virtual ~Observer();
36 };
37
[email protected]cfad8752013-06-04 16:58:3438 // TODO(nkostylev): Refactor and move this observer out of UserManager.
39 // Observer interface that defines methods used to notify on user session /
40 // active user state changes. Default implementation is empty.
[email protected]7cad6b0d2013-04-25 20:29:3241 class UserSessionStateObserver {
42 public:
[email protected]cfad8752013-06-04 16:58:3443 // Called when active user has changed.
44 virtual void ActiveUserChanged(const User* active_user);
45
[email protected]ad87c672013-10-09 21:01:3646 // Called when another user got added to the existing session.
47 virtual void UserAddedToSession(const User* added_user);
48
[email protected]7cad6b0d2013-04-25 20:29:3249 // Called right before notifying on user change so that those who rely
50 // on user_id hash would be accessing up-to-date value.
[email protected]cfad8752013-06-04 16:58:3451 virtual void ActiveUserHashChanged(const std::string& hash);
[email protected]7cad6b0d2013-04-25 20:29:3252
[email protected]2622feb82013-05-28 20:41:3853 // Called when UserManager finishes restoring user sessions after crash.
[email protected]cfad8752013-06-04 16:58:3454 virtual void PendingUserSessionsRestoreFinished();
[email protected]2622feb82013-05-28 20:41:3855
[email protected]7cad6b0d2013-04-25 20:29:3256 protected:
57 virtual ~UserSessionStateObserver();
[email protected]61a9fb32011-08-03 21:00:5158 };
59
[email protected]6dd76822013-11-26 12:04:1160 // Data retrieved from user account.
61 class UserAccountData {
62 public:
[email protected]96920152013-12-04 21:00:1663 UserAccountData(const base::string16& display_name,
64 const base::string16& given_name,
[email protected]6dd76822013-11-26 12:04:1165 const std::string& locale);
66 ~UserAccountData();
[email protected]96920152013-12-04 21:00:1667 const base::string16& display_name() const { return display_name_; }
68 const base::string16& given_name() const { return given_name_; }
[email protected]6dd76822013-11-26 12:04:1169 const std::string& locale() const { return locale_; }
70
71 private:
[email protected]96920152013-12-04 21:00:1672 const base::string16 display_name_;
73 const base::string16 given_name_;
[email protected]6dd76822013-11-26 12:04:1174 const std::string locale_;
75
76 DISALLOW_COPY_AND_ASSIGN(UserAccountData);
77 };
78
[email protected]89dbb1772012-07-17 13:47:2579 // Username for stub login when not running on ChromeOS.
80 static const char kStubUser[];
81
[email protected]688a9222014-02-07 08:34:2782 // Username for the login screen. It is only used to identify login screen
83 // tries to set default wallpaper. It is not a real user.
84 static const char kSignInUser[];
85
[email protected]68e31692013-05-20 13:08:2786 // Magic e-mail addresses are bad. They exist here because some code already
87 // depends on them and it is hard to figure out what. Any user types added in
88 // the future should be identified by a new |UserType|, not a new magic e-mail
89 // address.
90 // Username for Guest session user.
91 static const char kGuestUserName[];
92
[email protected]a2774c382013-01-16 14:35:3893 // Domain that is used for all locally managed users.
94 static const char kLocallyManagedUserDomain[];
95
[email protected]68e31692013-05-20 13:08:2796 // The retail mode user has a magic, domainless e-mail address.
97 static const char kRetailModeUserName[];
98
[email protected]9a68d3a2013-04-22 16:26:5499 // Creates the singleton instance. This method is not thread-safe and must be
[email protected]eddc251a2012-03-06 15:44:14100 // called from the main UI thread.
[email protected]9a68d3a2013-04-22 16:26:54101 static void Initialize();
[email protected]eddc251a2012-03-06 15:44:14102
[email protected]9a68d3a2013-04-22 16:26:54103 // Checks whether the singleton instance has been created already. This method
104 // is not thread-safe and must be called from the main UI thread.
105 static bool IsInitialized();
106
107 // Shuts down the UserManager. After this method has been called, the
108 // singleton has unregistered itself as an observer but remains available so
109 // that other classes can access it during their shutdown. This method is not
110 // thread-safe and must be called from the main UI thread.
111 virtual void Shutdown() = 0;
112
113 // Destroys the singleton instance. Always call Shutdown() first. This method
114 // is not thread-safe and must be called from the main UI thread.
115 static void Destroy();
116
117 // Returns the singleton instance or |NULL| if the singleton has either not
118 // been created yet or is already destroyed. This method is not thread-safe
119 // and must be called from the main UI thread.
120 static UserManager* Get();
[email protected]79bac422013-04-22 15:44:26121
[email protected]eddc251a2012-03-06 15:44:14122 // Registers user manager preferences.
[email protected]b1de2c72013-02-06 02:45:47123 static void RegisterPrefs(PrefRegistrySimple* registry);
[email protected]eddc251a2012-03-06 15:44:14124
[email protected]eddc251a2012-03-06 15:44:14125 virtual ~UserManager();
126
[email protected]2c857e62014-02-06 11:49:07127 virtual MultiProfileUserController* GetMultiProfileUserController() = 0;
[email protected]28126582013-12-24 18:36:55128 virtual UserImageManager* GetUserImageManager(const std::string& user_id) = 0;
[email protected]202f0142013-10-18 12:12:48129 virtual SupervisedUserManager* GetSupervisedUserManager() = 0;
[email protected]c4e418f2012-10-15 15:53:45130
[email protected]8e85e9462012-03-13 11:23:23131 // Returns a list of users who have logged into this device previously. This
132 // is sorted by last login date with the most recent user at the beginning.
[email protected]eddc251a2012-03-06 15:44:14133 virtual const UserList& GetUsers() const = 0;
134
[email protected]d1756c52014-06-17 08:07:17135 // Returns list of users admitted for logging in into multi-profile session.
[email protected]9319f082014-06-20 00:35:44136 // Users that have a policy that prevents them from being added to the
137 // multi-profile session will still be part of this list as long as they
138 // are regular users (i.e. not a public session/supervised etc.).
139 // Returns an empty list in case when primary user is not a regular one or
140 // has a policy that prohibids it to be part of multi-profile session.
[email protected]04887162013-05-29 23:01:51141 virtual UserList GetUsersAdmittedForMultiProfile() const = 0;
142
[email protected]e718e6f2013-04-15 16:01:59143 // Returns a list of users who are currently logged in.
144 virtual const UserList& GetLoggedInUsers() const = 0;
145
[email protected]c8d19f82013-05-18 09:09:41146 // Returns a list of users who are currently logged in in the LRU order -
147 // so the active user is the first one in the list. If there is no user logged
148 // in, the current user will be returned.
149 virtual const UserList& GetLRULoggedInUsers() = 0;
150
[email protected]8f484832013-09-18 02:52:56151 // Returns a list of users who can unlock the device.
[email protected]402fcdd2014-01-24 12:51:52152 // This list is based on policy and whether user is able to do unlock.
153 // Policy:
154 // * If user has primary-only policy then it is the only user in unlock users.
155 // * Otherwise all users with unrestricted policy are added to this list.
156 // All users that are unable to perform unlock are excluded from this list.
[email protected]8f484832013-09-18 02:52:56157 virtual UserList GetUnlockUsers() const = 0;
158
[email protected]204c19c2013-09-01 23:27:46159 // Returns the email of the owner user. Returns an empty string if there is
160 // no owner for the device.
161 virtual const std::string& GetOwnerEmail() = 0;
162
[email protected]202f0142013-10-18 12:12:48163 // Indicates that a user with the given |user_id| has just logged in. The
[email protected]8e85e9462012-03-13 11:23:23164 // persistent list is updated accordingly if the user is not ephemeral.
[email protected]503fc5b2012-06-14 17:52:12165 // |browser_restart| is true when reloading Chrome after crash to distinguish
166 // from normal sign in flow.
[email protected]40429592013-03-29 17:52:33167 // |username_hash| is used to identify homedir mount point.
[email protected]202f0142013-10-18 12:12:48168 virtual void UserLoggedIn(const std::string& user_id,
[email protected]40429592013-03-29 17:52:33169 const std::string& username_hash,
170 bool browser_restart) = 0;
[email protected]eddc251a2012-03-06 15:44:14171
[email protected]202f0142013-10-18 12:12:48172 // Switches to active user identified by |user_id|. User has to be logged in.
173 virtual void SwitchActiveUser(const std::string& user_id) = 0;
[email protected]e718e6f2013-04-15 16:01:59174
[email protected]d4f22f22012-05-05 00:44:55175 // Called when browser session is started i.e. after
[email protected]fe7c4872012-05-10 20:06:03176 // browser_creator.LaunchBrowser(...) was called after user sign in.
[email protected]d4f22f22012-05-05 00:44:55177 // When user is at the image screen IsUserLoggedIn() will return true
[email protected]53114692013-09-13 22:07:18178 // but IsSessionStarted() will return false. During the kiosk splash screen,
179 // we perform additional initialization after the user is logged in but
180 // before the session has been started.
[email protected]d4f22f22012-05-05 00:44:55181 // Fires NOTIFICATION_SESSION_STARTED.
182 virtual void SessionStarted() = 0;
183
[email protected]0fbe5d62013-05-23 16:10:16184 // Usually is called when Chrome is restarted after a crash and there's an
185 // active session. First user (one that is passed with --login-user) Chrome
186 // session has been already restored at this point. This method asks session
187 // manager for all active user sessions, marks them as logged in
188 // and notifies observers.
189 virtual void RestoreActiveSessions() = 0;
190
[email protected]eddc251a2012-03-06 15:44:14191 // Removes the user from the device. Note, it will verify that the given user
192 // isn't the owner, so calling this method for the owner will take no effect.
193 // Note, |delegate| can be NULL.
[email protected]202f0142013-10-18 12:12:48194 virtual void RemoveUser(const std::string& user_id,
[email protected]eddc251a2012-03-06 15:44:14195 RemoveUserDelegate* delegate) = 0;
196
197 // Removes the user from the persistent list only. Also removes the user's
198 // picture.
[email protected]202f0142013-10-18 12:12:48199 virtual void RemoveUserFromList(const std::string& user_id) = 0;
[email protected]eddc251a2012-03-06 15:44:14200
[email protected]202f0142013-10-18 12:12:48201 // Returns true if a user with the given user id is found in the persistent
202 // list or currently logged in as ephemeral.
203 virtual bool IsKnownUser(const std::string& user_id) const = 0;
[email protected]eddc251a2012-03-06 15:44:14204
[email protected]202f0142013-10-18 12:12:48205 // Returns the user with the given user id if found in the persistent
[email protected]8e85e9462012-03-13 11:23:23206 // list or currently logged in as ephemeral. Returns |NULL| otherwise.
[email protected]202f0142013-10-18 12:12:48207 virtual const User* FindUser(const std::string& user_id) const = 0;
[email protected]0a5da5b2013-10-01 13:48:37208
[email protected]25206cc2013-11-18 07:47:18209 // Returns the user with the given user id if found in the persistent
210 // list or currently logged in as ephemeral. Returns |NULL| otherwise.
211 // Same as FindUser but returns non-const pointer to User object.
212 virtual User* FindUserAndModify(const std::string& user_id) = 0;
213
[email protected]eddc251a2012-03-06 15:44:14214 // Returns the logged-in user.
[email protected]e718e6f2013-04-15 16:01:59215 // TODO(nkostylev): Deprecate this call, move clients to GetActiveUser().
216 // http://crbug.com/230852
[email protected]c4e418f2012-10-15 15:53:45217 virtual const User* GetLoggedInUser() const = 0;
218 virtual User* GetLoggedInUser() = 0;
[email protected]eddc251a2012-03-06 15:44:14219
[email protected]e718e6f2013-04-15 16:01:59220 // Returns the logged-in user that is currently active within this session.
221 // There could be multiple users logged in at the the same but for now
222 // we support only one of them being active.
223 virtual const User* GetActiveUser() const = 0;
224 virtual User* GetActiveUser() = 0;
225
[email protected]8f484832013-09-18 02:52:56226 // Returns the primary user of the current session. It is recorded for the
227 // first signed-in user and does not change thereafter.
228 virtual const User* GetPrimaryUser() const = 0;
229
[email protected]adcef6b2013-10-10 09:18:09230 // Returns NULL if User is not created.
231 virtual User* GetUserByProfile(Profile* profile) const = 0;
232
[email protected]16819522013-12-16 14:08:26233 /// Returns NULL if profile for user is not found or is not fully loaded.
[email protected]fe708772013-11-20 04:53:05234 virtual Profile* GetProfileByUser(const User* user) const = 0;
235
[email protected]eddc251a2012-03-06 15:44:14236 // Saves user's oauth token status in local state preferences.
237 virtual void SaveUserOAuthStatus(
[email protected]202f0142013-10-18 12:12:48238 const std::string& user_id,
[email protected]eddc251a2012-03-06 15:44:14239 User::OAuthTokenStatus oauth_token_status) = 0;
240
[email protected]f727a352014-01-25 22:52:46241 // Saves a flag indicating whether online authentication against GAIA should
242 // be enforced during the user's next sign-in.
243 virtual void SaveForceOnlineSignin(const std::string& user_id,
244 bool force_online_signin) = 0;
245
[email protected]7aa538b2012-06-06 00:27:38246 // Saves user's displayed name in local state preferences.
247 // Ignored If there is no such user.
[email protected]202f0142013-10-18 12:12:48248 virtual void SaveUserDisplayName(const std::string& user_id,
[email protected]96920152013-12-04 21:00:16249 const base::string16& display_name) = 0;
[email protected]7aa538b2012-06-06 00:27:38250
[email protected]c2b68c82013-09-24 02:49:39251 // Updates data upon User Account download.
[email protected]202f0142013-10-18 12:12:48252 virtual void UpdateUserAccountData(const std::string& user_id,
[email protected]6dd76822013-11-26 12:04:11253 const UserAccountData& account_data) = 0;
[email protected]c2b68c82013-09-24 02:49:39254
[email protected]202f0142013-10-18 12:12:48255 // Returns the display name for user |user_id| if it is known (was
[email protected]7aa538b2012-06-06 00:27:38256 // previously set by a |SaveUserDisplayName| call).
257 // Otherwise, returns an empty string.
[email protected]96920152013-12-04 21:00:16258 virtual base::string16 GetUserDisplayName(
[email protected]202f0142013-10-18 12:12:48259 const std::string& user_id) const = 0;
[email protected]7aa538b2012-06-06 00:27:38260
[email protected]2f5b4832012-05-15 21:41:37261 // Saves user's displayed (non-canonical) email in local state preferences.
[email protected]eddc251a2012-03-06 15:44:14262 // Ignored If there is no such user.
[email protected]202f0142013-10-18 12:12:48263 virtual void SaveUserDisplayEmail(const std::string& user_id,
[email protected]eddc251a2012-03-06 15:44:14264 const std::string& display_email) = 0;
265
[email protected]202f0142013-10-18 12:12:48266 // Returns the display email for user |user_id| if it is known (was
[email protected]eddc251a2012-03-06 15:44:14267 // previously set by a |SaveUserDisplayEmail| call).
[email protected]202f0142013-10-18 12:12:48268 // Otherwise, returns |user_id| itself.
[email protected]eddc251a2012-03-06 15:44:14269 virtual std::string GetUserDisplayEmail(
[email protected]202f0142013-10-18 12:12:48270 const std::string& user_id) const = 0;
[email protected]6c3bdc22013-07-08 18:12:44271
[email protected]a43c12e2012-03-06 21:57:10272 // Returns true if current user is an owner.
273 virtual bool IsCurrentUserOwner() const = 0;
[email protected]eddc251a2012-03-06 15:44:14274
[email protected]a43c12e2012-03-06 21:57:10275 // Returns true if current user is not existing one (hasn't signed in before).
276 virtual bool IsCurrentUserNew() const = 0;
277
[email protected]bdee4042012-12-07 07:36:30278 // Returns true if data stored or cached for the current user outside that
279 // user's cryptohome (wallpaper, avatar, OAuth token status, display name,
280 // display email) is ephemeral.
281 virtual bool IsCurrentUserNonCryptohomeDataEphemeral() const = 0;
[email protected]8e85e9462012-03-13 11:23:23282
[email protected]91545872012-11-21 13:58:27283 // Returns true if the current user's session can be locked (i.e. the user has
284 // a password with which to unlock the session).
285 virtual bool CanCurrentUserLock() const = 0;
286
[email protected]e718e6f2013-04-15 16:01:59287 // Returns true if at least one user has signed in.
[email protected]a43c12e2012-03-06 21:57:10288 virtual bool IsUserLoggedIn() const = 0;
[email protected]eddc251a2012-03-06 15:44:14289
[email protected]364aaef2012-12-04 12:18:13290 // Returns true if we're logged in as a regular user.
291 virtual bool IsLoggedInAsRegularUser() const = 0;
292
[email protected]eddc251a2012-03-06 15:44:14293 // Returns true if we're logged in as a demo user.
294 virtual bool IsLoggedInAsDemoUser() const = 0;
295
[email protected]4b9b73692012-11-01 06:35:55296 // Returns true if we're logged in as a public account.
297 virtual bool IsLoggedInAsPublicAccount() const = 0;
298
[email protected]eddc251a2012-03-06 15:44:14299 // Returns true if we're logged in as a Guest.
300 virtual bool IsLoggedInAsGuest() const = 0;
301
[email protected]a2774c382013-01-16 14:35:38302 // Returns true if we're logged in as a locally managed user.
303 virtual bool IsLoggedInAsLocallyManagedUser() const = 0;
304
[email protected]974bab52013-03-19 09:28:24305 // Returns true if we're logged in as a kiosk app.
306 virtual bool IsLoggedInAsKioskApp() const = 0;
307
[email protected]d4f22f22012-05-05 00:44:55308 // Returns true if we're logged in as the stub user used for testing on Linux.
[email protected]93cc27b2012-03-21 12:44:32309 virtual bool IsLoggedInAsStub() const = 0;
310
[email protected]d4f22f22012-05-05 00:44:55311 // Returns true if we're logged in and browser has been started i.e.
[email protected]fe7c4872012-05-10 20:06:03312 // browser_creator.LaunchBrowser(...) was called after sign in
[email protected]d4f22f22012-05-05 00:44:55313 // or restart after crash.
314 virtual bool IsSessionStarted() const = 0;
315
[email protected]2622feb82013-05-28 20:41:38316 // Returns true iff browser has been restarted after crash and UserManager
317 // finished restoring user sessions.
318 virtual bool UserSessionsRestored() const = 0;
319
[email protected]cf50d182012-12-15 08:37:07320 // Returns true when the browser has crashed and restarted during the current
321 // user's session.
322 virtual bool HasBrowserRestarted() const = 0;
323
[email protected]202f0142013-10-18 12:12:48324 // Returns true if data stored or cached for the user with the given user id
[email protected]bdee4042012-12-07 07:36:30325 // address outside that user's cryptohome (wallpaper, avatar, OAuth token
326 // status, display name, display email) is to be treated as ephemeral.
327 virtual bool IsUserNonCryptohomeDataEphemeral(
[email protected]202f0142013-10-18 12:12:48328 const std::string& user_id) const = 0;
[email protected]9b4976f2012-08-29 17:58:40329
[email protected]202f0142013-10-18 12:12:48330 // Method that allows to set |flow| for user identified by |user_id|.
[email protected]1a2a6d52013-02-22 19:20:53331 // Flow should be set before login attempt.
332 // Takes ownership of the |flow|, |flow| will be deleted in case of login
333 // failure.
[email protected]202f0142013-10-18 12:12:48334 virtual void SetUserFlow(const std::string& user_id, UserFlow* flow) = 0;
[email protected]1a2a6d52013-02-22 19:20:53335
336 // Return user flow for current user. Returns instance of DefaultUserFlow if
337 // no flow was defined for current user, or user is not logged in.
338 // Returned value should not be cached.
339 virtual UserFlow* GetCurrentUserFlow() const = 0;
340
[email protected]202f0142013-10-18 12:12:48341 // Return user flow for user identified by |user_id|. Returns instance of
[email protected]1a2a6d52013-02-22 19:20:53342 // DefaultUserFlow if no flow was defined for user.
343 // Returned value should not be cached.
[email protected]202f0142013-10-18 12:12:48344 virtual UserFlow* GetUserFlow(const std::string& user_id) const = 0;
[email protected]1a2a6d52013-02-22 19:20:53345
[email protected]202f0142013-10-18 12:12:48346 // Resets user flow for user identified by |user_id|.
347 virtual void ResetUserFlow(const std::string& user_id) = 0;
[email protected]1a2a6d52013-02-22 19:20:53348
[email protected]e282cc62013-03-30 17:39:43349 // Gets/sets chrome oauth client id and secret for kiosk app mode. The default
[email protected]44426242013-09-13 22:35:34350 // values can be overridden with kiosk auth file.
[email protected]e282cc62013-03-30 17:39:43351 virtual bool GetAppModeChromeClientOAuthInfo(
352 std::string* chrome_client_id,
353 std::string* chrome_client_secret) = 0;
354 virtual void SetAppModeChromeClientOAuthInfo(
355 const std::string& chrome_client_id,
356 const std::string& chrome_client_secret) = 0;
357
[email protected]eddc251a2012-03-06 15:44:14358 virtual void AddObserver(Observer* obs) = 0;
359 virtual void RemoveObserver(Observer* obs) = 0;
360
[email protected]7cad6b0d2013-04-25 20:29:32361 virtual void AddSessionStateObserver(UserSessionStateObserver* obs) = 0;
362 virtual void RemoveSessionStateObserver(UserSessionStateObserver* obs) = 0;
363
[email protected]eddc251a2012-03-06 15:44:14364 virtual void NotifyLocalStateChanged() = 0;
[email protected]9a68d3a2013-04-22 16:26:54365
[email protected]59c61c812013-06-22 00:38:14366 // Returns true if locally managed users allowed.
367 virtual bool AreLocallyManagedUsersAllowed() const = 0;
368
[email protected]202f0142013-10-18 12:12:48369 // Returns profile dir for the user identified by |user_id|.
370 virtual base::FilePath GetUserProfileDir(const std::string& user_id)
371 const = 0;
[email protected]44426242013-09-13 22:35:34372
[email protected]0b7fc202013-10-10 23:24:53373 // Changes browser locale (selects best suitable locale from different
[email protected]fcb10a482013-11-13 20:08:43374 // user settings). Returns true if callback will be called.
375 virtual bool RespectLocalePreference(
376 Profile* profile,
377 const User* user,
378 scoped_ptr<locale_util::SwitchLanguageCallback> callback) const = 0;
[email protected]0b7fc202013-10-10 23:24:53379
[email protected]9a68d3a2013-04-22 16:26:54380 private:
381 friend class ScopedUserManagerEnabler;
382
383 // Sets the singleton to the given |user_manager|, taking ownership. Returns
384 // the previous value of the singleton, passing ownership.
385 static UserManager* SetForTesting(UserManager* user_manager);
386};
387
[email protected]1cfc9a1f2013-06-13 20:15:30388// Helper class for unit tests. Initializes the UserManager singleton to the
389// given |user_manager| and tears it down again on destruction. If the singleton
390// had already been initialized, its previous value is restored after tearing
391// down |user_manager|.
[email protected]9a68d3a2013-04-22 16:26:54392class ScopedUserManagerEnabler {
393 public:
394 // Takes ownership of |user_manager|.
395 explicit ScopedUserManagerEnabler(UserManager* user_manager);
396 ~ScopedUserManagerEnabler();
397
398 private:
399 UserManager* previous_user_manager_;
400
401 DISALLOW_COPY_AND_ASSIGN(ScopedUserManagerEnabler);
402};
403
[email protected]1cfc9a1f2013-06-13 20:15:30404// Helper class for unit tests. Initializes the UserManager singleton on
405// construction and tears it down again on destruction.
[email protected]9a68d3a2013-04-22 16:26:54406class ScopedTestUserManager {
407 public:
408 ScopedTestUserManager();
409 ~ScopedTestUserManager();
410
411 private:
[email protected]9a68d3a2013-04-22 16:26:54412 DISALLOW_COPY_AND_ASSIGN(ScopedTestUserManager);
[email protected]bab1bceb2010-02-02 18:25:05413};
414
415} // namespace chromeos
416
[email protected]83d82d42014-05-16 02:04:42417#endif // CHROME_BROWSER_CHROMEOS_LOGIN_USERS_USER_MANAGER_H_