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_IMPL_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_USERS_USER_MANAGER_BASE_H_ |
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_USERS_USER_MANAGER_IMPL_H_ | 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_USERS_USER_MANAGER_BASE_H_ |
7 | 7 |
8 #include <map> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
13 #include "base/containers/hash_tables.h" | |
14 #include "base/memory/linked_ptr.h" | |
15 #include "base/memory/scoped_ptr.h" | |
16 #include "base/observer_list.h" | 13 #include "base/observer_list.h" |
17 #include "base/synchronization/lock.h" | 14 #include "base/synchronization/lock.h" |
18 #include "base/time/time.h" | 15 #include "base/time/time.h" |
19 #include "chrome/browser/chromeos/login/users/avatar/user_image_manager_impl.h" | |
20 #include "chrome/browser/chromeos/login/users/multi_profile_user_controller_dele gate.h" | |
21 #include "chrome/browser/chromeos/login/users/user_manager.h" | 16 #include "chrome/browser/chromeos/login/users/user_manager.h" |
22 #include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h" | |
23 #include "chrome/browser/chromeos/policy/cloud_external_data_policy_observer.h" | |
24 #include "chrome/browser/chromeos/policy/device_local_account_policy_service.h" | |
25 #include "chrome/browser/chromeos/settings/cros_settings.h" | |
26 #include "chrome/browser/chromeos/settings/device_settings_service.h" | |
27 #include "components/user_manager/user.h" | 17 #include "components/user_manager/user.h" |
28 #include "content/public/browser/notification_observer.h" | |
29 #include "content/public/browser/notification_registrar.h" | |
30 | 18 |
31 class PrefService; | 19 class PrefService; |
32 class ProfileSyncService; | 20 class PrefRegistrySimple; |
33 | |
34 namespace policy { | |
35 struct DeviceLocalAccount; | |
36 } | |
37 | 21 |
38 namespace chromeos { | 22 namespace chromeos { |
39 | 23 |
40 class MultiProfileUserController; | |
41 class RemoveUserDelegate; | 24 class RemoveUserDelegate; |
42 class SupervisedUserManagerImpl; | |
43 class SessionLengthLimiter; | |
44 | 25 |
45 // Implementation of the UserManager. | 26 // Base implementation of the UserManager interface. |
46 class UserManagerImpl | 27 class UserManagerBase : public UserManager { |
47 : public UserManager, | |
48 public content::NotificationObserver, | |
49 public policy::CloudExternalDataPolicyObserver::Delegate, | |
50 public policy::DeviceLocalAccountPolicyService::Observer, | |
51 public MultiProfileUserControllerDelegate { | |
52 public: | 28 public: |
53 virtual ~UserManagerImpl(); | 29 virtual ~UserManagerBase(); |
30 | |
31 // Registers UserManagerBase preferences. | |
32 static void RegisterPrefs(PrefRegistrySimple* registry); | |
54 | 33 |
55 // UserManager implementation: | 34 // UserManager implementation: |
56 virtual void Shutdown() OVERRIDE; | 35 virtual void Shutdown() OVERRIDE; |
57 virtual MultiProfileUserController* GetMultiProfileUserController() OVERRIDE; | |
58 virtual UserImageManager* GetUserImageManager( | |
59 const std::string& user_id) OVERRIDE; | |
60 virtual SupervisedUserManager* GetSupervisedUserManager() OVERRIDE; | |
61 virtual const user_manager::UserList& GetUsers() const OVERRIDE; | 36 virtual const user_manager::UserList& GetUsers() const OVERRIDE; |
62 virtual user_manager::UserList GetUsersAdmittedForMultiProfile() | |
63 const OVERRIDE; | |
64 virtual const user_manager::UserList& GetLoggedInUsers() const OVERRIDE; | 37 virtual const user_manager::UserList& GetLoggedInUsers() const OVERRIDE; |
65 virtual const user_manager::UserList& GetLRULoggedInUsers() OVERRIDE; | 38 virtual const user_manager::UserList& GetLRULoggedInUsers() OVERRIDE; |
Dmitry Polukhin
2014/07/28 09:32:39
const?
Nikita (slow)
2014/07/29 09:27:28
Done.
| |
66 virtual user_manager::UserList GetUnlockUsers() const OVERRIDE; | 39 virtual const std::string& GetOwnerEmail() const OVERRIDE; |
67 virtual const std::string& GetOwnerEmail() OVERRIDE; | |
68 virtual void UserLoggedIn(const std::string& user_id, | 40 virtual void UserLoggedIn(const std::string& user_id, |
69 const std::string& user_id_hash, | 41 const std::string& user_id_hash, |
70 bool browser_restart) OVERRIDE; | 42 bool browser_restart) OVERRIDE; |
71 virtual void SwitchActiveUser(const std::string& user_id) OVERRIDE; | 43 virtual void SwitchActiveUser(const std::string& user_id) OVERRIDE; |
72 virtual void SessionStarted() OVERRIDE; | 44 virtual void SessionStarted() OVERRIDE; |
73 virtual void RemoveUser(const std::string& user_id, | 45 virtual void RemoveUser(const std::string& user_id, |
74 RemoveUserDelegate* delegate) OVERRIDE; | 46 RemoveUserDelegate* delegate) OVERRIDE; |
75 virtual void RemoveUserFromList(const std::string& user_id) OVERRIDE; | 47 virtual void RemoveUserFromList(const std::string& user_id) OVERRIDE; |
76 virtual bool IsKnownUser(const std::string& user_id) const OVERRIDE; | 48 virtual bool IsKnownUser(const std::string& user_id) const OVERRIDE; |
77 virtual const user_manager::User* FindUser( | 49 virtual const user_manager::User* FindUser( |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
115 virtual bool IsUserNonCryptohomeDataEphemeral( | 87 virtual bool IsUserNonCryptohomeDataEphemeral( |
116 const std::string& user_id) const OVERRIDE; | 88 const std::string& user_id) const OVERRIDE; |
117 virtual void AddObserver(UserManager::Observer* obs) OVERRIDE; | 89 virtual void AddObserver(UserManager::Observer* obs) OVERRIDE; |
118 virtual void RemoveObserver(UserManager::Observer* obs) OVERRIDE; | 90 virtual void RemoveObserver(UserManager::Observer* obs) OVERRIDE; |
119 virtual void AddSessionStateObserver( | 91 virtual void AddSessionStateObserver( |
120 UserManager::UserSessionStateObserver* obs) OVERRIDE; | 92 UserManager::UserSessionStateObserver* obs) OVERRIDE; |
121 virtual void RemoveSessionStateObserver( | 93 virtual void RemoveSessionStateObserver( |
122 UserManager::UserSessionStateObserver* obs) OVERRIDE; | 94 UserManager::UserSessionStateObserver* obs) OVERRIDE; |
123 virtual void NotifyLocalStateChanged() OVERRIDE; | 95 virtual void NotifyLocalStateChanged() OVERRIDE; |
124 | 96 |
125 virtual UserFlow* GetCurrentUserFlow() const OVERRIDE; | 97 // Helper function that copies users from |users_list| to |users_vector| and |
126 virtual UserFlow* GetUserFlow(const std::string& user_id) const OVERRIDE; | 98 // |users_set|. Duplicates and users already present in |existing_users| are |
127 virtual void SetUserFlow(const std::string& user_id, UserFlow* flow) OVERRIDE; | 99 // skipped. |
128 virtual void ResetUserFlow(const std::string& user_id) OVERRIDE; | 100 static void ParseUserList(const base::ListValue& users_list, |
129 virtual bool AreSupervisedUsersAllowed() const OVERRIDE; | 101 const std::set<std::string>& existing_users, |
102 std::vector<std::string>* users_vector, | |
103 std::set<std::string>* users_set); | |
130 | 104 |
131 // content::NotificationObserver implementation. | 105 protected: |
132 virtual void Observe(int type, | 106 UserManagerBase(); |
133 const content::NotificationSource& source, | |
134 const content::NotificationDetails& details) OVERRIDE; | |
135 | 107 |
136 // policy::CloudExternalDataPolicyObserver::Delegate: | 108 // Adds |user| to users list, and adds it to front of LRU list. It is assumed |
137 virtual void OnExternalDataSet(const std::string& policy, | 109 // that there is no user with same id. |
138 const std::string& user_id) OVERRIDE; | 110 virtual void AddUserRecord(user_manager::User* user); |
139 virtual void OnExternalDataCleared(const std::string& policy, | |
140 const std::string& user_id) OVERRIDE; | |
141 virtual void OnExternalDataFetched(const std::string& policy, | |
142 const std::string& user_id, | |
143 scoped_ptr<std::string> data) OVERRIDE; | |
144 | 111 |
145 // policy::DeviceLocalAccountPolicyService::Observer implementation. | 112 // Returns true if trusted device policies have successfully been retrieved |
146 virtual void OnPolicyUpdated(const std::string& user_id) OVERRIDE; | 113 // and ephemeral users are enabled. |
147 virtual void OnDeviceLocalAccountsChanged() OVERRIDE; | 114 virtual bool AreEphemeralUsersEnabled() const = 0; |
148 | 115 |
149 void StopPolicyObserverForTesting(); | 116 // Returns true if user may be removed. |
117 virtual bool CanUserBeRemoved(const user_manager::User* user) const; | |
150 | 118 |
151 private: | 119 // A wrapper around C++ delete operator. Deletes |user|, and when |user| |
152 friend class SupervisedUserManagerImpl; | 120 // equals to active_user_, active_user_ is reset to NULL. |
153 friend class UserManager; | 121 virtual void DeleteUser(user_manager::User* user); |
154 friend class WallpaperManager; | |
155 friend class UserManagerTest; | |
156 friend class WallpaperManagerTest; | |
157 | 122 |
158 typedef base::hash_map<std::string, | 123 // Returns the locale used by the application. |
159 linked_ptr<UserImageManager> > UserImageManagerMap; | 124 virtual const std::string& GetApplicationLocale() const = 0; |
160 | 125 |
161 // Stages of loading user list from preferences. Some methods can have | 126 // Returns "Local State" PrefService instance. |
162 // different behavior depending on stage. | 127 virtual PrefService* GetLocalState() const = 0; |
163 enum UserLoadStage { | |
164 STAGE_NOT_LOADED = 0, | |
165 STAGE_LOADING, | |
166 STAGE_LOADED | |
167 }; | |
168 | |
169 UserManagerImpl(); | |
170 | 128 |
171 // Loads |users_| from Local State if the list has not been loaded yet. | 129 // Loads |users_| from Local State if the list has not been loaded yet. |
172 // Subsequent calls have no effect. Must be called on the UI thread. | 130 // Subsequent calls have no effect. Must be called on the UI thread. |
173 void EnsureUsersLoaded(); | 131 void EnsureUsersLoaded(); |
174 | 132 |
175 // Retrieves trusted device policies and removes users from the persistent | 133 // Returns true if device is enterprise managed. |
176 // list if ephemeral users are enabled. Schedules a callback to itself if | 134 virtual bool IsEnterpriseManaged() const = 0; |
177 // trusted device policies are not yet available. | |
178 void RetrieveTrustedDevicePolicies(); | |
179 | 135 |
180 // Returns true if trusted device policies have successfully been retrieved | 136 // Helper function that copies users from |users_list| to |users_vector| and |
181 // and ephemeral users are enabled. | 137 // |users_set|. Duplicates and users already present in |existing_users| are |
182 bool AreEphemeralUsersEnabled() const; | 138 // skipped. |
139 // Loads public accounts from the Local state and fills in | |
140 // |public_sessions_set|. | |
141 virtual void LoadPublicAccounts( | |
142 std::set<std::string>* public_sessions_set) = 0; | |
143 | |
144 // Notifies that user has logged in. | |
145 virtual void NotifyOnLogin(); | |
146 | |
147 // Notifies observers that another user was added to the session. | |
148 // If |user_switch_pending| is true this means that user has not been fully | |
149 // initialized yet like waiting for profile to be loaded. | |
150 virtual void NotifyUserAddedToSession(const user_manager::User* added_user, | |
151 bool user_switch_pending); | |
152 | |
153 // Performs any additional actions before user list is loaded. | |
154 virtual void PerformPreUserListLoadingActions() = 0; | |
155 | |
156 // Performs any additional actions after user list is loaded. | |
157 virtual void PerformPostUserListLoadingActions() = 0; | |
158 | |
159 // Performs any additional actions after UserLoggedIn() execution has been | |
160 // completed. | |
161 // |browser_restart| is true when reloading Chrome after crash to distinguish | |
162 // from normal sign in flow. | |
163 virtual void PerformPostUserLoggedInActions(bool browser_restart) = 0; | |
164 | |
165 // Implementation for RemoveUser method. It is synchronous. It is called from | |
166 // RemoveUserInternal after owner check. | |
167 virtual void RemoveNonOwnerUserInternal(const std::string& user_email, | |
168 RemoveUserDelegate* delegate); | |
169 | |
170 // Removes a regular or supervised user from the user list. | |
171 // Returns the user if found or NULL otherwise. | |
172 // Also removes the user from the persistent user list. | |
173 user_manager::User* RemoveRegularOrSupervisedUserFromList( | |
174 const std::string& user_id); | |
175 | |
176 // Implementation for RemoveUser method. This is an asynchronous part of the | |
177 // method, that verifies that owner will not get deleted, and calls | |
178 // |RemoveNonOwnerUserInternal|. | |
179 virtual void RemoveUserInternal(const std::string& user_email, | |
180 RemoveUserDelegate* delegate); | |
181 | |
182 // Removes data stored or cached outside the user's cryptohome (wallpaper, | |
183 // avatar, OAuth token status, display name, display email). | |
184 virtual void RemoveNonCryptohomeData(const std::string& user_id); | |
185 | |
186 // Check for a particular user type. | |
187 | |
188 // Returns true if |user_id| represents demo app. | |
189 virtual bool IsDemoApp(const std::string& user_id) const = 0; | |
190 | |
191 // Returns true if |user_id| represents kiosk app. | |
192 virtual bool IsKioskApp(const std::string& user_id) const = 0; | |
193 | |
194 // Returns true if |user_id| represents public account that has been marked | |
195 // for deletion. | |
196 virtual bool IsPublicAccountMarkedForRemoval( | |
197 const std::string& user_id) const = 0; | |
198 | |
199 // These methods are called when corresponding user type has signed in. | |
200 | |
201 // Indicates that the demo account has just logged in. | |
202 virtual void DemoAccountLoggedIn() = 0; | |
203 | |
204 // Indicates that a user just logged in as guest. | |
205 virtual void GuestUserLoggedIn(); | |
206 | |
207 // Indicates that a kiosk app robot just logged in. | |
208 virtual void KioskAppLoggedIn(const std::string& app_id) = 0; | |
209 | |
210 // Indicates that a user just logged into a public session. | |
211 virtual void PublicAccountUserLoggedIn(user_manager::User* user) = 0; | |
212 | |
213 // Indicates that a regular user just logged in. | |
214 virtual void RegularUserLoggedIn(const std::string& user_id); | |
215 | |
216 // Indicates that a regular user just logged in as ephemeral. | |
217 virtual void RegularUserLoggedInAsEphemeral(const std::string& user_id); | |
218 | |
219 // Indicates that a user just logged into a retail mode session. | |
220 virtual void RetailModeUserLoggedIn() = 0; | |
221 | |
222 // Indicates that a supervised user just logged in. | |
223 virtual void SupervisedUserLoggedIn(const std::string& user_id) = 0; | |
224 | |
225 // Getters/setters for private members. | |
226 | |
227 virtual void SetCurrentUserIsOwner(bool is_current_user_owner); | |
228 | |
229 virtual bool GetEphemeralUsersEnabled() const; | |
230 virtual void SetEphemeralUsersEnabled(bool enabled); | |
231 | |
232 virtual void SetIsCurrentUserNew(bool is_new); | |
233 | |
234 virtual void SetOwnerEmail(std::string owner_user_id); | |
235 | |
236 virtual const std::string& GetPendingUserSwitchID() const; | |
237 virtual void SetPendingUserSwitchID(std::string user_id); | |
238 | |
239 // The logged-in user that is currently active in current session. | |
240 // NULL until a user has logged in, then points to one | |
241 // of the User instances in |users_|, the |guest_user_| instance or an | |
242 // ephemeral user instance. | |
243 user_manager::User* active_user_; | |
244 | |
245 // The primary user of the current session. It is recorded for the first | |
246 // signed-in user and does not change thereafter. | |
247 user_manager::User* primary_user_; | |
248 | |
249 // List of all known users. User instances are owned by |this|. Regular users | |
250 // are removed by |RemoveUserFromList|, public accounts by | |
251 // |UpdateAndCleanUpPublicAccounts|. | |
252 user_manager::UserList users_; | |
253 | |
254 private: | |
255 // Stages of loading user list from preferences. Some methods can have | |
256 // different behavior depending on stage. | |
257 enum UserLoadStage { STAGE_NOT_LOADED = 0, STAGE_LOADING, STAGE_LOADED }; | |
183 | 258 |
184 // Returns a list of users who have logged into this device previously. | 259 // Returns a list of users who have logged into this device previously. |
185 // Same as GetUsers but used if you need to modify User from that list. | 260 // Same as GetUsers but used if you need to modify User from that list. |
186 user_manager::UserList& GetUsersAndModify(); | 261 user_manager::UserList& GetUsersAndModify(); |
187 | 262 |
188 // Returns the user with the given email address if found in the persistent | 263 // Returns the user with the given email address if found in the persistent |
189 // list. Returns |NULL| otherwise. | 264 // list. Returns |NULL| otherwise. |
190 const user_manager::User* FindUserInList(const std::string& user_id) const; | 265 const user_manager::User* FindUserInList(const std::string& user_id) const; |
191 | 266 |
192 // Returns |true| if user with the given id is found in the persistent list. | 267 // Returns |true| if user with the given id is found in the persistent list. |
193 // Returns |false| otherwise. Does not trigger user loading. | 268 // Returns |false| otherwise. Does not trigger user loading. |
194 const bool UserExistsInList(const std::string& user_id) const; | 269 const bool UserExistsInList(const std::string& user_id) const; |
195 | 270 |
196 // Same as FindUserInList but returns non-const pointer to User object. | 271 // Same as FindUserInList but returns non-const pointer to User object. |
197 user_manager::User* FindUserInListAndModify(const std::string& user_id); | 272 user_manager::User* FindUserInListAndModify(const std::string& user_id); |
198 | 273 |
199 // Indicates that a user just logged in as guest. | |
200 void GuestUserLoggedIn(); | |
201 | |
202 // Indicates that a regular user just logged in. | |
203 void RegularUserLoggedIn(const std::string& user_id); | |
204 | |
205 // Indicates that a regular user just logged in as ephemeral. | |
206 void RegularUserLoggedInAsEphemeral(const std::string& user_id); | |
207 | |
208 // Indicates that a supervised user just logged in. | |
209 void SupervisedUserLoggedIn(const std::string& user_id); | |
210 | |
211 // Indicates that a user just logged into a public session. | |
212 void PublicAccountUserLoggedIn(user_manager::User* user); | |
213 | |
214 // Indicates that a kiosk app robot just logged in. | |
215 void KioskAppLoggedIn(const std::string& app_id); | |
216 | |
217 // Indicates that the demo account has just logged in. | |
218 void DemoAccountLoggedIn(); | |
219 | |
220 // Indicates that a user just logged into a retail mode session. | |
221 void RetailModeUserLoggedIn(); | |
222 | |
223 // Notifies that user has logged in. | |
224 // Sends NOTIFICATION_LOGIN_USER_CHANGED notification. | |
225 void NotifyOnLogin(); | |
226 | |
227 // Reads user's oauth token status from local state preferences. | 274 // Reads user's oauth token status from local state preferences. |
228 user_manager::User::OAuthTokenStatus LoadUserOAuthStatus( | 275 user_manager::User::OAuthTokenStatus LoadUserOAuthStatus( |
229 const std::string& user_id) const; | 276 const std::string& user_id) const; |
230 | 277 |
231 // Read a flag indicating whether online authentication against GAIA should | 278 // Read a flag indicating whether online authentication against GAIA should |
232 // be enforced during the user's next sign-in from local state preferences. | 279 // be enforced during the user's next sign-in from local state preferences. |
233 bool LoadForceOnlineSignin(const std::string& user_id) const; | 280 bool LoadForceOnlineSignin(const std::string& user_id) const; |
234 | 281 |
235 void SetCurrentUserIsOwner(bool is_current_user_owner); | |
236 | |
237 // Updates current user ownership on UI thread. | |
238 void UpdateOwnership(); | |
239 | |
240 // Removes data stored or cached outside the user's cryptohome (wallpaper, | |
241 // avatar, OAuth token status, display name, display email). | |
242 void RemoveNonCryptohomeData(const std::string& user_id); | |
243 | |
244 // Removes a regular or supervised user from the user list. | |
245 // Returns the user if found or NULL otherwise. | |
246 // Also removes the user from the persistent user list. | |
247 user_manager::User* RemoveRegularOrSupervisedUserFromList( | |
248 const std::string& user_id); | |
249 | |
250 // If data for a public account is marked as pending removal and the user is | |
251 // no longer logged into that account, removes the data. | |
252 void CleanUpPublicAccountNonCryptohomeDataPendingRemoval(); | |
253 | |
254 // Removes data belonging to public accounts that are no longer found on the | |
255 // user list. If the user is currently logged into one of these accounts, the | |
256 // data for that account is not removed immediately but marked as pending | |
257 // removal after logout. | |
258 void CleanUpPublicAccountNonCryptohomeData( | |
259 const std::vector<std::string>& old_public_accounts); | |
260 | |
261 // Replaces the list of public accounts with those found in | |
262 // |device_local_accounts|. Ensures that data belonging to accounts no longer | |
263 // on the list is removed. Returns |true| if the list has changed. | |
264 // Public accounts are defined by policy. This method is called whenever an | |
265 // updated list of public accounts is received from policy. | |
266 bool UpdateAndCleanUpPublicAccounts( | |
267 const std::vector<policy::DeviceLocalAccount>& device_local_accounts); | |
268 | |
269 // Updates the display name for public account |username| from policy settings | |
270 // associated with that username. | |
271 void UpdatePublicAccountDisplayName(const std::string& user_id); | |
272 | |
273 // Notifies the UI about a change to the user list. | |
274 void NotifyUserListChanged(); | |
275 | |
276 // Notifies observers that merge session state had changed. | 282 // Notifies observers that merge session state had changed. |
277 void NotifyMergeSessionStateChanged(); | 283 void NotifyMergeSessionStateChanged(); |
278 | 284 |
279 // Notifies observers that active user has changed. | 285 // Notifies observers that active user has changed. |
280 void NotifyActiveUserChanged(const user_manager::User* active_user); | 286 void NotifyActiveUserChanged(const user_manager::User* active_user); |
281 | 287 |
282 // Notifies observers that another user was added to the session. | |
283 void NotifyUserAddedToSession(const user_manager::User* added_user); | |
284 | |
285 // Notifies observers that active user_id hash has changed. | 288 // Notifies observers that active user_id hash has changed. |
286 void NotifyActiveUserHashChanged(const std::string& hash); | 289 void NotifyActiveUserHashChanged(const std::string& hash); |
287 | 290 |
288 // Lazily creates default user flow. | |
289 UserFlow* GetDefaultUserFlow() const; | |
290 | |
291 // Update the global LoginState. | 291 // Update the global LoginState. |
292 void UpdateLoginState(); | 292 void UpdateLoginState(); |
293 | 293 |
294 // Insert |user| at the front of the LRU user list. | 294 // Insert |user| at the front of the LRU user list. |
295 void SetLRUUser(user_manager::User* user); | 295 void SetLRUUser(user_manager::User* user); |
296 | 296 |
297 // Adds |user| to users list, and adds it to front of LRU list. It is assumed | |
298 // that there is no user with same id. | |
299 void AddUserRecord(user_manager::User* user); | |
300 | |
301 // Sends metrics in response to a regular user logging in. | 297 // Sends metrics in response to a regular user logging in. |
302 void SendRegularUserLoginMetrics(const std::string& user_id); | 298 void SendRegularUserLoginMetrics(const std::string& user_id); |
303 | 299 |
304 // Implementation for RemoveUser method. This is an asynchronous part of the | |
305 // method, that verifies that owner will not get deleted, and calls | |
306 // |RemoveNonOwnerUserInternal|. | |
307 void RemoveUserInternal(const std::string& user_email, | |
308 RemoveUserDelegate* delegate); | |
309 | |
310 // Implementation for RemoveUser method. It is synchronous. It is called from | |
311 // RemoveUserInternal after owner check. | |
312 void RemoveNonOwnerUserInternal(const std::string& user_email, | |
313 RemoveUserDelegate* delegate); | |
314 | |
315 // MultiProfileUserControllerDelegate implementation: | |
316 virtual void OnUserNotAllowed(const std::string& user_email) OVERRIDE; | |
317 | |
318 // Sets account locale for user with id |user_id|. | 300 // Sets account locale for user with id |user_id|. |
319 virtual void UpdateUserAccountLocale(const std::string& user_id, | 301 virtual void UpdateUserAccountLocale(const std::string& user_id, |
320 const std::string& locale); | 302 const std::string& locale); |
321 | 303 |
322 // Updates user account after locale was resolved. | 304 // Updates user account after locale was resolved. |
323 void DoUpdateAccountLocale(const std::string& user_id, | 305 void DoUpdateAccountLocale(const std::string& user_id, |
324 const std::string& resolved_locale); | 306 const std::string& resolved_locale); |
325 | 307 |
326 // Update the number of users. | |
327 void UpdateNumberOfUsers(); | |
328 | |
329 // A wrapper around C++ delete operator. Deletes |user|, and when |user| | |
330 // equals to active_user_, active_user_ is reset to NULL. | |
331 void DeleteUser(user_manager::User* user); | |
332 | |
333 // Interface to the signed settings store. | |
334 CrosSettings* cros_settings_; | |
335 | |
336 // Interface to device-local account definitions and associated policy. | |
337 policy::DeviceLocalAccountPolicyService* device_local_account_policy_service_; | |
338 | |
339 // Indicates stage of loading user from prefs. | 308 // Indicates stage of loading user from prefs. |
340 UserLoadStage user_loading_stage_; | 309 UserLoadStage user_loading_stage_; |
341 | 310 |
342 // List of all known users. User instances are owned by |this|. Regular users | |
343 // are removed by |RemoveUserFromList|, public accounts by | |
344 // |UpdateAndCleanUpPublicAccounts|. | |
345 user_manager::UserList users_; | |
346 | |
347 // List of all users that are logged in current session. These point to User | 311 // List of all users that are logged in current session. These point to User |
348 // instances in |users_|. Only one of them could be marked as active. | 312 // instances in |users_|. Only one of them could be marked as active. |
349 user_manager::UserList logged_in_users_; | 313 user_manager::UserList logged_in_users_; |
350 | 314 |
351 // A list of all users that are logged in the current session. In contrast to | 315 // A list of all users that are logged in the current session. In contrast to |
352 // |logged_in_users|, the order of this list is least recently used so that | 316 // |logged_in_users|, the order of this list is least recently used so that |
353 // the active user should always be the first one in the list. | 317 // the active user should always be the first one in the list. |
354 user_manager::UserList lru_logged_in_users_; | 318 user_manager::UserList lru_logged_in_users_; |
355 | 319 |
356 // The list which gets reported when the |lru_logged_in_users_| list is empty. | 320 // The list which gets reported when the |lru_logged_in_users_| list is empty. |
357 user_manager::UserList temp_single_logged_in_users_; | 321 user_manager::UserList temp_single_logged_in_users_; |
358 | 322 |
359 // The logged-in user that is currently active in current session. | |
360 // NULL until a user has logged in, then points to one | |
361 // of the User instances in |users_|, the |guest_user_| instance or an | |
362 // ephemeral user instance. | |
363 user_manager::User* active_user_; | |
364 | |
365 // The primary user of the current session. It is recorded for the first | |
366 // signed-in user and does not change thereafter. | |
367 user_manager::User* primary_user_; | |
368 | |
369 // True if SessionStarted() has been called. | 323 // True if SessionStarted() has been called. |
370 bool session_started_; | 324 bool session_started_; |
371 | 325 |
372 // Cached flag of whether currently logged-in user is owner or not. | 326 // Cached flag of whether currently logged-in user is owner or not. |
373 // May be accessed on different threads, requires locking. | 327 // May be accessed on different threads, requires locking. |
374 bool is_current_user_owner_; | 328 bool is_current_user_owner_; |
375 mutable base::Lock is_current_user_owner_lock_; | 329 mutable base::Lock is_current_user_owner_lock_; |
376 | 330 |
377 // Cached flag of whether the currently logged-in user existed before this | 331 // Cached flag of whether the currently logged-in user existed before this |
378 // login. | 332 // login. |
379 bool is_current_user_new_; | 333 bool is_current_user_new_; |
380 | 334 |
381 // Cached flag of whether the currently logged-in user is a regular user who | 335 // Cached flag of whether the currently logged-in user is a regular user who |
382 // logged in as ephemeral. Storage of persistent information is avoided for | 336 // logged in as ephemeral. Storage of persistent information is avoided for |
383 // such users by not adding them to the persistent user list, not downloading | 337 // such users by not adding them to the persistent user list, not downloading |
384 // their custom avatars and mounting their cryptohomes using tmpfs. Defaults | 338 // their custom avatars and mounting their cryptohomes using tmpfs. Defaults |
385 // to |false|. | 339 // to |false|. |
386 bool is_current_user_ephemeral_regular_user_; | 340 bool is_current_user_ephemeral_regular_user_; |
387 | 341 |
388 // Cached flag indicating whether the ephemeral user policy is enabled. | 342 // Cached flag indicating whether the ephemeral user policy is enabled. |
389 // Defaults to |false| if the value has not been read from trusted device | 343 // Defaults to |false| if the value has not been read from trusted device |
390 // policy yet. | 344 // policy yet. |
391 bool ephemeral_users_enabled_; | 345 bool ephemeral_users_enabled_; |
392 | 346 |
393 // Cached name of device owner. Defaults to empty string if the value has not | 347 // Cached name of device owner. Defaults to empty string if the value has not |
394 // been read from trusted device policy yet. | 348 // been read from trusted device policy yet. |
395 std::string owner_email_; | 349 std::string owner_email_; |
396 | 350 |
397 content::NotificationRegistrar registrar_; | |
398 | |
399 ObserverList<UserManager::Observer> observer_list_; | 351 ObserverList<UserManager::Observer> observer_list_; |
400 | 352 |
401 // TODO(nkostylev): Merge with session state refactoring CL. | 353 // TODO(nkostylev): Merge with session state refactoring CL. |
402 ObserverList<UserManager::UserSessionStateObserver> | 354 ObserverList<UserManager::UserSessionStateObserver> |
403 session_state_observer_list_; | 355 session_state_observer_list_; |
404 | 356 |
405 // User avatar managers. | |
406 UserImageManagerMap user_image_managers_; | |
407 | |
408 // Supervised user manager. | |
409 scoped_ptr<SupervisedUserManagerImpl> supervised_user_manager_; | |
410 | |
411 // Session length limiter. | |
412 scoped_ptr<SessionLengthLimiter> session_length_limiter_; | |
413 | |
414 typedef std::map<std::string, UserFlow*> FlowMap; | |
415 | |
416 // Lazy-initialized default flow. | |
417 mutable scoped_ptr<UserFlow> default_flow_; | |
418 | |
419 // Specific flows by user e-mail. Keys should be canonicalized before | |
420 // access. | |
421 FlowMap specific_flows_; | |
422 | |
423 // Time at which this object was created. | 357 // Time at which this object was created. |
424 base::TimeTicks manager_creation_time_; | 358 base::TimeTicks manager_creation_time_; |
425 | 359 |
426 scoped_ptr<CrosSettings::ObserverSubscription> | |
427 local_accounts_subscription_; | |
428 | |
429 scoped_ptr<MultiProfileUserController> multi_profile_user_controller_; | |
430 | |
431 // Observer for the policy that can be used to manage user images. | |
432 scoped_ptr<policy::CloudExternalDataPolicyObserver> avatar_policy_observer_; | |
433 | |
434 // Observer for the policy that can be used to manage wallpapers. | |
435 scoped_ptr<policy::CloudExternalDataPolicyObserver> | |
436 wallpaper_policy_observer_; | |
437 | |
438 // ID of the user just added to the session that needs to be activated | 360 // ID of the user just added to the session that needs to be activated |
439 // as soon as user's profile is loaded. | 361 // as soon as user's profile is loaded. |
440 std::string pending_user_switch_; | 362 std::string pending_user_switch_; |
441 | 363 |
442 DISALLOW_COPY_AND_ASSIGN(UserManagerImpl); | 364 DISALLOW_COPY_AND_ASSIGN(UserManagerBase); |
443 }; | 365 }; |
444 | 366 |
445 } // namespace chromeos | 367 } // namespace chromeos |
446 | 368 |
447 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USERS_USER_MANAGER_IMPL_H_ | 369 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USERS_USER_MANAGER_BASE_H_ |
OLD | NEW |