OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_USER_MANAGER_IMPL_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_USER_MANAGER_IMPL_H_ |
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_USER_MANAGER_IMPL_H_ | 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_USER_MANAGER_IMPL_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 28 matching lines...) Expand all Loading... |
39 public ProfileSyncServiceObserver, | 39 public ProfileSyncServiceObserver, |
40 public content::NotificationObserver, | 40 public content::NotificationObserver, |
41 public policy::DeviceLocalAccountPolicyService::Observer { | 41 public policy::DeviceLocalAccountPolicyService::Observer { |
42 public: | 42 public: |
43 virtual ~UserManagerImpl(); | 43 virtual ~UserManagerImpl(); |
44 | 44 |
45 // UserManager implementation: | 45 // UserManager implementation: |
46 virtual void Shutdown() OVERRIDE; | 46 virtual void Shutdown() OVERRIDE; |
47 virtual UserImageManager* GetUserImageManager() OVERRIDE; | 47 virtual UserImageManager* GetUserImageManager() OVERRIDE; |
48 virtual const UserList& GetUsers() const OVERRIDE; | 48 virtual const UserList& GetUsers() const OVERRIDE; |
| 49 virtual const UserList& GetLoggedInUsers() const OVERRIDE; |
49 virtual void UserLoggedIn(const std::string& email, | 50 virtual void UserLoggedIn(const std::string& email, |
50 const std::string& username_hash, | 51 const std::string& username_hash, |
51 bool browser_restart) OVERRIDE; | 52 bool browser_restart) OVERRIDE; |
| 53 virtual void SwitchActiveUser(const std::string& email) OVERRIDE; |
52 virtual void RetailModeUserLoggedIn() OVERRIDE; | 54 virtual void RetailModeUserLoggedIn() OVERRIDE; |
53 virtual void GuestUserLoggedIn() OVERRIDE; | 55 virtual void GuestUserLoggedIn() OVERRIDE; |
54 virtual void KioskAppLoggedIn(const std::string& username) OVERRIDE; | 56 virtual void KioskAppLoggedIn(const std::string& username) OVERRIDE; |
55 virtual void LocallyManagedUserLoggedIn(const std::string& username) OVERRIDE; | 57 virtual void LocallyManagedUserLoggedIn(const std::string& username) OVERRIDE; |
56 virtual void PublicAccountUserLoggedIn(User* user) OVERRIDE; | 58 virtual void PublicAccountUserLoggedIn(User* user) OVERRIDE; |
57 virtual void RegularUserLoggedIn(const std::string& email, | 59 virtual void RegularUserLoggedIn(const std::string& email, |
58 bool browser_restart) OVERRIDE; | 60 bool browser_restart) OVERRIDE; |
59 virtual void RegularUserLoggedInAsEphemeral( | 61 virtual void RegularUserLoggedInAsEphemeral( |
60 const std::string& email) OVERRIDE; | 62 const std::string& email) OVERRIDE; |
61 virtual void SessionStarted() OVERRIDE; | 63 virtual void SessionStarted() OVERRIDE; |
62 virtual void RemoveUser(const std::string& email, | 64 virtual void RemoveUser(const std::string& email, |
63 RemoveUserDelegate* delegate) OVERRIDE; | 65 RemoveUserDelegate* delegate) OVERRIDE; |
64 virtual void RemoveUserFromList(const std::string& email) OVERRIDE; | 66 virtual void RemoveUserFromList(const std::string& email) OVERRIDE; |
65 virtual bool IsKnownUser(const std::string& email) const OVERRIDE; | 67 virtual bool IsKnownUser(const std::string& email) const OVERRIDE; |
66 virtual const User* FindUser(const std::string& email) const OVERRIDE; | 68 virtual const User* FindUser(const std::string& email) const OVERRIDE; |
67 virtual const User* FindLocallyManagedUser( | 69 virtual const User* FindLocallyManagedUser( |
68 const string16& display_name) const OVERRIDE; | 70 const string16& display_name) const OVERRIDE; |
69 virtual const User* GetLoggedInUser() const OVERRIDE; | 71 virtual const User* GetLoggedInUser() const OVERRIDE; |
70 virtual User* GetLoggedInUser() OVERRIDE; | 72 virtual User* GetLoggedInUser() OVERRIDE; |
| 73 virtual const User* GetActiveUser() const OVERRIDE; |
| 74 virtual User* GetActiveUser() OVERRIDE; |
71 virtual void SaveUserOAuthStatus( | 75 virtual void SaveUserOAuthStatus( |
72 const std::string& username, | 76 const std::string& username, |
73 User::OAuthTokenStatus oauth_token_status) OVERRIDE; | 77 User::OAuthTokenStatus oauth_token_status) OVERRIDE; |
74 virtual void SaveUserDisplayName(const std::string& username, | 78 virtual void SaveUserDisplayName(const std::string& username, |
75 const string16& display_name) OVERRIDE; | 79 const string16& display_name) OVERRIDE; |
76 virtual string16 GetUserDisplayName( | 80 virtual string16 GetUserDisplayName( |
77 const std::string& username) const OVERRIDE; | 81 const std::string& username) const OVERRIDE; |
78 virtual void SaveUserDisplayEmail(const std::string& username, | 82 virtual void SaveUserDisplayEmail(const std::string& username, |
79 const std::string& display_email) OVERRIDE; | 83 const std::string& display_email) OVERRIDE; |
80 virtual std::string GetUserDisplayEmail( | 84 virtual std::string GetUserDisplayEmail( |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 | 150 |
147 // Retrieves trusted device policies and removes users from the persistent | 151 // Retrieves trusted device policies and removes users from the persistent |
148 // list if ephemeral users are enabled. Schedules a callback to itself if | 152 // list if ephemeral users are enabled. Schedules a callback to itself if |
149 // trusted device policies are not yet available. | 153 // trusted device policies are not yet available. |
150 void RetrieveTrustedDevicePolicies(); | 154 void RetrieveTrustedDevicePolicies(); |
151 | 155 |
152 // Returns true if trusted device policies have successfully been retrieved | 156 // Returns true if trusted device policies have successfully been retrieved |
153 // and ephemeral users are enabled. | 157 // and ephemeral users are enabled. |
154 bool AreEphemeralUsersEnabled() const; | 158 bool AreEphemeralUsersEnabled() const; |
155 | 159 |
| 160 // Returns a list of users who have logged into this device previously. |
| 161 // Same as GetUsers but used if you need to modify User from that list. |
| 162 UserList& GetUsersAndModify(); |
| 163 |
| 164 // Returns the user with the given email address if found in the persistent |
| 165 // list or currently logged in as ephemeral. Returns |NULL| otherwise. |
| 166 // Same as FindUser but returns non-const pointer to User object. |
| 167 User* FindUserAndModify(const std::string& email); |
| 168 |
156 // Returns the user with the given email address if found in the persistent | 169 // Returns the user with the given email address if found in the persistent |
157 // list. Returns |NULL| otherwise. | 170 // list. Returns |NULL| otherwise. |
158 const User* FindUserInList(const std::string& email) const; | 171 const User* FindUserInList(const std::string& email) const; |
159 | 172 |
160 // Notifies that new user session has started. | 173 // Same as FindUserInList but returns non-const pointer to User object. |
| 174 User* FindUserInListAndModify(const std::string& email); |
| 175 |
| 176 // Notifies that user has logged in. |
| 177 // Sends NOTIFICATION_LOGIN_USER_CHANGED notification. |
161 void NotifyOnLogin(); | 178 void NotifyOnLogin(); |
162 | 179 |
163 // Reads user's oauth token status from local state preferences. | 180 // Reads user's oauth token status from local state preferences. |
164 User::OAuthTokenStatus LoadUserOAuthStatus(const std::string& username) const; | 181 User::OAuthTokenStatus LoadUserOAuthStatus(const std::string& username) const; |
165 | 182 |
166 void SetCurrentUserIsOwner(bool is_current_user_owner); | 183 void SetCurrentUserIsOwner(bool is_current_user_owner); |
167 | 184 |
168 // Updates current user ownership on UI thread. | 185 // Updates current user ownership on UI thread. |
169 void UpdateOwnership(DeviceSettingsService::OwnershipStatus status, | 186 void UpdateOwnership(DeviceSettingsService::OwnershipStatus status, |
170 bool is_owner); | 187 bool is_owner); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 policy::DeviceLocalAccountPolicyService* device_local_account_policy_service_; | 231 policy::DeviceLocalAccountPolicyService* device_local_account_policy_service_; |
215 | 232 |
216 // True if users have been loaded from prefs already. | 233 // True if users have been loaded from prefs already. |
217 bool users_loaded_; | 234 bool users_loaded_; |
218 | 235 |
219 // List of all known users. User instances are owned by |this|. Regular users | 236 // List of all known users. User instances are owned by |this|. Regular users |
220 // are removed by |RemoveUserFromList|, public accounts by | 237 // are removed by |RemoveUserFromList|, public accounts by |
221 // |UpdateAndCleanUpPublicAccounts|. | 238 // |UpdateAndCleanUpPublicAccounts|. |
222 UserList users_; | 239 UserList users_; |
223 | 240 |
224 // The logged-in user. NULL until a user has logged in, then points to one | 241 // List of all users that are logged in current session. These point to User |
| 242 // instances in |users_|. Only one of them could be marked as active. |
| 243 UserList logged_in_users_; |
| 244 |
| 245 // The logged-in user that is currently active in current session. |
| 246 // NULL until a user has logged in, then points to one |
225 // of the User instances in |users_|, the |guest_user_| instance or an | 247 // of the User instances in |users_|, the |guest_user_| instance or an |
226 // ephemeral user instance. | 248 // ephemeral user instance. |
227 User* logged_in_user_; | 249 User* active_user_; |
228 | 250 |
229 // True if SessionStarted() has been called. | 251 // True if SessionStarted() has been called. |
230 bool session_started_; | 252 bool session_started_; |
231 | 253 |
232 // Cached flag of whether currently logged-in user is owner or not. | 254 // Cached flag of whether currently logged-in user is owner or not. |
233 // May be accessed on different threads, requires locking. | 255 // May be accessed on different threads, requires locking. |
234 bool is_current_user_owner_; | 256 bool is_current_user_owner_; |
235 mutable base::Lock is_current_user_owner_lock_; | 257 mutable base::Lock is_current_user_owner_lock_; |
236 | 258 |
237 // Cached flag of whether the currently logged-in user existed before this | 259 // Cached flag of whether the currently logged-in user existed before this |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 | 305 |
284 // Specific flows by user e-mail. | 306 // Specific flows by user e-mail. |
285 FlowMap specific_flows_; | 307 FlowMap specific_flows_; |
286 | 308 |
287 DISALLOW_COPY_AND_ASSIGN(UserManagerImpl); | 309 DISALLOW_COPY_AND_ASSIGN(UserManagerImpl); |
288 }; | 310 }; |
289 | 311 |
290 } // namespace chromeos | 312 } // namespace chromeos |
291 | 313 |
292 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USER_MANAGER_IMPL_H_ | 314 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USER_MANAGER_IMPL_H_ |
OLD | NEW |