blob: cf398fad8ff871a63338a83a38cc064a049320be [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]4d390782014-08-15 09:22:585#ifndef COMPONENTS_USER_MANAGER_USER_MANAGER_H_
6#define COMPONENTS_USER_MANAGER_USER_MANAGER_H_
[email protected]bab1bceb2010-02-02 18:25:057
8#include <string>
[email protected]bab1bceb2010-02-02 18:25:059
alemate33433e22016-01-13 14:50:3010#include "base/callback_forward.h"
avi5dd91f82015-12-25 22:30:4611#include "base/macros.h"
alemate33433e22016-01-13 14:50:3012#include "base/strings/string16.h"
[email protected]2fda9972014-07-23 14:51:5913#include "components/user_manager/user.h"
[email protected]4d390782014-08-15 09:22:5814#include "components/user_manager/user_manager_export.h"
merkulovab82b7132014-11-17 11:06:5015#include "components/user_manager/user_type.h"
[email protected]c2a7e682011-03-16 13:03:1816
alemate3ffbde6f2015-11-03 02:02:5517class AccountId;
alemate8730a2f2015-12-19 07:13:0918class PrefService;
alemate3ffbde6f2015-11-03 02:02:5519
[email protected]4d390782014-08-15 09:22:5820namespace user_manager {
21
Xiyuan Xiadfe3a9f2017-11-13 21:46:2622class ScopedUserManager;
[email protected]773a8142011-03-02 16:44:1123class RemoveUserDelegate;
[email protected]8f0d8ecd12010-04-20 11:51:3024
[email protected]4d390782014-08-15 09:22:5825// Interface for UserManagerBase - that provides base implementation for
26// Chrome OS user management. Typical features:
27// * Get list of all know users (who have logged into this Chrome OS device)
28// * Keep track for logged in/LRU users, active user in multi-user session.
29// * Find/modify users, store user meta-data such as display name/email.
30class USER_MANAGER_EXPORT UserManager {
[email protected]bab1bceb2010-02-02 18:25:0531 public:
[email protected]61a9fb32011-08-03 21:00:5132 // Interface that observers of UserManager must implement in order
33 // to receive notification when local state preferences is changed
34 class Observer {
35 public:
[email protected]64f784cc2013-02-16 02:14:2136 // Called when the local state preferences is changed.
[email protected]f8622a42013-06-07 14:12:3637 virtual void LocalStateChanged(UserManager* user_manager);
[email protected]61a9fb32011-08-03 21:00:5138
xiyuan66e41772016-12-13 21:57:5839 // Called when the image of the given user is changed.
40 virtual void OnUserImageChanged(const User& user);
41
42 // Called when the profile image download for the given user fails or
43 // user has the default profile image or no porfile image at all.
44 virtual void OnUserProfileImageUpdateFailed(const User& user);
45
46 // Called when the profile image for the given user is downloaded.
47 // |profile_image| contains the downloaded profile image.
48 virtual void OnUserProfileImageUpdated(const User& user,
49 const gfx::ImageSkia& profile_image);
50
Daria Yakovlevaea3ce4b2017-10-11 19:51:5951 // Called when any of the device cros settings which are responsible for
52 // user sign in are changed.
53 virtual void OnUsersSignInConstraintsChanged();
54
[email protected]61a9fb32011-08-03 21:00:5155 protected:
[email protected]7cad6b0d2013-04-25 20:29:3256 virtual ~Observer();
57 };
58
xiyuan5d8d3ba2017-03-01 21:34:4059 // TODO(xiyuan): Refactor and move this observer out of UserManager.
[email protected]cfad8752013-06-04 16:58:3460 // Observer interface that defines methods used to notify on user session /
61 // active user state changes. Default implementation is empty.
[email protected]7cad6b0d2013-04-25 20:29:3262 class UserSessionStateObserver {
63 public:
[email protected]cfad8752013-06-04 16:58:3464 // Called when active user has changed.
[email protected]4d390782014-08-15 09:22:5865 virtual void ActiveUserChanged(const User* active_user);
[email protected]cfad8752013-06-04 16:58:3466
[email protected]ad87c672013-10-09 21:01:3667 // Called when another user got added to the existing session.
[email protected]4d390782014-08-15 09:22:5868 virtual void UserAddedToSession(const User* added_user);
[email protected]ad87c672013-10-09 21:01:3669
[email protected]7cad6b0d2013-04-25 20:29:3270 // Called right before notifying on user change so that those who rely
alemate3ffbde6f2015-11-03 02:02:5571 // on account_id hash would be accessing up-to-date value.
[email protected]cfad8752013-06-04 16:58:3472 virtual void ActiveUserHashChanged(const std::string& hash);
[email protected]7cad6b0d2013-04-25 20:29:3273
74 protected:
75 virtual ~UserSessionStateObserver();
[email protected]61a9fb32011-08-03 21:00:5176 };
77
[email protected]6dd76822013-11-26 12:04:1178 // Data retrieved from user account.
79 class UserAccountData {
80 public:
[email protected]96920152013-12-04 21:00:1681 UserAccountData(const base::string16& display_name,
82 const base::string16& given_name,
[email protected]6dd76822013-11-26 12:04:1183 const std::string& locale);
84 ~UserAccountData();
[email protected]96920152013-12-04 21:00:1685 const base::string16& display_name() const { return display_name_; }
86 const base::string16& given_name() const { return given_name_; }
[email protected]6dd76822013-11-26 12:04:1187 const std::string& locale() const { return locale_; }
88
89 private:
[email protected]96920152013-12-04 21:00:1690 const base::string16 display_name_;
91 const base::string16 given_name_;
[email protected]6dd76822013-11-26 12:04:1192 const std::string locale_;
93
94 DISALLOW_COPY_AND_ASSIGN(UserAccountData);
95 };
96
[email protected]4d390782014-08-15 09:22:5897 // Initializes UserManager instance to this. Normally should be called right
98 // after creation so that user_manager::UserManager::Get() doesn't fail.
99 // Tests could call this method if they are replacing existing UserManager
100 // instance with their own test instance.
alemate33433e22016-01-13 14:50:30101 virtual void Initialize();
[email protected]eddc251a2012-03-06 15:44:14102
[email protected]4d390782014-08-15 09:22:58103 // Checks whether the UserManager instance has been created already.
104 // This method is not thread-safe and must be called from the main UI thread.
[email protected]9a68d3a2013-04-22 16:26:54105 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
[email protected]4d390782014-08-15 09:22:58113 // Sets UserManager instance to NULL. Always call Shutdown() first.
114 // This method is not thread-safe and must be called from the main UI thread.
115 void Destroy();
[email protected]9a68d3a2013-04-22 16:26:54116
[email protected]4d390782014-08-15 09:22:58117 // Returns UserManager instance or will crash if it is |NULL| (has either not
118 // been created yet or is already destroyed). This method is not thread-safe
[email protected]9a68d3a2013-04-22 16:26:54119 // 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 virtual ~UserManager();
123
[email protected]8e85e9462012-03-13 11:23:23124 // Returns a list of users who have logged into this device previously. This
125 // is sorted by last login date with the most recent user at the beginning.
[email protected]4d390782014-08-15 09:22:58126 virtual const UserList& GetUsers() const = 0;
[email protected]eddc251a2012-03-06 15:44:14127
rsorokinc21feee52014-09-30 10:53:16128 // Returns list of users allowed for logging in into multi-profile session.
[email protected]9319f082014-06-20 00:35:44129 // Users that have a policy that prevents them from being added to the
130 // multi-profile session will still be part of this list as long as they
131 // are regular users (i.e. not a public session/supervised etc.).
132 // Returns an empty list in case when primary user is not a regular one or
merkulovab82b7132014-11-17 11:06:50133 // has a policy that prohibits it to be part of multi-profile session.
rsorokinc21feee52014-09-30 10:53:16134 virtual UserList GetUsersAllowedForMultiProfile() const = 0;
[email protected]04887162013-05-29 23:01:51135
[email protected]e718e6f2013-04-15 16:01:59136 // Returns a list of users who are currently logged in.
[email protected]4d390782014-08-15 09:22:58137 virtual const UserList& GetLoggedInUsers() const = 0;
[email protected]e718e6f2013-04-15 16:01:59138
[email protected]c8d19f82013-05-18 09:09:41139 // Returns a list of users who are currently logged in in the LRU order -
140 // so the active user is the first one in the list. If there is no user logged
141 // in, the current user will be returned.
[email protected]4d390782014-08-15 09:22:58142 virtual const UserList& GetLRULoggedInUsers() const = 0;
[email protected]c8d19f82013-05-18 09:09:41143
[email protected]8f484832013-09-18 02:52:56144 // Returns a list of users who can unlock the device.
[email protected]402fcdd2014-01-24 12:51:52145 // This list is based on policy and whether user is able to do unlock.
146 // Policy:
147 // * If user has primary-only policy then it is the only user in unlock users.
148 // * Otherwise all users with unrestricted policy are added to this list.
149 // All users that are unable to perform unlock are excluded from this list.
[email protected]4d390782014-08-15 09:22:58150 virtual UserList GetUnlockUsers() const = 0;
[email protected]8f484832013-09-18 02:52:56151
alemate3ffbde6f2015-11-03 02:02:55152 // Returns account Id of the owner user. Returns an empty Id if there is
[email protected]204c19c2013-09-01 23:27:46153 // no owner for the device.
alemate3ffbde6f2015-11-03 02:02:55154 virtual const AccountId& GetOwnerAccountId() const = 0;
[email protected]204c19c2013-09-01 23:27:46155
alemate3ffbde6f2015-11-03 02:02:55156 // Indicates that a user with the given |account_id| has just logged in. The
[email protected]8e85e9462012-03-13 11:23:23157 // persistent list is updated accordingly if the user is not ephemeral.
[email protected]503fc5b2012-06-14 17:52:12158 // |browser_restart| is true when reloading Chrome after crash to distinguish
159 // from normal sign in flow.
[email protected]40429592013-03-29 17:52:33160 // |username_hash| is used to identify homedir mount point.
alemate3ffbde6f2015-11-03 02:02:55161 virtual void UserLoggedIn(const AccountId& account_id,
[email protected]40429592013-03-29 17:52:33162 const std::string& username_hash,
Alexander Alekseev2a5efd62017-12-06 07:27:28163 bool browser_restart,
164 bool is_child) = 0;
[email protected]eddc251a2012-03-06 15:44:14165
alemate3ffbde6f2015-11-03 02:02:55166 // Switches to active user identified by |account_id|. User has to be logged
167 // in.
168 virtual void SwitchActiveUser(const AccountId& account_id) = 0;
[email protected]e718e6f2013-04-15 16:01:59169
nkostylev5df7e992014-09-26 09:03:47170 // Switches to the last active user (called after crash happens and session
171 // restore has completed).
172 virtual void SwitchToLastActiveUser() = 0;
173
xiyuan834f3bc2016-10-26 19:40:53174 // Invoked by session manager to inform session start.
175 virtual void OnSessionStarted() = 0;
[email protected]d4f22f22012-05-05 00:44:55176
atwilsond5a7eabf2017-03-09 13:18:39177 // Invoked once profile initialization has been completed. This allows various
178 // subsystems (for example, policy framework) to skip an expensive online
179 // initialization process, and also allows the signin screen to force an
180 // online signin if it knows that profile initialization has not yet
181 // completed. |user| is the User associated with the profile that has
182 // completed initialization.
183 virtual void OnProfileInitialized(User* user) = 0;
184
[email protected]eddc251a2012-03-06 15:44:14185 // Removes the user from the device. Note, it will verify that the given user
186 // isn't the owner, so calling this method for the owner will take no effect.
187 // Note, |delegate| can be NULL.
alemate3ffbde6f2015-11-03 02:02:55188 virtual void RemoveUser(const AccountId& account_id,
[email protected]eddc251a2012-03-06 15:44:14189 RemoveUserDelegate* delegate) = 0;
190
191 // Removes the user from the persistent list only. Also removes the user's
192 // picture.
alemate3ffbde6f2015-11-03 02:02:55193 virtual void RemoveUserFromList(const AccountId& account_id) = 0;
[email protected]eddc251a2012-03-06 15:44:14194
alemate3ffbde6f2015-11-03 02:02:55195 // Returns true if a user with the given account id is found in the persistent
[email protected]202f0142013-10-18 12:12:48196 // list or currently logged in as ephemeral.
alemate3ffbde6f2015-11-03 02:02:55197 virtual bool IsKnownUser(const AccountId& account_id) const = 0;
[email protected]eddc251a2012-03-06 15:44:14198
alemate3ffbde6f2015-11-03 02:02:55199 // Returns the user with the given account id if found in the persistent
[email protected]8e85e9462012-03-13 11:23:23200 // list or currently logged in as ephemeral. Returns |NULL| otherwise.
alemate3ffbde6f2015-11-03 02:02:55201 virtual const User* FindUser(const AccountId& account_id) const = 0;
[email protected]0a5da5b2013-10-01 13:48:37202
alemate3ffbde6f2015-11-03 02:02:55203 // Returns the user with the given account id if found in the persistent
[email protected]25206cc2013-11-18 07:47:18204 // list or currently logged in as ephemeral. Returns |NULL| otherwise.
205 // Same as FindUser but returns non-const pointer to User object.
alemate3ffbde6f2015-11-03 02:02:55206 virtual User* FindUserAndModify(const AccountId& account_id) = 0;
[email protected]25206cc2013-11-18 07:47:18207
[email protected]e718e6f2013-04-15 16:01:59208 // Returns the logged-in user that is currently active within this session.
209 // There could be multiple users logged in at the the same but for now
210 // we support only one of them being active.
[email protected]4d390782014-08-15 09:22:58211 virtual const User* GetActiveUser() const = 0;
212 virtual User* GetActiveUser() = 0;
[email protected]e718e6f2013-04-15 16:01:59213
[email protected]8f484832013-09-18 02:52:56214 // Returns the primary user of the current session. It is recorded for the
215 // first signed-in user and does not change thereafter.
[email protected]4d390782014-08-15 09:22:58216 virtual const User* GetPrimaryUser() const = 0;
[email protected]8f484832013-09-18 02:52:56217
[email protected]eddc251a2012-03-06 15:44:14218 // Saves user's oauth token status in local state preferences.
219 virtual void SaveUserOAuthStatus(
alemate3ffbde6f2015-11-03 02:02:55220 const AccountId& account_id,
[email protected]4d390782014-08-15 09:22:58221 User::OAuthTokenStatus oauth_token_status) = 0;
[email protected]eddc251a2012-03-06 15:44:14222
[email protected]f727a352014-01-25 22:52:46223 // Saves a flag indicating whether online authentication against GAIA should
224 // be enforced during the user's next sign-in.
alemate3ffbde6f2015-11-03 02:02:55225 virtual void SaveForceOnlineSignin(const AccountId& account_id,
[email protected]f727a352014-01-25 22:52:46226 bool force_online_signin) = 0;
227
[email protected]7aa538b2012-06-06 00:27:38228 // Saves user's displayed name in local state preferences.
229 // Ignored If there is no such user.
alemate3ffbde6f2015-11-03 02:02:55230 virtual void SaveUserDisplayName(const AccountId& account_id,
[email protected]96920152013-12-04 21:00:16231 const base::string16& display_name) = 0;
[email protected]7aa538b2012-06-06 00:27:38232
[email protected]c2b68c82013-09-24 02:49:39233 // Updates data upon User Account download.
alemate3ffbde6f2015-11-03 02:02:55234 virtual void UpdateUserAccountData(const AccountId& account_id,
[email protected]6dd76822013-11-26 12:04:11235 const UserAccountData& account_data) = 0;
[email protected]c2b68c82013-09-24 02:49:39236
alemate3ffbde6f2015-11-03 02:02:55237 // Returns the display name for user |account_id| if it is known (was
[email protected]7aa538b2012-06-06 00:27:38238 // previously set by a |SaveUserDisplayName| call).
239 // Otherwise, returns an empty string.
[email protected]96920152013-12-04 21:00:16240 virtual base::string16 GetUserDisplayName(
alemate3ffbde6f2015-11-03 02:02:55241 const AccountId& account_id) const = 0;
[email protected]7aa538b2012-06-06 00:27:38242
[email protected]2f5b4832012-05-15 21:41:37243 // Saves user's displayed (non-canonical) email in local state preferences.
[email protected]eddc251a2012-03-06 15:44:14244 // Ignored If there is no such user.
alemate3ffbde6f2015-11-03 02:02:55245 virtual void SaveUserDisplayEmail(const AccountId& account_id,
[email protected]eddc251a2012-03-06 15:44:14246 const std::string& display_email) = 0;
247
alemate3ffbde6f2015-11-03 02:02:55248 // Returns the display email for user |account_id| if it is known (was
[email protected]eddc251a2012-03-06 15:44:14249 // previously set by a |SaveUserDisplayEmail| call).
alemate3ffbde6f2015-11-03 02:02:55250 // Otherwise, returns |account_id| itself.
251 virtual std::string GetUserDisplayEmail(
252 const AccountId& account_id) const = 0;
[email protected]6c3bdc22013-07-08 18:12:44253
Alexander Alekseev2a5efd62017-12-06 07:27:28254 // Saves user's type for |user| into local state preferences.
255 virtual void SaveUserType(const User* user) = 0;
merkulovab82b7132014-11-17 11:06:50256
[email protected]a43c12e2012-03-06 21:57:10257 // Returns true if current user is an owner.
258 virtual bool IsCurrentUserOwner() const = 0;
[email protected]eddc251a2012-03-06 15:44:14259
[email protected]a43c12e2012-03-06 21:57:10260 // Returns true if current user is not existing one (hasn't signed in before).
261 virtual bool IsCurrentUserNew() const = 0;
262
[email protected]bdee4042012-12-07 07:36:30263 // Returns true if data stored or cached for the current user outside that
264 // user's cryptohome (wallpaper, avatar, OAuth token status, display name,
265 // display email) is ephemeral.
266 virtual bool IsCurrentUserNonCryptohomeDataEphemeral() const = 0;
[email protected]8e85e9462012-03-13 11:23:23267
rsorokin79e93442016-04-29 07:54:12268 // Returns true if data stored or cached for the current user inside that
269 // user's cryptohome is ephemeral.
270 virtual bool IsCurrentUserCryptohomeDataEphemeral() const = 0;
271
[email protected]91545872012-11-21 13:58:27272 // Returns true if the current user's session can be locked (i.e. the user has
273 // a password with which to unlock the session).
274 virtual bool CanCurrentUserLock() const = 0;
275
[email protected]e718e6f2013-04-15 16:01:59276 // Returns true if at least one user has signed in.
[email protected]a43c12e2012-03-06 21:57:10277 virtual bool IsUserLoggedIn() const = 0;
[email protected]eddc251a2012-03-06 15:44:14278
merkulovac3ae44d2014-11-17 09:35:07279 // Returns true if we're logged in as a user with gaia account.
280 virtual bool IsLoggedInAsUserWithGaiaAccount() const = 0;
281
merkulova6d6cb08a2014-12-11 09:40:02282 // Returns true if we're logged in as a child user.
283 virtual bool IsLoggedInAsChildUser() const = 0;
[email protected]364aaef2012-12-04 12:18:13284
[email protected]4b9b73692012-11-01 06:35:55285 // Returns true if we're logged in as a public account.
286 virtual bool IsLoggedInAsPublicAccount() const = 0;
287
[email protected]eddc251a2012-03-06 15:44:14288 // Returns true if we're logged in as a Guest.
289 virtual bool IsLoggedInAsGuest() const = 0;
290
merkulova6d6cb08a2014-12-11 09:40:02291 // Returns true if we're logged in as a legacy supervised user.
[email protected]933cc2e22014-07-18 13:26:57292 virtual bool IsLoggedInAsSupervisedUser() const = 0;
[email protected]a2774c382013-01-16 14:35:38293
[email protected]974bab52013-03-19 09:28:24294 // Returns true if we're logged in as a kiosk app.
295 virtual bool IsLoggedInAsKioskApp() const = 0;
296
peletskyi53c440d2016-10-25 15:09:55297 // Returns true if we're logged in as a ARC kiosk app.
298 virtual bool IsLoggedInAsArcKioskApp() const = 0;
299
[email protected]d4f22f22012-05-05 00:44:55300 // Returns true if we're logged in as the stub user used for testing on Linux.
[email protected]93cc27b2012-03-21 12:44:32301 virtual bool IsLoggedInAsStub() const = 0;
302
alemate3ffbde6f2015-11-03 02:02:55303 // Returns true if data stored or cached for the user with the given
304 // |account_id|
[email protected]bdee4042012-12-07 07:36:30305 // address outside that user's cryptohome (wallpaper, avatar, OAuth token
306 // status, display name, display email) is to be treated as ephemeral.
307 virtual bool IsUserNonCryptohomeDataEphemeral(
alemate3ffbde6f2015-11-03 02:02:55308 const AccountId& account_id) const = 0;
[email protected]9b4976f2012-08-29 17:58:40309
rsorokin79e93442016-04-29 07:54:12310 virtual bool IsUserCryptohomeDataEphemeral(
311 const AccountId& account_id) const = 0;
312
[email protected]eddc251a2012-03-06 15:44:14313 virtual void AddObserver(Observer* obs) = 0;
314 virtual void RemoveObserver(Observer* obs) = 0;
315
[email protected]7cad6b0d2013-04-25 20:29:32316 virtual void AddSessionStateObserver(UserSessionStateObserver* obs) = 0;
317 virtual void RemoveSessionStateObserver(UserSessionStateObserver* obs) = 0;
318
[email protected]eddc251a2012-03-06 15:44:14319 virtual void NotifyLocalStateChanged() = 0;
xiyuan66e41772016-12-13 21:57:58320 virtual void NotifyUserImageChanged(const User& user) = 0;
321 virtual void NotifyUserProfileImageUpdateFailed(const User& user) = 0;
322 virtual void NotifyUserProfileImageUpdated(
323 const User& user,
324 const gfx::ImageSkia& profile_image) = 0;
Daria Yakovlevaea3ce4b2017-10-11 19:51:59325 virtual void NotifyUsersSignInConstraintsChanged() = 0;
[email protected]9a68d3a2013-04-22 16:26:54326
Pavol Markoa9808a62017-08-31 16:22:37327 // Resets this profile to be regarded as if it has never been initialized
328 // before. Used on profile wipe.
329 virtual void ResetProfileEverInitialized(const AccountId& account_id) = 0;
merkulova57466b92014-10-09 10:55:12330
[email protected]933cc2e22014-07-18 13:26:57331 // Returns true if supervised users allowed.
332 virtual bool AreSupervisedUsersAllowed() const = 0;
[email protected]59c61c812013-06-22 00:38:14333
Daria Yakovlevaea3ce4b2017-10-11 19:51:59334 // Returns true if guest user is allowed.
335 virtual bool IsGuestSessionAllowed() const = 0;
336
337 // Returns true if the |user|, which has a GAIA account is allowed according
338 // to device settings and policies.
339 // Accept only users who has gaia account.
340 virtual bool IsGaiaUserAllowed(const User& user) const = 0;
341
342 // Returns true if |user| is allowed depending on device policies.
343 // Accepted user types: USER_TYPE_REGULAR, USER_TYPE_GUEST,
344 // USER_TYPE_SUPERVISED, USER_TYPE_CHILD.
345 virtual bool IsUserAllowed(const User& user) const = 0;
346
alemate8730a2f2015-12-19 07:13:09347 // Returns "Local State" PrefService instance.
348 virtual PrefService* GetLocalState() const = 0;
nkostyleveb9ce0de52015-05-07 22:23:24349
alemate33433e22016-01-13 14:50:30350 // Checks for platform-specific known users matching given |user_email| and
351 // |gaia_id|. If data matches a known account, fills |out_account_id| with
352 // account id and returns true.
353 virtual bool GetPlatformKnownUserId(const std::string& user_email,
354 const std::string& gaia_id,
355 AccountId* out_account_id) const = 0;
356
357 // Returns account id of the Guest user.
358 virtual const AccountId& GetGuestAccountId() const = 0;
359
360 // Returns true if this is first exec after boot.
361 virtual bool IsFirstExecAfterBoot() const = 0;
362
363 // Actually removes cryptohome.
364 virtual void AsyncRemoveCryptohome(const AccountId& account_id) const = 0;
365
366 // Returns true if |account_id| is Guest user.
367 virtual bool IsGuestAccountId(const AccountId& account_id) const = 0;
368
369 // Returns true if |account_id| is Stub user.
370 virtual bool IsStubAccountId(const AccountId& account_id) const = 0;
371
372 // Returns true if |account_id| is supervised.
373 virtual bool IsSupervisedAccountId(const AccountId& account_id) const = 0;
374
Alexander Alekseev2a5efd62017-12-06 07:27:28375 virtual bool IsDeviceLocalAccountMarkedForRemoval(
376 const AccountId& account_id) const = 0;
377
alemate33433e22016-01-13 14:50:30378 // Returns true when the browser has crashed and restarted during the current
379 // user's session.
380 virtual bool HasBrowserRestarted() const = 0;
381
alemate9e6d7102016-01-13 16:04:48382 // Returns image from resources bundle.
383 virtual const gfx::ImageSkia& GetResourceImagekiaNamed(int id) const = 0;
384
385 // Returns string from resources bundle.
386 virtual base::string16 GetResourceStringUTF16(int string_id) const = 0;
387
alemate33433e22016-01-13 14:50:30388 // Schedules CheckAndResolveLocale using given task runner and
389 // |on_resolved_callback| as reply callback.
390 virtual void ScheduleResolveLocale(
391 const std::string& locale,
Claudio DeSouza591a9972018-02-21 17:27:16392 base::OnceClosure on_resolved_callback,
alemate33433e22016-01-13 14:50:30393 std::string* out_resolved_locale) const = 0;
394
alemate9e6d7102016-01-13 16:04:48395 // Returns true if |image_index| is a valid default user image index.
396 virtual bool IsValidDefaultUserImageId(int image_index) const = 0;
397
Alexander Alekseev2a5efd62017-12-06 07:27:28398 UserType CalculateUserType(const AccountId& account_id,
399 const User* user,
400 bool browser_restart,
401 bool is_child) const;
402
[email protected]4d390782014-08-15 09:22:58403 protected:
404 // Sets UserManager instance.
405 static void SetInstance(UserManager* user_manager);
[email protected]9a68d3a2013-04-22 16:26:54406
[email protected]4d390782014-08-15 09:22:58407 // Pointer to the existing UserManager instance (if any).
408 // Usually is set by calling Initialize(), reset by calling Destroy().
409 // Not owned since specific implementation of UserManager should decide on its
410 // own appropriate owner. For src/chrome implementation such place is
411 // g_browser_process->platform_part().
412 static UserManager* instance;
413
414 private:
Xiyuan Xiadfe3a9f2017-11-13 21:46:26415 friend class ScopedUserManager;
[email protected]4d390782014-08-15 09:22:58416
417 // Same as Get() but doesn't won't crash is current instance is NULL.
418 static UserManager* GetForTesting();
419
420 // Sets UserManager instance to the given |user_manager|.
421 // Returns the previous value of the instance.
[email protected]9a68d3a2013-04-22 16:26:54422 static UserManager* SetForTesting(UserManager* user_manager);
423};
424
xiyuan5d8d3ba2017-03-01 21:34:40425// TODO(xiyuan): Move this along with UserSessionStateObserver
426class USER_MANAGER_EXPORT ScopedUserSessionStateObserver {
427 public:
428 explicit ScopedUserSessionStateObserver(
429 UserManager::UserSessionStateObserver* observer);
430 ~ScopedUserSessionStateObserver();
431
432 private:
433 UserManager::UserSessionStateObserver* const observer_;
434
435 DISALLOW_COPY_AND_ASSIGN(ScopedUserSessionStateObserver);
436};
437
[email protected]4d390782014-08-15 09:22:58438} // namespace user_manager
[email protected]9a68d3a2013-04-22 16:26:54439
[email protected]4d390782014-08-15 09:22:58440#endif // COMPONENTS_USER_MANAGER_USER_MANAGER_H_