Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(149)

Side by Side Diff: chrome/browser/chromeos/login/users/user_manager_base.h

Issue 417623002: user_manager component: Add UserManagerBase class. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: check for LocalState, update test - make sure that policies are initialized on UserManager creation Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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" 13 #include "base/memory/weak_ptr.h"
14 #include "base/memory/linked_ptr.h"
15 #include "base/memory/scoped_ptr.h"
16 #include "base/observer_list.h" 14 #include "base/observer_list.h"
17 #include "base/synchronization/lock.h" 15 #include "base/synchronization/lock.h"
18 #include "base/time/time.h" 16 #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" 17 #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" 18 #include "components/user_manager/user.h"
28 #include "content/public/browser/notification_observer.h"
29 #include "content/public/browser/notification_registrar.h"
30 19
31 class PrefService; 20 class PrefService;
32 class ProfileSyncService; 21 class PrefRegistrySimple;
33
34 namespace policy {
35 struct DeviceLocalAccount;
36 }
37 22
38 namespace chromeos { 23 namespace chromeos {
39 24
40 class MultiProfileUserController;
41 class RemoveUserDelegate; 25 class RemoveUserDelegate;
42 class SupervisedUserManagerImpl;
43 class SessionLengthLimiter;
44 26
45 // Implementation of the UserManager. 27 // Base implementation of the UserManager interface.
46 class UserManagerImpl 28 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: 29 public:
53 virtual ~UserManagerImpl(); 30 virtual ~UserManagerBase();
31
32 // Registers UserManagerBase preferences.
33 static void RegisterPrefs(PrefRegistrySimple* registry);
54 34
55 // UserManager implementation: 35 // UserManager implementation:
56 virtual void Shutdown() OVERRIDE; 36 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; 37 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; 38 virtual const user_manager::UserList& GetLoggedInUsers() const OVERRIDE;
65 virtual const user_manager::UserList& GetLRULoggedInUsers() OVERRIDE; 39 virtual const user_manager::UserList& GetLRULoggedInUsers() const OVERRIDE;
66 virtual user_manager::UserList GetUnlockUsers() const OVERRIDE; 40 virtual const std::string& GetOwnerEmail() const OVERRIDE;
67 virtual const std::string& GetOwnerEmail() OVERRIDE;
68 virtual void UserLoggedIn(const std::string& user_id, 41 virtual void UserLoggedIn(const std::string& user_id,
69 const std::string& user_id_hash, 42 const std::string& user_id_hash,
70 bool browser_restart) OVERRIDE; 43 bool browser_restart) OVERRIDE;
71 virtual void SwitchActiveUser(const std::string& user_id) OVERRIDE; 44 virtual void SwitchActiveUser(const std::string& user_id) OVERRIDE;
72 virtual void SessionStarted() OVERRIDE; 45 virtual void SessionStarted() OVERRIDE;
73 virtual void RemoveUser(const std::string& user_id, 46 virtual void RemoveUser(const std::string& user_id,
74 RemoveUserDelegate* delegate) OVERRIDE; 47 RemoveUserDelegate* delegate) OVERRIDE;
75 virtual void RemoveUserFromList(const std::string& user_id) OVERRIDE; 48 virtual void RemoveUserFromList(const std::string& user_id) OVERRIDE;
76 virtual bool IsKnownUser(const std::string& user_id) const OVERRIDE; 49 virtual bool IsKnownUser(const std::string& user_id) const OVERRIDE;
77 virtual const user_manager::User* FindUser( 50 virtual const user_manager::User* FindUser(
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 virtual bool IsUserNonCryptohomeDataEphemeral( 88 virtual bool IsUserNonCryptohomeDataEphemeral(
116 const std::string& user_id) const OVERRIDE; 89 const std::string& user_id) const OVERRIDE;
117 virtual void AddObserver(UserManager::Observer* obs) OVERRIDE; 90 virtual void AddObserver(UserManager::Observer* obs) OVERRIDE;
118 virtual void RemoveObserver(UserManager::Observer* obs) OVERRIDE; 91 virtual void RemoveObserver(UserManager::Observer* obs) OVERRIDE;
119 virtual void AddSessionStateObserver( 92 virtual void AddSessionStateObserver(
120 UserManager::UserSessionStateObserver* obs) OVERRIDE; 93 UserManager::UserSessionStateObserver* obs) OVERRIDE;
121 virtual void RemoveSessionStateObserver( 94 virtual void RemoveSessionStateObserver(
122 UserManager::UserSessionStateObserver* obs) OVERRIDE; 95 UserManager::UserSessionStateObserver* obs) OVERRIDE;
123 virtual void NotifyLocalStateChanged() OVERRIDE; 96 virtual void NotifyLocalStateChanged() OVERRIDE;
124 97
125 virtual UserFlow* GetCurrentUserFlow() const OVERRIDE; 98 // Helper function that copies users from |users_list| to |users_vector| and
126 virtual UserFlow* GetUserFlow(const std::string& user_id) const OVERRIDE; 99 // |users_set|. Duplicates and users already present in |existing_users| are
127 virtual void SetUserFlow(const std::string& user_id, UserFlow* flow) OVERRIDE; 100 // skipped.
128 virtual void ResetUserFlow(const std::string& user_id) OVERRIDE; 101 static void ParseUserList(const base::ListValue& users_list,
129 virtual bool AreSupervisedUsersAllowed() const OVERRIDE; 102 const std::set<std::string>& existing_users,
103 std::vector<std::string>* users_vector,
104 std::set<std::string>* users_set);
130 105
131 // content::NotificationObserver implementation. 106 protected:
132 virtual void Observe(int type, 107 UserManagerBase();
133 const content::NotificationSource& source,
134 const content::NotificationDetails& details) OVERRIDE;
135 108
136 // policy::CloudExternalDataPolicyObserver::Delegate: 109 // Adds |user| to users list, and adds it to front of LRU list. It is assumed
137 virtual void OnExternalDataSet(const std::string& policy, 110 // that there is no user with same id.
138 const std::string& user_id) OVERRIDE; 111 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 112
145 // policy::DeviceLocalAccountPolicyService::Observer implementation. 113 // Returns true if trusted device policies have successfully been retrieved
146 virtual void OnPolicyUpdated(const std::string& user_id) OVERRIDE; 114 // and ephemeral users are enabled.
147 virtual void OnDeviceLocalAccountsChanged() OVERRIDE; 115 virtual bool AreEphemeralUsersEnabled() const = 0;
148 116
149 void StopPolicyObserverForTesting(); 117 // Returns true if user may be removed.
118 virtual bool CanUserBeRemoved(const user_manager::User* user) const;
150 119
151 private: 120 // A wrapper around C++ delete operator. Deletes |user|, and when |user|
152 friend class SupervisedUserManagerImpl; 121 // equals to active_user_, active_user_ is reset to NULL.
153 friend class UserManager; 122 virtual void DeleteUser(user_manager::User* user);
154 friend class WallpaperManager;
155 friend class UserManagerTest;
156 friend class WallpaperManagerTest;
157 123
158 typedef base::hash_map<std::string, 124 // Returns the locale used by the application.
159 linked_ptr<UserImageManager> > UserImageManagerMap; 125 virtual const std::string& GetApplicationLocale() const = 0;
160 126
161 // Stages of loading user list from preferences. Some methods can have 127 // Returns "Local State" PrefService instance.
162 // different behavior depending on stage. 128 virtual PrefService* GetLocalState() const = 0;
163 enum UserLoadStage {
164 STAGE_NOT_LOADED = 0,
165 STAGE_LOADING,
166 STAGE_LOADED
167 };
168
169 UserManagerImpl();
170 129
171 // Loads |users_| from Local State if the list has not been loaded yet. 130 // 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. 131 // Subsequent calls have no effect. Must be called on the UI thread.
173 void EnsureUsersLoaded(); 132 void EnsureUsersLoaded();
174 133
175 // Retrieves trusted device policies and removes users from the persistent 134 // Returns true if device is enterprise managed.
176 // list if ephemeral users are enabled. Schedules a callback to itself if 135 virtual bool IsEnterpriseManaged() const = 0;
177 // trusted device policies are not yet available.
178 void RetrieveTrustedDevicePolicies();
179 136
180 // Returns true if trusted device policies have successfully been retrieved 137 // Helper function that copies users from |users_list| to |users_vector| and
181 // and ephemeral users are enabled. 138 // |users_set|. Duplicates and users already present in |existing_users| are
182 bool AreEphemeralUsersEnabled() const; 139 // skipped.
140 // Loads public accounts from the Local state and fills in
141 // |public_sessions_set|.
142 virtual void LoadPublicAccounts(
143 std::set<std::string>* public_sessions_set) = 0;
144
145 // Notifies that user has logged in.
146 virtual void NotifyOnLogin();
147
148 // Notifies observers that another user was added to the session.
149 // If |user_switch_pending| is true this means that user has not been fully
150 // initialized yet like waiting for profile to be loaded.
151 virtual void NotifyUserAddedToSession(const user_manager::User* added_user,
152 bool user_switch_pending);
153
154 // Performs any additional actions before user list is loaded.
155 virtual void PerformPreUserListLoadingActions() = 0;
156
157 // Performs any additional actions after user list is loaded.
158 virtual void PerformPostUserListLoadingActions() = 0;
159
160 // Performs any additional actions after UserLoggedIn() execution has been
161 // completed.
162 // |browser_restart| is true when reloading Chrome after crash to distinguish
163 // from normal sign in flow.
164 virtual void PerformPostUserLoggedInActions(bool browser_restart) = 0;
165
166 // Implementation for RemoveUser method. It is synchronous. It is called from
167 // RemoveUserInternal after owner check.
168 virtual void RemoveNonOwnerUserInternal(const std::string& user_email,
169 RemoveUserDelegate* delegate);
170
171 // Removes a regular or supervised user from the user list.
172 // Returns the user if found or NULL otherwise.
173 // Also removes the user from the persistent user list.
174 user_manager::User* RemoveRegularOrSupervisedUserFromList(
175 const std::string& user_id);
176
177 // Implementation for RemoveUser method. This is an asynchronous part of the
178 // method, that verifies that owner will not get deleted, and calls
179 // |RemoveNonOwnerUserInternal|.
180 virtual void RemoveUserInternal(const std::string& user_email,
181 RemoveUserDelegate* delegate);
182
183 // Removes data stored or cached outside the user's cryptohome (wallpaper,
184 // avatar, OAuth token status, display name, display email).
185 virtual void RemoveNonCryptohomeData(const std::string& user_id);
186
187 // Check for a particular user type.
188
189 // Returns true if |user_id| represents demo app.
190 virtual bool IsDemoApp(const std::string& user_id) const = 0;
191
192 // Returns true if |user_id| represents kiosk app.
193 virtual bool IsKioskApp(const std::string& user_id) const = 0;
194
195 // Returns true if |user_id| represents public account that has been marked
196 // for deletion.
197 virtual bool IsPublicAccountMarkedForRemoval(
198 const std::string& user_id) const = 0;
199
200 // These methods are called when corresponding user type has signed in.
201
202 // Indicates that the demo account has just logged in.
203 virtual void DemoAccountLoggedIn() = 0;
204
205 // Indicates that a user just logged in as guest.
206 virtual void GuestUserLoggedIn();
207
208 // Indicates that a kiosk app robot just logged in.
209 virtual void KioskAppLoggedIn(const std::string& app_id) = 0;
210
211 // Indicates that a user just logged into a public session.
212 virtual void PublicAccountUserLoggedIn(user_manager::User* user) = 0;
213
214 // Indicates that a regular user just logged in.
215 virtual void RegularUserLoggedIn(const std::string& user_id);
216
217 // Indicates that a regular user just logged in as ephemeral.
218 virtual void RegularUserLoggedInAsEphemeral(const std::string& user_id);
219
220 // Indicates that a user just logged into a retail mode session.
221 virtual void RetailModeUserLoggedIn() = 0;
222
223 // Indicates that a supervised user just logged in.
224 virtual void SupervisedUserLoggedIn(const std::string& user_id) = 0;
225
226 // Getters/setters for private members.
227
228 virtual void SetCurrentUserIsOwner(bool is_current_user_owner);
229
230 virtual bool GetEphemeralUsersEnabled() const;
231 virtual void SetEphemeralUsersEnabled(bool enabled);
232
233 virtual void SetIsCurrentUserNew(bool is_new);
234
235 virtual void SetOwnerEmail(std::string owner_user_id);
236
237 virtual const std::string& GetPendingUserSwitchID() const;
238 virtual void SetPendingUserSwitchID(std::string user_id);
239
240 // The logged-in user that is currently active in current session.
241 // NULL until a user has logged in, then points to one
242 // of the User instances in |users_|, the |guest_user_| instance or an
243 // ephemeral user instance.
244 user_manager::User* active_user_;
245
246 // The primary user of the current session. It is recorded for the first
247 // signed-in user and does not change thereafter.
248 user_manager::User* primary_user_;
249
250 // List of all known users. User instances are owned by |this|. Regular users
251 // are removed by |RemoveUserFromList|, public accounts by
252 // |UpdateAndCleanUpPublicAccounts|.
253 user_manager::UserList users_;
254
255 private:
256 // Stages of loading user list from preferences. Some methods can have
257 // different behavior depending on stage.
258 enum UserLoadStage { STAGE_NOT_LOADED = 0, STAGE_LOADING, STAGE_LOADED };
183 259
184 // Returns a list of users who have logged into this device previously. 260 // 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. 261 // Same as GetUsers but used if you need to modify User from that list.
186 user_manager::UserList& GetUsersAndModify(); 262 user_manager::UserList& GetUsersAndModify();
187 263
188 // Returns the user with the given email address if found in the persistent 264 // Returns the user with the given email address if found in the persistent
189 // list. Returns |NULL| otherwise. 265 // list. Returns |NULL| otherwise.
190 const user_manager::User* FindUserInList(const std::string& user_id) const; 266 const user_manager::User* FindUserInList(const std::string& user_id) const;
191 267
192 // Returns |true| if user with the given id is found in the persistent list. 268 // Returns |true| if user with the given id is found in the persistent list.
193 // Returns |false| otherwise. Does not trigger user loading. 269 // Returns |false| otherwise. Does not trigger user loading.
194 const bool UserExistsInList(const std::string& user_id) const; 270 const bool UserExistsInList(const std::string& user_id) const;
195 271
196 // Same as FindUserInList but returns non-const pointer to User object. 272 // Same as FindUserInList but returns non-const pointer to User object.
197 user_manager::User* FindUserInListAndModify(const std::string& user_id); 273 user_manager::User* FindUserInListAndModify(const std::string& user_id);
198 274
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. 275 // Reads user's oauth token status from local state preferences.
228 user_manager::User::OAuthTokenStatus LoadUserOAuthStatus( 276 user_manager::User::OAuthTokenStatus LoadUserOAuthStatus(
229 const std::string& user_id) const; 277 const std::string& user_id) const;
230 278
231 // Read a flag indicating whether online authentication against GAIA should 279 // Read a flag indicating whether online authentication against GAIA should
232 // be enforced during the user's next sign-in from local state preferences. 280 // be enforced during the user's next sign-in from local state preferences.
233 bool LoadForceOnlineSignin(const std::string& user_id) const; 281 bool LoadForceOnlineSignin(const std::string& user_id) const;
234 282
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. 283 // Notifies observers that merge session state had changed.
277 void NotifyMergeSessionStateChanged(); 284 void NotifyMergeSessionStateChanged();
278 285
279 // Notifies observers that active user has changed. 286 // Notifies observers that active user has changed.
280 void NotifyActiveUserChanged(const user_manager::User* active_user); 287 void NotifyActiveUserChanged(const user_manager::User* active_user);
281 288
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. 289 // Notifies observers that active user_id hash has changed.
286 void NotifyActiveUserHashChanged(const std::string& hash); 290 void NotifyActiveUserHashChanged(const std::string& hash);
287 291
288 // Lazily creates default user flow.
289 UserFlow* GetDefaultUserFlow() const;
290
291 // Update the global LoginState. 292 // Update the global LoginState.
292 void UpdateLoginState(); 293 void UpdateLoginState();
293 294
294 // Insert |user| at the front of the LRU user list. 295 // Insert |user| at the front of the LRU user list.
295 void SetLRUUser(user_manager::User* user); 296 void SetLRUUser(user_manager::User* user);
296 297
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. 298 // Sends metrics in response to a regular user logging in.
302 void SendRegularUserLoginMetrics(const std::string& user_id); 299 void SendRegularUserLoginMetrics(const std::string& user_id);
303 300
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|. 301 // Sets account locale for user with id |user_id|.
319 virtual void UpdateUserAccountLocale(const std::string& user_id, 302 virtual void UpdateUserAccountLocale(const std::string& user_id,
320 const std::string& locale); 303 const std::string& locale);
321 304
322 // Updates user account after locale was resolved. 305 // Updates user account after locale was resolved.
323 void DoUpdateAccountLocale(const std::string& user_id, 306 void DoUpdateAccountLocale(const std::string& user_id,
324 const std::string& resolved_locale); 307 const std::string& resolved_locale);
325 308
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. 309 // Indicates stage of loading user from prefs.
340 UserLoadStage user_loading_stage_; 310 UserLoadStage user_loading_stage_;
341 311
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 312 // 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. 313 // instances in |users_|. Only one of them could be marked as active.
349 user_manager::UserList logged_in_users_; 314 user_manager::UserList logged_in_users_;
350 315
351 // A list of all users that are logged in the current session. In contrast to 316 // 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 317 // |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. 318 // the active user should always be the first one in the list.
354 user_manager::UserList lru_logged_in_users_; 319 user_manager::UserList lru_logged_in_users_;
355 320
356 // The list which gets reported when the |lru_logged_in_users_| list is empty.
357 user_manager::UserList temp_single_logged_in_users_;
358
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. 321 // True if SessionStarted() has been called.
370 bool session_started_; 322 bool session_started_;
371 323
372 // Cached flag of whether currently logged-in user is owner or not. 324 // Cached flag of whether currently logged-in user is owner or not.
373 // May be accessed on different threads, requires locking. 325 // May be accessed on different threads, requires locking.
374 bool is_current_user_owner_; 326 bool is_current_user_owner_;
375 mutable base::Lock is_current_user_owner_lock_; 327 mutable base::Lock is_current_user_owner_lock_;
376 328
377 // Cached flag of whether the currently logged-in user existed before this 329 // Cached flag of whether the currently logged-in user existed before this
378 // login. 330 // login.
379 bool is_current_user_new_; 331 bool is_current_user_new_;
380 332
381 // Cached flag of whether the currently logged-in user is a regular user who 333 // 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 334 // 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 335 // such users by not adding them to the persistent user list, not downloading
384 // their custom avatars and mounting their cryptohomes using tmpfs. Defaults 336 // their custom avatars and mounting their cryptohomes using tmpfs. Defaults
385 // to |false|. 337 // to |false|.
386 bool is_current_user_ephemeral_regular_user_; 338 bool is_current_user_ephemeral_regular_user_;
387 339
388 // Cached flag indicating whether the ephemeral user policy is enabled. 340 // Cached flag indicating whether the ephemeral user policy is enabled.
389 // Defaults to |false| if the value has not been read from trusted device 341 // Defaults to |false| if the value has not been read from trusted device
390 // policy yet. 342 // policy yet.
391 bool ephemeral_users_enabled_; 343 bool ephemeral_users_enabled_;
392 344
393 // Cached name of device owner. Defaults to empty string if the value has not 345 // Cached name of device owner. Defaults to empty string if the value has not
394 // been read from trusted device policy yet. 346 // been read from trusted device policy yet.
395 std::string owner_email_; 347 std::string owner_email_;
396 348
397 content::NotificationRegistrar registrar_;
398
399 ObserverList<UserManager::Observer> observer_list_; 349 ObserverList<UserManager::Observer> observer_list_;
400 350
401 // TODO(nkostylev): Merge with session state refactoring CL. 351 // TODO(nkostylev): Merge with session state refactoring CL.
402 ObserverList<UserManager::UserSessionStateObserver> 352 ObserverList<UserManager::UserSessionStateObserver>
403 session_state_observer_list_; 353 session_state_observer_list_;
404 354
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. 355 // Time at which this object was created.
424 base::TimeTicks manager_creation_time_; 356 base::TimeTicks manager_creation_time_;
425 357
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 358 // ID of the user just added to the session that needs to be activated
439 // as soon as user's profile is loaded. 359 // as soon as user's profile is loaded.
440 std::string pending_user_switch_; 360 std::string pending_user_switch_;
441 361
442 DISALLOW_COPY_AND_ASSIGN(UserManagerImpl); 362 base::WeakPtrFactory<UserManagerBase> weak_factory_;
363
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_
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/users/user_manager.cc ('k') | chrome/browser/chromeos/login/users/user_manager_base.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698