[email protected] | e09155d | 2012-02-17 23:57:31 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
[email protected] | bab1bceb | 2010-02-02 18:25:05 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
[email protected] | 56f0ffc8 | 2010-02-04 21:30:37 | [diff] [blame] | 5 | #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_USER_MANAGER_H_ |
| 6 | #define CHROME_BROWSER_CHROMEOS_LOGIN_USER_MANAGER_H_ |
[email protected] | bab1bceb | 2010-02-02 18:25:05 | [diff] [blame] | 7 | |
| 8 | #include <string> |
[email protected] | bab1bceb | 2010-02-02 18:25:05 | [diff] [blame] | 9 | |
[email protected] | 39db0670 | 2011-11-10 16:31:24 | [diff] [blame] | 10 | #include "chrome/browser/chromeos/login/user.h" |
[email protected] | 1a2a6d5 | 2013-02-22 19:20:53 | [diff] [blame] | 11 | #include "chrome/browser/chromeos/login/user_flow.h" |
[email protected] | bab1bceb | 2010-02-02 18:25:05 | [diff] [blame] | 12 | |
[email protected] | b1de2c7 | 2013-02-06 02:45:47 | [diff] [blame] | 13 | class PrefRegistrySimple; |
[email protected] | c2a7e68 | 2011-03-16 13:03:18 | [diff] [blame] | 14 | |
[email protected] | 8f0d8ecd1 | 2010-04-20 11:51:30 | [diff] [blame] | 15 | namespace chromeos { |
[email protected] | 39db0670 | 2011-11-10 16:31:24 | [diff] [blame] | 16 | |
[email protected] | 773a814 | 2011-03-02 16:44:11 | [diff] [blame] | 17 | class RemoveUserDelegate; |
[email protected] | c4e418f | 2012-10-15 15:53:45 | [diff] [blame] | 18 | class UserImageManager; |
[email protected] | 8f0d8ecd1 | 2010-04-20 11:51:30 | [diff] [blame] | 19 | |
[email protected] | eddc251a | 2012-03-06 15:44:14 | [diff] [blame] | 20 | // Base class for UserManagerImpl - provides a mechanism for discovering users |
| 21 | // who have logged into this Chrome OS device before and updating that list. |
| 22 | class UserManager { |
[email protected] | bab1bceb | 2010-02-02 18:25:05 | [diff] [blame] | 23 | public: |
[email protected] | 61a9fb3 | 2011-08-03 21:00:51 | [diff] [blame] | 24 | // Interface that observers of UserManager must implement in order |
| 25 | // to receive notification when local state preferences is changed |
| 26 | class Observer { |
| 27 | public: |
[email protected] | 64f784cc | 2013-02-16 02:14:21 | [diff] [blame] | 28 | // Called when the local state preferences is changed. |
[email protected] | f8622a4 | 2013-06-07 14:12:36 | [diff] [blame] | 29 | virtual void LocalStateChanged(UserManager* user_manager); |
[email protected] | 61a9fb3 | 2011-08-03 21:00:51 | [diff] [blame] | 30 | |
| 31 | protected: |
[email protected] | 7cad6b0d | 2013-04-25 20:29:32 | [diff] [blame] | 32 | virtual ~Observer(); |
| 33 | }; |
| 34 | |
[email protected] | cfad875 | 2013-06-04 16:58:34 | [diff] [blame] | 35 | // TODO(nkostylev): Refactor and move this observer out of UserManager. |
| 36 | // Observer interface that defines methods used to notify on user session / |
| 37 | // active user state changes. Default implementation is empty. |
[email protected] | 7cad6b0d | 2013-04-25 20:29:32 | [diff] [blame] | 38 | class UserSessionStateObserver { |
| 39 | public: |
[email protected] | cfad875 | 2013-06-04 16:58:34 | [diff] [blame] | 40 | // Called when active user has changed. |
| 41 | virtual void ActiveUserChanged(const User* active_user); |
| 42 | |
[email protected] | 7cad6b0d | 2013-04-25 20:29:32 | [diff] [blame] | 43 | // Called right before notifying on user change so that those who rely |
| 44 | // on user_id hash would be accessing up-to-date value. |
[email protected] | cfad875 | 2013-06-04 16:58:34 | [diff] [blame] | 45 | virtual void ActiveUserHashChanged(const std::string& hash); |
[email protected] | 7cad6b0d | 2013-04-25 20:29:32 | [diff] [blame] | 46 | |
[email protected] | 2622feb8 | 2013-05-28 20:41:38 | [diff] [blame] | 47 | // Called when UserManager finishes restoring user sessions after crash. |
[email protected] | cfad875 | 2013-06-04 16:58:34 | [diff] [blame] | 48 | virtual void PendingUserSessionsRestoreFinished(); |
[email protected] | 2622feb8 | 2013-05-28 20:41:38 | [diff] [blame] | 49 | |
[email protected] | 7cad6b0d | 2013-04-25 20:29:32 | [diff] [blame] | 50 | protected: |
| 51 | virtual ~UserSessionStateObserver(); |
[email protected] | 61a9fb3 | 2011-08-03 21:00:51 | [diff] [blame] | 52 | }; |
| 53 | |
[email protected] | 89dbb177 | 2012-07-17 13:47:25 | [diff] [blame] | 54 | // Username for stub login when not running on ChromeOS. |
| 55 | static const char kStubUser[]; |
| 56 | |
[email protected] | 68e3169 | 2013-05-20 13:08:27 | [diff] [blame] | 57 | // Magic e-mail addresses are bad. They exist here because some code already |
| 58 | // depends on them and it is hard to figure out what. Any user types added in |
| 59 | // the future should be identified by a new |UserType|, not a new magic e-mail |
| 60 | // address. |
| 61 | // Username for Guest session user. |
| 62 | static const char kGuestUserName[]; |
| 63 | |
[email protected] | a2774c38 | 2013-01-16 14:35:38 | [diff] [blame] | 64 | // Domain that is used for all locally managed users. |
| 65 | static const char kLocallyManagedUserDomain[]; |
| 66 | |
[email protected] | 68e3169 | 2013-05-20 13:08:27 | [diff] [blame] | 67 | // The retail mode user has a magic, domainless e-mail address. |
| 68 | static const char kRetailModeUserName[]; |
| 69 | |
[email protected] | 9a68d3a | 2013-04-22 16:26:54 | [diff] [blame] | 70 | // Creates the singleton instance. This method is not thread-safe and must be |
[email protected] | eddc251a | 2012-03-06 15:44:14 | [diff] [blame] | 71 | // called from the main UI thread. |
[email protected] | 9a68d3a | 2013-04-22 16:26:54 | [diff] [blame] | 72 | static void Initialize(); |
[email protected] | eddc251a | 2012-03-06 15:44:14 | [diff] [blame] | 73 | |
[email protected] | 9a68d3a | 2013-04-22 16:26:54 | [diff] [blame] | 74 | // Checks whether the singleton instance has been created already. This method |
| 75 | // is not thread-safe and must be called from the main UI thread. |
| 76 | static bool IsInitialized(); |
| 77 | |
| 78 | // Shuts down the UserManager. After this method has been called, the |
| 79 | // singleton has unregistered itself as an observer but remains available so |
| 80 | // that other classes can access it during their shutdown. This method is not |
| 81 | // thread-safe and must be called from the main UI thread. |
| 82 | virtual void Shutdown() = 0; |
| 83 | |
| 84 | // Destroys the singleton instance. Always call Shutdown() first. This method |
| 85 | // is not thread-safe and must be called from the main UI thread. |
| 86 | static void Destroy(); |
| 87 | |
| 88 | // Returns the singleton instance or |NULL| if the singleton has either not |
| 89 | // been created yet or is already destroyed. This method is not thread-safe |
| 90 | // and must be called from the main UI thread. |
| 91 | static UserManager* Get(); |
[email protected] | 79bac42 | 2013-04-22 15:44:26 | [diff] [blame] | 92 | |
[email protected] | eddc251a | 2012-03-06 15:44:14 | [diff] [blame] | 93 | // Registers user manager preferences. |
[email protected] | b1de2c7 | 2013-02-06 02:45:47 | [diff] [blame] | 94 | static void RegisterPrefs(PrefRegistrySimple* registry); |
[email protected] | eddc251a | 2012-03-06 15:44:14 | [diff] [blame] | 95 | |
[email protected] | d81240b | 2013-09-20 21:05:28 | [diff] [blame] | 96 | // Returns true if multiple profiles support is allowed. |
| 97 | static bool IsMultipleProfilesAllowed(); |
| 98 | |
[email protected] | eddc251a | 2012-03-06 15:44:14 | [diff] [blame] | 99 | virtual ~UserManager(); |
| 100 | |
[email protected] | c4e418f | 2012-10-15 15:53:45 | [diff] [blame] | 101 | virtual UserImageManager* GetUserImageManager() = 0; |
| 102 | |
[email protected] | 8e85e946 | 2012-03-13 11:23:23 | [diff] [blame] | 103 | // Returns a list of users who have logged into this device previously. This |
| 104 | // is sorted by last login date with the most recent user at the beginning. |
[email protected] | eddc251a | 2012-03-06 15:44:14 | [diff] [blame] | 105 | virtual const UserList& GetUsers() const = 0; |
| 106 | |
[email protected] | 0488716 | 2013-05-29 23:01:51 | [diff] [blame] | 107 | // Returns list of users admitted for logging in into multiprofile session. |
| 108 | virtual UserList GetUsersAdmittedForMultiProfile() const = 0; |
| 109 | |
[email protected] | e718e6f | 2013-04-15 16:01:59 | [diff] [blame] | 110 | // Returns a list of users who are currently logged in. |
| 111 | virtual const UserList& GetLoggedInUsers() const = 0; |
| 112 | |
[email protected] | c8d19f8 | 2013-05-18 09:09:41 | [diff] [blame] | 113 | // Returns a list of users who are currently logged in in the LRU order - |
| 114 | // so the active user is the first one in the list. If there is no user logged |
| 115 | // in, the current user will be returned. |
| 116 | virtual const UserList& GetLRULoggedInUsers() = 0; |
| 117 | |
[email protected] | 8f48483 | 2013-09-18 02:52:56 | [diff] [blame] | 118 | // Returns a list of users who can unlock the device. |
| 119 | virtual UserList GetUnlockUsers() const = 0; |
| 120 | |
[email protected] | 204c19c | 2013-09-01 23:27:46 | [diff] [blame] | 121 | // Returns the email of the owner user. Returns an empty string if there is |
| 122 | // no owner for the device. |
| 123 | virtual const std::string& GetOwnerEmail() = 0; |
| 124 | |
[email protected] | 4042959 | 2013-03-29 17:52:33 | [diff] [blame] | 125 | // Indicates that a user with the given |email| has just logged in. The |
[email protected] | 8e85e946 | 2012-03-13 11:23:23 | [diff] [blame] | 126 | // persistent list is updated accordingly if the user is not ephemeral. |
[email protected] | 503fc5b | 2012-06-14 17:52:12 | [diff] [blame] | 127 | // |browser_restart| is true when reloading Chrome after crash to distinguish |
| 128 | // from normal sign in flow. |
[email protected] | 4042959 | 2013-03-29 17:52:33 | [diff] [blame] | 129 | // |username_hash| is used to identify homedir mount point. |
| 130 | virtual void UserLoggedIn(const std::string& email, |
| 131 | const std::string& username_hash, |
| 132 | bool browser_restart) = 0; |
[email protected] | eddc251a | 2012-03-06 15:44:14 | [diff] [blame] | 133 | |
[email protected] | e718e6f | 2013-04-15 16:01:59 | [diff] [blame] | 134 | // Switches to active user identified by |email|. User has to be logged in. |
| 135 | virtual void SwitchActiveUser(const std::string& email) = 0; |
| 136 | |
[email protected] | d4f22f2 | 2012-05-05 00:44:55 | [diff] [blame] | 137 | // Called when browser session is started i.e. after |
[email protected] | fe7c487 | 2012-05-10 20:06:03 | [diff] [blame] | 138 | // browser_creator.LaunchBrowser(...) was called after user sign in. |
[email protected] | d4f22f2 | 2012-05-05 00:44:55 | [diff] [blame] | 139 | // When user is at the image screen IsUserLoggedIn() will return true |
[email protected] | 5311469 | 2013-09-13 22:07:18 | [diff] [blame] | 140 | // but IsSessionStarted() will return false. During the kiosk splash screen, |
| 141 | // we perform additional initialization after the user is logged in but |
| 142 | // before the session has been started. |
[email protected] | d4f22f2 | 2012-05-05 00:44:55 | [diff] [blame] | 143 | // Fires NOTIFICATION_SESSION_STARTED. |
| 144 | virtual void SessionStarted() = 0; |
| 145 | |
[email protected] | 0fbe5d6 | 2013-05-23 16:10:16 | [diff] [blame] | 146 | // Usually is called when Chrome is restarted after a crash and there's an |
| 147 | // active session. First user (one that is passed with --login-user) Chrome |
| 148 | // session has been already restored at this point. This method asks session |
| 149 | // manager for all active user sessions, marks them as logged in |
| 150 | // and notifies observers. |
| 151 | virtual void RestoreActiveSessions() = 0; |
| 152 | |
[email protected] | f024768b | 2013-08-13 20:06:41 | [diff] [blame] | 153 | // Creates locally managed user with given |display_name| and|local_user_id| |
| 154 | // and persists that to user list. Also links this user identified by |
| 155 | // |sync_user_id| to manager with a |manager_id|. |
| 156 | // Returns created user, or existing user if there already |
[email protected] | c4e10a3 | 2013-01-24 15:05:13 | [diff] [blame] | 157 | // was locally managed user with such display name. |
[email protected] | f024768b | 2013-08-13 20:06:41 | [diff] [blame] | 158 | // TODO(antrim): Refactor into a single struct to have only 1 getter. |
[email protected] | c4e10a3 | 2013-01-24 15:05:13 | [diff] [blame] | 159 | virtual const User* CreateLocallyManagedUserRecord( |
[email protected] | 059b94f0 | 2013-05-31 09:26:34 | [diff] [blame] | 160 | const std::string& manager_id, |
[email protected] | f024768b | 2013-08-13 20:06:41 | [diff] [blame] | 161 | const std::string& local_user_id, |
| 162 | const std::string& sync_user_id, |
[email protected] | c4e10a3 | 2013-01-24 15:05:13 | [diff] [blame] | 163 | const string16& display_name) = 0; |
| 164 | |
[email protected] | e3ed9f80 | 2013-02-28 21:46:43 | [diff] [blame] | 165 | // Generates unique username for locally managed user. |
| 166 | virtual std::string GenerateUniqueLocallyManagedUserId() = 0; |
| 167 | |
[email protected] | eddc251a | 2012-03-06 15:44:14 | [diff] [blame] | 168 | // Removes the user from the device. Note, it will verify that the given user |
| 169 | // isn't the owner, so calling this method for the owner will take no effect. |
| 170 | // Note, |delegate| can be NULL. |
| 171 | virtual void RemoveUser(const std::string& email, |
| 172 | RemoveUserDelegate* delegate) = 0; |
| 173 | |
| 174 | // Removes the user from the persistent list only. Also removes the user's |
| 175 | // picture. |
| 176 | virtual void RemoveUserFromList(const std::string& email) = 0; |
| 177 | |
[email protected] | 8e85e946 | 2012-03-13 11:23:23 | [diff] [blame] | 178 | // Returns true if a user with the given email address is found in the |
| 179 | // persistent list or currently logged in as ephemeral. |
[email protected] | eddc251a | 2012-03-06 15:44:14 | [diff] [blame] | 180 | virtual bool IsKnownUser(const std::string& email) const = 0; |
| 181 | |
[email protected] | 8e85e946 | 2012-03-13 11:23:23 | [diff] [blame] | 182 | // Returns the user with the given email address if found in the persistent |
| 183 | // list or currently logged in as ephemeral. Returns |NULL| otherwise. |
[email protected] | eddc251a | 2012-03-06 15:44:14 | [diff] [blame] | 184 | virtual const User* FindUser(const std::string& email) const = 0; |
| 185 | |
[email protected] | c4e10a3 | 2013-01-24 15:05:13 | [diff] [blame] | 186 | // Returns the locally managed user with the given |display_name| if found in |
| 187 | // the persistent list. Returns |NULL| otherwise. |
| 188 | virtual const User* FindLocallyManagedUser( |
| 189 | const string16& display_name) const = 0; |
| 190 | |
[email protected] | 0a5da5b | 2013-10-01 13:48:37 | [diff] [blame^] | 191 | // Returns the locally managed user with the given |sync_id| if found in |
| 192 | // the persistent list. Returns |NULL| otherwise. |
| 193 | virtual const User* FindLocallyManagedUserBySyncId( |
| 194 | const std::string& sync_id) const = 0; |
| 195 | |
[email protected] | eddc251a | 2012-03-06 15:44:14 | [diff] [blame] | 196 | // Returns the logged-in user. |
[email protected] | e718e6f | 2013-04-15 16:01:59 | [diff] [blame] | 197 | // TODO(nkostylev): Deprecate this call, move clients to GetActiveUser(). |
| 198 | // http://crbug.com/230852 |
[email protected] | c4e418f | 2012-10-15 15:53:45 | [diff] [blame] | 199 | virtual const User* GetLoggedInUser() const = 0; |
| 200 | virtual User* GetLoggedInUser() = 0; |
[email protected] | eddc251a | 2012-03-06 15:44:14 | [diff] [blame] | 201 | |
[email protected] | e718e6f | 2013-04-15 16:01:59 | [diff] [blame] | 202 | // Returns the logged-in user that is currently active within this session. |
| 203 | // There could be multiple users logged in at the the same but for now |
| 204 | // we support only one of them being active. |
| 205 | virtual const User* GetActiveUser() const = 0; |
| 206 | virtual User* GetActiveUser() = 0; |
| 207 | |
[email protected] | 8f48483 | 2013-09-18 02:52:56 | [diff] [blame] | 208 | // Returns the primary user of the current session. It is recorded for the |
| 209 | // first signed-in user and does not change thereafter. |
| 210 | virtual const User* GetPrimaryUser() const = 0; |
| 211 | |
[email protected] | eddc251a | 2012-03-06 15:44:14 | [diff] [blame] | 212 | // Saves user's oauth token status in local state preferences. |
| 213 | virtual void SaveUserOAuthStatus( |
| 214 | const std::string& username, |
| 215 | User::OAuthTokenStatus oauth_token_status) = 0; |
| 216 | |
[email protected] | 7aa538b | 2012-06-06 00:27:38 | [diff] [blame] | 217 | // Saves user's displayed name in local state preferences. |
| 218 | // Ignored If there is no such user. |
| 219 | virtual void SaveUserDisplayName(const std::string& username, |
| 220 | const string16& display_name) = 0; |
| 221 | |
[email protected] | c2b68c8 | 2013-09-24 02:49:39 | [diff] [blame] | 222 | // Updates data upon User Account download. |
| 223 | virtual void UpdateUserAccountData(const std::string& username, |
| 224 | const string16& display_name, |
| 225 | const std::string& locale) = 0; |
| 226 | |
[email protected] | 7aa538b | 2012-06-06 00:27:38 | [diff] [blame] | 227 | // Returns the display name for user |username| if it is known (was |
| 228 | // previously set by a |SaveUserDisplayName| call). |
| 229 | // Otherwise, returns an empty string. |
| 230 | virtual string16 GetUserDisplayName( |
| 231 | const std::string& username) const = 0; |
| 232 | |
[email protected] | 2f5b483 | 2012-05-15 21:41:37 | [diff] [blame] | 233 | // Saves user's displayed (non-canonical) email in local state preferences. |
[email protected] | eddc251a | 2012-03-06 15:44:14 | [diff] [blame] | 234 | // Ignored If there is no such user. |
| 235 | virtual void SaveUserDisplayEmail(const std::string& username, |
| 236 | const std::string& display_email) = 0; |
| 237 | |
| 238 | // Returns the display email for user |username| if it is known (was |
| 239 | // previously set by a |SaveUserDisplayEmail| call). |
| 240 | // Otherwise, returns |username| itself. |
| 241 | virtual std::string GetUserDisplayEmail( |
| 242 | const std::string& username) const = 0; |
| 243 | |
[email protected] | f024768b | 2013-08-13 20:06:41 | [diff] [blame] | 244 | // Returns sync_user_id for locally managed user with |managed_user_id| or |
| 245 | // empty string if such user is not found or it doesn't have |
| 246 | // sync_user_id defined. |
| 247 | virtual std::string GetManagedUserSyncId( |
| 248 | const std::string& managed_user_id) const = 0; |
| 249 | |
[email protected] | 059b94f0 | 2013-05-31 09:26:34 | [diff] [blame] | 250 | // Returns the display name for manager of user |managed_user_id| if it is |
| 251 | // known (was previously set by a |SaveUserDisplayName| call). |
| 252 | // Otherwise, returns a manager id. |
| 253 | virtual string16 GetManagerDisplayNameForManagedUser( |
| 254 | const std::string& managed_user_id) const = 0; |
| 255 | |
| 256 | // Returns the user id for manager of user |managed_user_id| if it is known |
| 257 | // (user is actually a managed user). |
| 258 | // Otherwise, returns an empty string. |
| 259 | virtual std::string GetManagerUserIdForManagedUser( |
| 260 | const std::string& managed_user_id) const = 0; |
| 261 | |
[email protected] | 6c3bdc2 | 2013-07-08 18:12:44 | [diff] [blame] | 262 | // Returns the display email for manager of user |managed_user_id| if it is |
| 263 | // known (user is actually a managed user). |
| 264 | // Otherwise, returns an empty string. |
| 265 | virtual std::string GetManagerDisplayEmailForManagedUser( |
| 266 | const std::string& managed_user_id) const = 0; |
| 267 | |
[email protected] | a43c12e | 2012-03-06 21:57:10 | [diff] [blame] | 268 | // Returns true if current user is an owner. |
| 269 | virtual bool IsCurrentUserOwner() const = 0; |
[email protected] | eddc251a | 2012-03-06 15:44:14 | [diff] [blame] | 270 | |
[email protected] | a43c12e | 2012-03-06 21:57:10 | [diff] [blame] | 271 | // Returns true if current user is not existing one (hasn't signed in before). |
| 272 | virtual bool IsCurrentUserNew() const = 0; |
| 273 | |
[email protected] | bdee404 | 2012-12-07 07:36:30 | [diff] [blame] | 274 | // Returns true if data stored or cached for the current user outside that |
| 275 | // user's cryptohome (wallpaper, avatar, OAuth token status, display name, |
| 276 | // display email) is ephemeral. |
| 277 | virtual bool IsCurrentUserNonCryptohomeDataEphemeral() const = 0; |
[email protected] | 8e85e946 | 2012-03-13 11:23:23 | [diff] [blame] | 278 | |
[email protected] | 9154587 | 2012-11-21 13:58:27 | [diff] [blame] | 279 | // Returns true if the current user's session can be locked (i.e. the user has |
| 280 | // a password with which to unlock the session). |
| 281 | virtual bool CanCurrentUserLock() const = 0; |
| 282 | |
[email protected] | e718e6f | 2013-04-15 16:01:59 | [diff] [blame] | 283 | // Returns true if at least one user has signed in. |
[email protected] | a43c12e | 2012-03-06 21:57:10 | [diff] [blame] | 284 | virtual bool IsUserLoggedIn() const = 0; |
[email protected] | eddc251a | 2012-03-06 15:44:14 | [diff] [blame] | 285 | |
[email protected] | 364aaef | 2012-12-04 12:18:13 | [diff] [blame] | 286 | // Returns true if we're logged in as a regular user. |
| 287 | virtual bool IsLoggedInAsRegularUser() const = 0; |
| 288 | |
[email protected] | eddc251a | 2012-03-06 15:44:14 | [diff] [blame] | 289 | // Returns true if we're logged in as a demo user. |
| 290 | virtual bool IsLoggedInAsDemoUser() const = 0; |
| 291 | |
[email protected] | 4b9b7369 | 2012-11-01 06:35:55 | [diff] [blame] | 292 | // Returns true if we're logged in as a public account. |
| 293 | virtual bool IsLoggedInAsPublicAccount() const = 0; |
| 294 | |
[email protected] | eddc251a | 2012-03-06 15:44:14 | [diff] [blame] | 295 | // Returns true if we're logged in as a Guest. |
| 296 | virtual bool IsLoggedInAsGuest() const = 0; |
| 297 | |
[email protected] | a2774c38 | 2013-01-16 14:35:38 | [diff] [blame] | 298 | // Returns true if we're logged in as a locally managed user. |
| 299 | virtual bool IsLoggedInAsLocallyManagedUser() const = 0; |
| 300 | |
[email protected] | 974bab5 | 2013-03-19 09:28:24 | [diff] [blame] | 301 | // Returns true if we're logged in as a kiosk app. |
| 302 | virtual bool IsLoggedInAsKioskApp() const = 0; |
| 303 | |
[email protected] | d4f22f2 | 2012-05-05 00:44:55 | [diff] [blame] | 304 | // Returns true if we're logged in as the stub user used for testing on Linux. |
[email protected] | 93cc27b | 2012-03-21 12:44:32 | [diff] [blame] | 305 | virtual bool IsLoggedInAsStub() const = 0; |
| 306 | |
[email protected] | d4f22f2 | 2012-05-05 00:44:55 | [diff] [blame] | 307 | // Returns true if we're logged in and browser has been started i.e. |
[email protected] | fe7c487 | 2012-05-10 20:06:03 | [diff] [blame] | 308 | // browser_creator.LaunchBrowser(...) was called after sign in |
[email protected] | d4f22f2 | 2012-05-05 00:44:55 | [diff] [blame] | 309 | // or restart after crash. |
| 310 | virtual bool IsSessionStarted() const = 0; |
| 311 | |
[email protected] | 2622feb8 | 2013-05-28 20:41:38 | [diff] [blame] | 312 | // Returns true iff browser has been restarted after crash and UserManager |
| 313 | // finished restoring user sessions. |
| 314 | virtual bool UserSessionsRestored() const = 0; |
| 315 | |
[email protected] | cf50d18 | 2012-12-15 08:37:07 | [diff] [blame] | 316 | // Returns true when the browser has crashed and restarted during the current |
| 317 | // user's session. |
| 318 | virtual bool HasBrowserRestarted() const = 0; |
| 319 | |
[email protected] | bdee404 | 2012-12-07 07:36:30 | [diff] [blame] | 320 | // Returns true if data stored or cached for the user with the given email |
| 321 | // address outside that user's cryptohome (wallpaper, avatar, OAuth token |
| 322 | // status, display name, display email) is to be treated as ephemeral. |
| 323 | virtual bool IsUserNonCryptohomeDataEphemeral( |
| 324 | const std::string& email) const = 0; |
[email protected] | 9b4976f | 2012-08-29 17:58:40 | [diff] [blame] | 325 | |
[email protected] | e3ed9f80 | 2013-02-28 21:46:43 | [diff] [blame] | 326 | // Create a record about starting locally managed user creation transaction. |
| 327 | virtual void StartLocallyManagedUserCreationTransaction( |
| 328 | const string16& display_name) = 0; |
| 329 | |
| 330 | // Add user id to locally managed user creation transaction record. |
| 331 | virtual void SetLocallyManagedUserCreationTransactionUserId( |
| 332 | const std::string& email) = 0; |
| 333 | |
| 334 | // Remove locally managed user creation transaction record. |
| 335 | virtual void CommitLocallyManagedUserCreationTransaction() = 0; |
| 336 | |
[email protected] | 1a2a6d5 | 2013-02-22 19:20:53 | [diff] [blame] | 337 | // Method that allows to set |flow| for user identified by |email|. |
| 338 | // Flow should be set before login attempt. |
| 339 | // Takes ownership of the |flow|, |flow| will be deleted in case of login |
| 340 | // failure. |
| 341 | virtual void SetUserFlow(const std::string& email, UserFlow* flow) = 0; |
| 342 | |
| 343 | // Return user flow for current user. Returns instance of DefaultUserFlow if |
| 344 | // no flow was defined for current user, or user is not logged in. |
| 345 | // Returned value should not be cached. |
| 346 | virtual UserFlow* GetCurrentUserFlow() const = 0; |
| 347 | |
| 348 | // Return user flow for user identified by |email|. Returns instance of |
| 349 | // DefaultUserFlow if no flow was defined for user. |
| 350 | // Returned value should not be cached. |
| 351 | virtual UserFlow* GetUserFlow(const std::string& email) const = 0; |
| 352 | |
[email protected] | 4442624 | 2013-09-13 22:35:34 | [diff] [blame] | 353 | // Resets user flow for user identified by |email|. |
[email protected] | 1a2a6d5 | 2013-02-22 19:20:53 | [diff] [blame] | 354 | virtual void ResetUserFlow(const std::string& email) = 0; |
| 355 | |
[email protected] | e282cc6 | 2013-03-30 17:39:43 | [diff] [blame] | 356 | // Gets/sets chrome oauth client id and secret for kiosk app mode. The default |
[email protected] | 4442624 | 2013-09-13 22:35:34 | [diff] [blame] | 357 | // values can be overridden with kiosk auth file. |
[email protected] | e282cc6 | 2013-03-30 17:39:43 | [diff] [blame] | 358 | virtual bool GetAppModeChromeClientOAuthInfo( |
| 359 | std::string* chrome_client_id, |
| 360 | std::string* chrome_client_secret) = 0; |
| 361 | virtual void SetAppModeChromeClientOAuthInfo( |
| 362 | const std::string& chrome_client_id, |
| 363 | const std::string& chrome_client_secret) = 0; |
| 364 | |
[email protected] | eddc251a | 2012-03-06 15:44:14 | [diff] [blame] | 365 | virtual void AddObserver(Observer* obs) = 0; |
| 366 | virtual void RemoveObserver(Observer* obs) = 0; |
| 367 | |
[email protected] | 7cad6b0d | 2013-04-25 20:29:32 | [diff] [blame] | 368 | virtual void AddSessionStateObserver(UserSessionStateObserver* obs) = 0; |
| 369 | virtual void RemoveSessionStateObserver(UserSessionStateObserver* obs) = 0; |
| 370 | |
[email protected] | eddc251a | 2012-03-06 15:44:14 | [diff] [blame] | 371 | virtual void NotifyLocalStateChanged() = 0; |
[email protected] | 9a68d3a | 2013-04-22 16:26:54 | [diff] [blame] | 372 | |
[email protected] | 59c61c81 | 2013-06-22 00:38:14 | [diff] [blame] | 373 | // Returns true if locally managed users allowed. |
| 374 | virtual bool AreLocallyManagedUsersAllowed() const = 0; |
| 375 | |
[email protected] | 4442624 | 2013-09-13 22:35:34 | [diff] [blame] | 376 | // Returns profile dir for the user identified by |email|. |
| 377 | virtual base::FilePath GetUserProfileDir(const std::string& email) const = 0; |
| 378 | |
[email protected] | 9a68d3a | 2013-04-22 16:26:54 | [diff] [blame] | 379 | private: |
| 380 | friend class ScopedUserManagerEnabler; |
| 381 | |
| 382 | // Sets the singleton to the given |user_manager|, taking ownership. Returns |
| 383 | // the previous value of the singleton, passing ownership. |
| 384 | static UserManager* SetForTesting(UserManager* user_manager); |
| 385 | }; |
| 386 | |
[email protected] | 1cfc9a1f | 2013-06-13 20:15:30 | [diff] [blame] | 387 | // Helper class for unit tests. Initializes the UserManager singleton to the |
| 388 | // given |user_manager| and tears it down again on destruction. If the singleton |
| 389 | // had already been initialized, its previous value is restored after tearing |
| 390 | // down |user_manager|. |
[email protected] | 9a68d3a | 2013-04-22 16:26:54 | [diff] [blame] | 391 | class ScopedUserManagerEnabler { |
| 392 | public: |
| 393 | // Takes ownership of |user_manager|. |
| 394 | explicit ScopedUserManagerEnabler(UserManager* user_manager); |
| 395 | ~ScopedUserManagerEnabler(); |
| 396 | |
| 397 | private: |
| 398 | UserManager* previous_user_manager_; |
| 399 | |
| 400 | DISALLOW_COPY_AND_ASSIGN(ScopedUserManagerEnabler); |
| 401 | }; |
| 402 | |
[email protected] | 1cfc9a1f | 2013-06-13 20:15:30 | [diff] [blame] | 403 | // Helper class for unit tests. Initializes the UserManager singleton on |
| 404 | // construction and tears it down again on destruction. |
[email protected] | 9a68d3a | 2013-04-22 16:26:54 | [diff] [blame] | 405 | class ScopedTestUserManager { |
| 406 | public: |
| 407 | ScopedTestUserManager(); |
| 408 | ~ScopedTestUserManager(); |
| 409 | |
| 410 | private: |
[email protected] | 9a68d3a | 2013-04-22 16:26:54 | [diff] [blame] | 411 | DISALLOW_COPY_AND_ASSIGN(ScopedTestUserManager); |
[email protected] | bab1bceb | 2010-02-02 18:25:05 | [diff] [blame] | 412 | }; |
| 413 | |
| 414 | } // namespace chromeos |
| 415 | |
[email protected] | 56f0ffc8 | 2010-02-04 21:30:37 | [diff] [blame] | 416 | #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USER_MANAGER_H_ |