| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_CHROMEOS_LOGIN_USERS_USER_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_USERS_USER_MANAGER_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_USERS_USER_MANAGER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_USERS_USER_MANAGER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "chrome/browser/chromeos/login/user_flow.h" | 10 #include "chrome/browser/chromeos/login/user_flow.h" |
| 11 #include "chrome/browser/chromeos/login/users/user.h" | 11 #include "components/user_manager/user.h" |
| 12 | 12 |
| 13 class PrefRegistrySimple; | 13 class PrefRegistrySimple; |
| 14 | 14 |
| 15 namespace chromeos { | 15 namespace chromeos { |
| 16 | 16 |
| 17 class MultiProfileUserController; | 17 class MultiProfileUserController; |
| 18 class RemoveUserDelegate; | 18 class RemoveUserDelegate; |
| 19 class UserImageManager; | 19 class UserImageManager; |
| 20 class SupervisedUserManager; | 20 class SupervisedUserManager; |
| 21 | 21 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 33 protected: | 33 protected: |
| 34 virtual ~Observer(); | 34 virtual ~Observer(); |
| 35 }; | 35 }; |
| 36 | 36 |
| 37 // TODO(nkostylev): Refactor and move this observer out of UserManager. | 37 // TODO(nkostylev): Refactor and move this observer out of UserManager. |
| 38 // Observer interface that defines methods used to notify on user session / | 38 // Observer interface that defines methods used to notify on user session / |
| 39 // active user state changes. Default implementation is empty. | 39 // active user state changes. Default implementation is empty. |
| 40 class UserSessionStateObserver { | 40 class UserSessionStateObserver { |
| 41 public: | 41 public: |
| 42 // Called when active user has changed. | 42 // Called when active user has changed. |
| 43 virtual void ActiveUserChanged(const User* active_user); | 43 virtual void ActiveUserChanged(const user_manager::User* active_user); |
| 44 | 44 |
| 45 // Called when another user got added to the existing session. | 45 // Called when another user got added to the existing session. |
| 46 virtual void UserAddedToSession(const User* added_user); | 46 virtual void UserAddedToSession(const user_manager::User* added_user); |
| 47 | 47 |
| 48 // Called right before notifying on user change so that those who rely | 48 // Called right before notifying on user change so that those who rely |
| 49 // on user_id hash would be accessing up-to-date value. | 49 // on user_id hash would be accessing up-to-date value. |
| 50 virtual void ActiveUserHashChanged(const std::string& hash); | 50 virtual void ActiveUserHashChanged(const std::string& hash); |
| 51 | 51 |
| 52 protected: | 52 protected: |
| 53 virtual ~UserSessionStateObserver(); | 53 virtual ~UserSessionStateObserver(); |
| 54 }; | 54 }; |
| 55 | 55 |
| 56 // Data retrieved from user account. | 56 // Data retrieved from user account. |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 static void RegisterPrefs(PrefRegistrySimple* registry); | 99 static void RegisterPrefs(PrefRegistrySimple* registry); |
| 100 | 100 |
| 101 virtual ~UserManager(); | 101 virtual ~UserManager(); |
| 102 | 102 |
| 103 virtual MultiProfileUserController* GetMultiProfileUserController() = 0; | 103 virtual MultiProfileUserController* GetMultiProfileUserController() = 0; |
| 104 virtual UserImageManager* GetUserImageManager(const std::string& user_id) = 0; | 104 virtual UserImageManager* GetUserImageManager(const std::string& user_id) = 0; |
| 105 virtual SupervisedUserManager* GetSupervisedUserManager() = 0; | 105 virtual SupervisedUserManager* GetSupervisedUserManager() = 0; |
| 106 | 106 |
| 107 // Returns a list of users who have logged into this device previously. This | 107 // Returns a list of users who have logged into this device previously. This |
| 108 // is sorted by last login date with the most recent user at the beginning. | 108 // is sorted by last login date with the most recent user at the beginning. |
| 109 virtual const UserList& GetUsers() const = 0; | 109 virtual const user_manager::UserList& GetUsers() const = 0; |
| 110 | 110 |
| 111 // Returns list of users admitted for logging in into multi-profile session. | 111 // Returns list of users admitted for logging in into multi-profile session. |
| 112 // Users that have a policy that prevents them from being added to the | 112 // Users that have a policy that prevents them from being added to the |
| 113 // multi-profile session will still be part of this list as long as they | 113 // multi-profile session will still be part of this list as long as they |
| 114 // are regular users (i.e. not a public session/supervised etc.). | 114 // are regular users (i.e. not a public session/supervised etc.). |
| 115 // Returns an empty list in case when primary user is not a regular one or | 115 // Returns an empty list in case when primary user is not a regular one or |
| 116 // has a policy that prohibids it to be part of multi-profile session. | 116 // has a policy that prohibids it to be part of multi-profile session. |
| 117 virtual UserList GetUsersAdmittedForMultiProfile() const = 0; | 117 virtual user_manager::UserList GetUsersAdmittedForMultiProfile() const = 0; |
| 118 | 118 |
| 119 // Returns a list of users who are currently logged in. | 119 // Returns a list of users who are currently logged in. |
| 120 virtual const UserList& GetLoggedInUsers() const = 0; | 120 virtual const user_manager::UserList& GetLoggedInUsers() const = 0; |
| 121 | 121 |
| 122 // Returns a list of users who are currently logged in in the LRU order - | 122 // Returns a list of users who are currently logged in in the LRU order - |
| 123 // so the active user is the first one in the list. If there is no user logged | 123 // so the active user is the first one in the list. If there is no user logged |
| 124 // in, the current user will be returned. | 124 // in, the current user will be returned. |
| 125 virtual const UserList& GetLRULoggedInUsers() = 0; | 125 virtual const user_manager::UserList& GetLRULoggedInUsers() = 0; |
| 126 | 126 |
| 127 // Returns a list of users who can unlock the device. | 127 // Returns a list of users who can unlock the device. |
| 128 // This list is based on policy and whether user is able to do unlock. | 128 // This list is based on policy and whether user is able to do unlock. |
| 129 // Policy: | 129 // Policy: |
| 130 // * If user has primary-only policy then it is the only user in unlock users. | 130 // * If user has primary-only policy then it is the only user in unlock users. |
| 131 // * Otherwise all users with unrestricted policy are added to this list. | 131 // * Otherwise all users with unrestricted policy are added to this list. |
| 132 // All users that are unable to perform unlock are excluded from this list. | 132 // All users that are unable to perform unlock are excluded from this list. |
| 133 virtual UserList GetUnlockUsers() const = 0; | 133 virtual user_manager::UserList GetUnlockUsers() const = 0; |
| 134 | 134 |
| 135 // Returns the email of the owner user. Returns an empty string if there is | 135 // Returns the email of the owner user. Returns an empty string if there is |
| 136 // no owner for the device. | 136 // no owner for the device. |
| 137 virtual const std::string& GetOwnerEmail() = 0; | 137 virtual const std::string& GetOwnerEmail() = 0; |
| 138 | 138 |
| 139 // Indicates that a user with the given |user_id| has just logged in. The | 139 // Indicates that a user with the given |user_id| has just logged in. The |
| 140 // persistent list is updated accordingly if the user is not ephemeral. | 140 // persistent list is updated accordingly if the user is not ephemeral. |
| 141 // |browser_restart| is true when reloading Chrome after crash to distinguish | 141 // |browser_restart| is true when reloading Chrome after crash to distinguish |
| 142 // from normal sign in flow. | 142 // from normal sign in flow. |
| 143 // |username_hash| is used to identify homedir mount point. | 143 // |username_hash| is used to identify homedir mount point. |
| (...skipping 22 matching lines...) Expand all Loading... |
| 166 // Removes the user from the persistent list only. Also removes the user's | 166 // Removes the user from the persistent list only. Also removes the user's |
| 167 // picture. | 167 // picture. |
| 168 virtual void RemoveUserFromList(const std::string& user_id) = 0; | 168 virtual void RemoveUserFromList(const std::string& user_id) = 0; |
| 169 | 169 |
| 170 // Returns true if a user with the given user id is found in the persistent | 170 // Returns true if a user with the given user id is found in the persistent |
| 171 // list or currently logged in as ephemeral. | 171 // list or currently logged in as ephemeral. |
| 172 virtual bool IsKnownUser(const std::string& user_id) const = 0; | 172 virtual bool IsKnownUser(const std::string& user_id) const = 0; |
| 173 | 173 |
| 174 // Returns the user with the given user id if found in the persistent | 174 // Returns the user with the given user id if found in the persistent |
| 175 // list or currently logged in as ephemeral. Returns |NULL| otherwise. | 175 // list or currently logged in as ephemeral. Returns |NULL| otherwise. |
| 176 virtual const User* FindUser(const std::string& user_id) const = 0; | 176 virtual const user_manager::User* FindUser( |
| 177 const std::string& user_id) const = 0; |
| 177 | 178 |
| 178 // Returns the user with the given user id if found in the persistent | 179 // Returns the user with the given user id if found in the persistent |
| 179 // list or currently logged in as ephemeral. Returns |NULL| otherwise. | 180 // list or currently logged in as ephemeral. Returns |NULL| otherwise. |
| 180 // Same as FindUser but returns non-const pointer to User object. | 181 // Same as FindUser but returns non-const pointer to User object. |
| 181 virtual User* FindUserAndModify(const std::string& user_id) = 0; | 182 virtual user_manager::User* FindUserAndModify(const std::string& user_id) = 0; |
| 182 | 183 |
| 183 // Returns the logged-in user. | 184 // Returns the logged-in user. |
| 184 // TODO(nkostylev): Deprecate this call, move clients to GetActiveUser(). | 185 // TODO(nkostylev): Deprecate this call, move clients to GetActiveUser(). |
| 185 // http://crbug.com/230852 | 186 // http://crbug.com/230852 |
| 186 virtual const User* GetLoggedInUser() const = 0; | 187 virtual const user_manager::User* GetLoggedInUser() const = 0; |
| 187 virtual User* GetLoggedInUser() = 0; | 188 virtual user_manager::User* GetLoggedInUser() = 0; |
| 188 | 189 |
| 189 // Returns the logged-in user that is currently active within this session. | 190 // Returns the logged-in user that is currently active within this session. |
| 190 // There could be multiple users logged in at the the same but for now | 191 // There could be multiple users logged in at the the same but for now |
| 191 // we support only one of them being active. | 192 // we support only one of them being active. |
| 192 virtual const User* GetActiveUser() const = 0; | 193 virtual const user_manager::User* GetActiveUser() const = 0; |
| 193 virtual User* GetActiveUser() = 0; | 194 virtual user_manager::User* GetActiveUser() = 0; |
| 194 | 195 |
| 195 // Returns the primary user of the current session. It is recorded for the | 196 // Returns the primary user of the current session. It is recorded for the |
| 196 // first signed-in user and does not change thereafter. | 197 // first signed-in user and does not change thereafter. |
| 197 virtual const User* GetPrimaryUser() const = 0; | 198 virtual const user_manager::User* GetPrimaryUser() const = 0; |
| 198 | 199 |
| 199 // Saves user's oauth token status in local state preferences. | 200 // Saves user's oauth token status in local state preferences. |
| 200 virtual void SaveUserOAuthStatus( | 201 virtual void SaveUserOAuthStatus( |
| 201 const std::string& user_id, | 202 const std::string& user_id, |
| 202 User::OAuthTokenStatus oauth_token_status) = 0; | 203 user_manager::User::OAuthTokenStatus oauth_token_status) = 0; |
| 203 | 204 |
| 204 // Saves a flag indicating whether online authentication against GAIA should | 205 // Saves a flag indicating whether online authentication against GAIA should |
| 205 // be enforced during the user's next sign-in. | 206 // be enforced during the user's next sign-in. |
| 206 virtual void SaveForceOnlineSignin(const std::string& user_id, | 207 virtual void SaveForceOnlineSignin(const std::string& user_id, |
| 207 bool force_online_signin) = 0; | 208 bool force_online_signin) = 0; |
| 208 | 209 |
| 209 // Saves user's displayed name in local state preferences. | 210 // Saves user's displayed name in local state preferences. |
| 210 // Ignored If there is no such user. | 211 // Ignored If there is no such user. |
| 211 virtual void SaveUserDisplayName(const std::string& user_id, | 212 virtual void SaveUserDisplayName(const std::string& user_id, |
| 212 const base::string16& display_name) = 0; | 213 const base::string16& display_name) = 0; |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 343 ScopedTestUserManager(); | 344 ScopedTestUserManager(); |
| 344 ~ScopedTestUserManager(); | 345 ~ScopedTestUserManager(); |
| 345 | 346 |
| 346 private: | 347 private: |
| 347 DISALLOW_COPY_AND_ASSIGN(ScopedTestUserManager); | 348 DISALLOW_COPY_AND_ASSIGN(ScopedTestUserManager); |
| 348 }; | 349 }; |
| 349 | 350 |
| 350 } // namespace chromeos | 351 } // namespace chromeos |
| 351 | 352 |
| 352 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USERS_USER_MANAGER_H_ | 353 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USERS_USER_MANAGER_H_ |
| OLD | NEW |