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

Side by Side Diff: chrome/browser/chromeos/login/users/chrome_user_manager.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_CHROME_USER_MANAGER_H_
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_USERS_USER_MANAGER_IMPL_H_ 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_USERS_CHROME_USER_MANAGER_H_
7 7
8 #include <map> 8 #include <map>
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/containers/hash_tables.h"
14 #include "base/memory/linked_ptr.h" 14 #include "base/memory/linked_ptr.h"
15 #include "base/memory/scoped_ptr.h" 15 #include "base/memory/scoped_ptr.h"
16 #include "base/memory/weak_ptr.h"
16 #include "base/observer_list.h" 17 #include "base/observer_list.h"
17 #include "base/synchronization/lock.h" 18 #include "base/synchronization/lock.h"
18 #include "base/time/time.h" 19 #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/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/multi_profile_user_controller_dele gate.h"
21 #include "chrome/browser/chromeos/login/users/user_manager.h" 22 #include "chrome/browser/chromeos/login/users/user_manager_base.h"
22 #include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h" 23 #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/cloud_external_data_policy_observer.h"
24 #include "chrome/browser/chromeos/policy/device_local_account_policy_service.h" 25 #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/cros_settings.h"
26 #include "chrome/browser/chromeos/settings/device_settings_service.h" 27 #include "chrome/browser/chromeos/settings/device_settings_service.h"
27 #include "components/user_manager/user.h" 28 #include "components/user_manager/user.h"
28 #include "content/public/browser/notification_observer.h" 29 #include "content/public/browser/notification_observer.h"
29 #include "content/public/browser/notification_registrar.h" 30 #include "content/public/browser/notification_registrar.h"
30 31
31 class PrefService; 32 class PrefService;
32 class ProfileSyncService; 33 class ProfileSyncService;
33 34
34 namespace policy { 35 namespace policy {
35 struct DeviceLocalAccount; 36 struct DeviceLocalAccount;
36 } 37 }
37 38
38 namespace chromeos { 39 namespace chromeos {
39 40
40 class MultiProfileUserController; 41 class MultiProfileUserController;
41 class RemoveUserDelegate; 42 class RemoveUserDelegate;
42 class SupervisedUserManagerImpl; 43 class SupervisedUserManagerImpl;
43 class SessionLengthLimiter; 44 class SessionLengthLimiter;
44 45
45 // Implementation of the UserManager. 46 // Chrome specific implementation of the UserManager.
46 class UserManagerImpl 47 class ChromeUserManager
47 : public UserManager, 48 : public UserManagerBase,
48 public content::NotificationObserver, 49 public content::NotificationObserver,
49 public policy::CloudExternalDataPolicyObserver::Delegate, 50 public policy::CloudExternalDataPolicyObserver::Delegate,
50 public policy::DeviceLocalAccountPolicyService::Observer, 51 public policy::DeviceLocalAccountPolicyService::Observer,
51 public MultiProfileUserControllerDelegate { 52 public MultiProfileUserControllerDelegate {
52 public: 53 public:
53 virtual ~UserManagerImpl(); 54 virtual ~ChromeUserManager();
54 55
55 // UserManager implementation: 56 // UserManager implementation:
56 virtual void Shutdown() OVERRIDE; 57 virtual void Shutdown() OVERRIDE;
57 virtual MultiProfileUserController* GetMultiProfileUserController() OVERRIDE; 58 virtual MultiProfileUserController* GetMultiProfileUserController() OVERRIDE;
58 virtual UserImageManager* GetUserImageManager( 59 virtual UserImageManager* GetUserImageManager(
59 const std::string& user_id) OVERRIDE; 60 const std::string& user_id) OVERRIDE;
60 virtual SupervisedUserManager* GetSupervisedUserManager() OVERRIDE; 61 virtual SupervisedUserManager* GetSupervisedUserManager() OVERRIDE;
61 virtual const user_manager::UserList& GetUsers() const OVERRIDE;
62 virtual user_manager::UserList GetUsersAdmittedForMultiProfile() 62 virtual user_manager::UserList GetUsersAdmittedForMultiProfile()
63 const OVERRIDE; 63 const OVERRIDE;
64 virtual const user_manager::UserList& GetLoggedInUsers() const OVERRIDE;
65 virtual const user_manager::UserList& GetLRULoggedInUsers() OVERRIDE;
66 virtual user_manager::UserList GetUnlockUsers() const OVERRIDE; 64 virtual user_manager::UserList GetUnlockUsers() const OVERRIDE;
67 virtual const std::string& GetOwnerEmail() OVERRIDE;
68 virtual void UserLoggedIn(const std::string& user_id,
69 const std::string& user_id_hash,
70 bool browser_restart) OVERRIDE;
71 virtual void SwitchActiveUser(const std::string& user_id) OVERRIDE;
72 virtual void SessionStarted() OVERRIDE; 65 virtual void SessionStarted() OVERRIDE;
73 virtual void RemoveUser(const std::string& user_id,
74 RemoveUserDelegate* delegate) OVERRIDE;
75 virtual void RemoveUserFromList(const std::string& user_id) OVERRIDE;
76 virtual bool IsKnownUser(const std::string& user_id) const OVERRIDE;
77 virtual const user_manager::User* FindUser(
78 const std::string& user_id) const OVERRIDE;
79 virtual user_manager::User* FindUserAndModify(
80 const std::string& user_id) OVERRIDE;
81 virtual const user_manager::User* GetLoggedInUser() const OVERRIDE;
82 virtual user_manager::User* GetLoggedInUser() OVERRIDE;
83 virtual const user_manager::User* GetActiveUser() const OVERRIDE;
84 virtual user_manager::User* GetActiveUser() OVERRIDE;
85 virtual const user_manager::User* GetPrimaryUser() const OVERRIDE;
86 virtual void SaveUserOAuthStatus( 66 virtual void SaveUserOAuthStatus(
87 const std::string& user_id, 67 const std::string& user_id,
88 user_manager::User::OAuthTokenStatus oauth_token_status) OVERRIDE; 68 user_manager::User::OAuthTokenStatus oauth_token_status) OVERRIDE;
89 virtual void SaveForceOnlineSignin(const std::string& user_id,
90 bool force_online_signin) OVERRIDE;
91 virtual void SaveUserDisplayName(const std::string& user_id, 69 virtual void SaveUserDisplayName(const std::string& user_id,
92 const base::string16& display_name) OVERRIDE; 70 const base::string16& display_name) OVERRIDE;
93 virtual base::string16 GetUserDisplayName(
94 const std::string& user_id) const OVERRIDE;
95 virtual void SaveUserDisplayEmail(const std::string& user_id,
96 const std::string& display_email) OVERRIDE;
97 virtual std::string GetUserDisplayEmail(
98 const std::string& user_id) const OVERRIDE;
99 virtual void UpdateUserAccountData(
100 const std::string& user_id,
101 const UserAccountData& account_data) OVERRIDE;
102 virtual bool IsCurrentUserOwner() const OVERRIDE;
103 virtual bool IsCurrentUserNew() const OVERRIDE;
104 virtual bool IsCurrentUserNonCryptohomeDataEphemeral() const OVERRIDE;
105 virtual bool CanCurrentUserLock() const OVERRIDE; 71 virtual bool CanCurrentUserLock() const OVERRIDE;
106 virtual bool IsUserLoggedIn() const OVERRIDE;
107 virtual bool IsLoggedInAsRegularUser() const OVERRIDE;
108 virtual bool IsLoggedInAsDemoUser() const OVERRIDE;
109 virtual bool IsLoggedInAsPublicAccount() const OVERRIDE;
110 virtual bool IsLoggedInAsGuest() const OVERRIDE;
111 virtual bool IsLoggedInAsSupervisedUser() const OVERRIDE;
112 virtual bool IsLoggedInAsKioskApp() const OVERRIDE;
113 virtual bool IsLoggedInAsStub() const OVERRIDE;
114 virtual bool IsSessionStarted() const OVERRIDE;
115 virtual bool IsUserNonCryptohomeDataEphemeral( 72 virtual bool IsUserNonCryptohomeDataEphemeral(
116 const std::string& user_id) const OVERRIDE; 73 const std::string& user_id) const OVERRIDE;
117 virtual void AddObserver(UserManager::Observer* obs) OVERRIDE;
118 virtual void RemoveObserver(UserManager::Observer* obs) OVERRIDE;
119 virtual void AddSessionStateObserver(
120 UserManager::UserSessionStateObserver* obs) OVERRIDE;
121 virtual void RemoveSessionStateObserver(
122 UserManager::UserSessionStateObserver* obs) OVERRIDE;
123 virtual void NotifyLocalStateChanged() OVERRIDE;
124 74
125 virtual UserFlow* GetCurrentUserFlow() const OVERRIDE; 75 virtual UserFlow* GetCurrentUserFlow() const OVERRIDE;
126 virtual UserFlow* GetUserFlow(const std::string& user_id) const OVERRIDE; 76 virtual UserFlow* GetUserFlow(const std::string& user_id) const OVERRIDE;
127 virtual void SetUserFlow(const std::string& user_id, UserFlow* flow) OVERRIDE; 77 virtual void SetUserFlow(const std::string& user_id, UserFlow* flow) OVERRIDE;
128 virtual void ResetUserFlow(const std::string& user_id) OVERRIDE; 78 virtual void ResetUserFlow(const std::string& user_id) OVERRIDE;
129 virtual bool AreSupervisedUsersAllowed() const OVERRIDE; 79 virtual bool AreSupervisedUsersAllowed() const OVERRIDE;
130 80
131 // content::NotificationObserver implementation. 81 // content::NotificationObserver implementation.
132 virtual void Observe(int type, 82 virtual void Observe(int type,
133 const content::NotificationSource& source, 83 const content::NotificationSource& source,
134 const content::NotificationDetails& details) OVERRIDE; 84 const content::NotificationDetails& details) OVERRIDE;
135 85
136 // policy::CloudExternalDataPolicyObserver::Delegate: 86 // policy::CloudExternalDataPolicyObserver::Delegate:
137 virtual void OnExternalDataSet(const std::string& policy, 87 virtual void OnExternalDataSet(const std::string& policy,
138 const std::string& user_id) OVERRIDE; 88 const std::string& user_id) OVERRIDE;
139 virtual void OnExternalDataCleared(const std::string& policy, 89 virtual void OnExternalDataCleared(const std::string& policy,
140 const std::string& user_id) OVERRIDE; 90 const std::string& user_id) OVERRIDE;
141 virtual void OnExternalDataFetched(const std::string& policy, 91 virtual void OnExternalDataFetched(const std::string& policy,
142 const std::string& user_id, 92 const std::string& user_id,
143 scoped_ptr<std::string> data) OVERRIDE; 93 scoped_ptr<std::string> data) OVERRIDE;
144 94
145 // policy::DeviceLocalAccountPolicyService::Observer implementation. 95 // policy::DeviceLocalAccountPolicyService::Observer implementation.
146 virtual void OnPolicyUpdated(const std::string& user_id) OVERRIDE; 96 virtual void OnPolicyUpdated(const std::string& user_id) OVERRIDE;
147 virtual void OnDeviceLocalAccountsChanged() OVERRIDE; 97 virtual void OnDeviceLocalAccountsChanged() OVERRIDE;
148 98
149 void StopPolicyObserverForTesting(); 99 void StopPolicyObserverForTesting();
150 100
101 protected:
102 // UserManagerBase implementation:
103 virtual bool AreEphemeralUsersEnabled() const OVERRIDE;
104 virtual const std::string& GetApplicationLocale() const OVERRIDE;
105 virtual PrefService* GetLocalState() const OVERRIDE;
106 virtual bool IsEnterpriseManaged() const OVERRIDE;
107 virtual void LoadPublicAccounts(std::set<std::string>* users_set) OVERRIDE;
108 virtual void NotifyOnLogin() OVERRIDE;
109 virtual void NotifyUserAddedToSession(const user_manager::User* added_user,
110 bool user_switch_pending) OVERRIDE;
111 virtual void PerformPreUserListLoadingActions() OVERRIDE;
112 virtual void PerformPostUserListLoadingActions() OVERRIDE;
113 virtual void PerformPostUserLoggedInActions(bool browser_restart) OVERRIDE;
114 virtual void RemoveNonCryptohomeData(const std::string& user_id) OVERRIDE;
115 virtual void RemoveUserInternal(const std::string& user_email,
116 RemoveUserDelegate* delegate) OVERRIDE;
117 virtual bool IsDemoApp(const std::string& user_id) const OVERRIDE;
118 virtual bool IsKioskApp(const std::string& user_id) const OVERRIDE;
119 virtual bool IsPublicAccountMarkedForRemoval(
120 const std::string& user_id) const OVERRIDE;
121 virtual void DemoAccountLoggedIn() OVERRIDE;
122 virtual void GuestUserLoggedIn() OVERRIDE;
123 virtual void KioskAppLoggedIn(const std::string& app_id) OVERRIDE;
124 virtual void PublicAccountUserLoggedIn(user_manager::User* user) OVERRIDE;
125 virtual void RegularUserLoggedIn(const std::string& user_id) OVERRIDE;
126 virtual void RegularUserLoggedInAsEphemeral(
127 const std::string& user_id) OVERRIDE;
128 virtual void RetailModeUserLoggedIn() OVERRIDE;
129 virtual void SupervisedUserLoggedIn(const std::string& user_id) OVERRIDE;
130
151 private: 131 private:
152 friend class SupervisedUserManagerImpl; 132 friend class SupervisedUserManagerImpl;
153 friend class UserManager; 133 friend class UserManager;
134 friend class UserManagerTest;
154 friend class WallpaperManager; 135 friend class WallpaperManager;
155 friend class UserManagerTest;
156 friend class WallpaperManagerTest; 136 friend class WallpaperManagerTest;
157 137
158 typedef base::hash_map<std::string, 138 typedef base::hash_map<std::string, linked_ptr<UserImageManager> >
159 linked_ptr<UserImageManager> > UserImageManagerMap; 139 UserImageManagerMap;
160 140
161 // Stages of loading user list from preferences. Some methods can have 141 ChromeUserManager();
162 // different behavior depending on stage.
163 enum UserLoadStage {
164 STAGE_NOT_LOADED = 0,
165 STAGE_LOADING,
166 STAGE_LOADED
167 };
168
169 UserManagerImpl();
170
171 // 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.
173 void EnsureUsersLoaded();
174 142
175 // Retrieves trusted device policies and removes users from the persistent 143 // Retrieves trusted device policies and removes users from the persistent
176 // list if ephemeral users are enabled. Schedules a callback to itself if 144 // list if ephemeral users are enabled. Schedules a callback to itself if
177 // trusted device policies are not yet available. 145 // trusted device policies are not yet available.
178 void RetrieveTrustedDevicePolicies(); 146 void RetrieveTrustedDevicePolicies();
179 147
180 // Returns true if trusted device policies have successfully been retrieved
181 // and ephemeral users are enabled.
182 bool AreEphemeralUsersEnabled() const;
183
184 // 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.
186 user_manager::UserList& GetUsersAndModify();
187
188 // Returns the user with the given email address if found in the persistent
189 // list. Returns |NULL| otherwise.
190 const user_manager::User* FindUserInList(const std::string& user_id) const;
191
192 // Returns |true| if user with the given id is found in the persistent list.
193 // Returns |false| otherwise. Does not trigger user loading.
194 const bool UserExistsInList(const std::string& user_id) const;
195
196 // Same as FindUserInList but returns non-const pointer to User object.
197 user_manager::User* FindUserInListAndModify(const std::string& user_id);
198
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.
228 user_manager::User::OAuthTokenStatus LoadUserOAuthStatus(
229 const std::string& user_id) const;
230
231 // Read a flag indicating whether online authentication against GAIA should
232 // be enforced during the user's next sign-in from local state preferences.
233 bool LoadForceOnlineSignin(const std::string& user_id) const;
234
235 void SetCurrentUserIsOwner(bool is_current_user_owner);
236
237 // Updates current user ownership on UI thread. 148 // Updates current user ownership on UI thread.
238 void UpdateOwnership(); 149 void UpdateOwnership();
239 150
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 151 // 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. 152 // no longer logged into that account, removes the data.
252 void CleanUpPublicAccountNonCryptohomeDataPendingRemoval(); 153 void CleanUpPublicAccountNonCryptohomeDataPendingRemoval();
253 154
254 // Removes data belonging to public accounts that are no longer found on the 155 // 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 156 // 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 157 // data for that account is not removed immediately but marked as pending
257 // removal after logout. 158 // removal after logout.
258 void CleanUpPublicAccountNonCryptohomeData( 159 void CleanUpPublicAccountNonCryptohomeData(
259 const std::vector<std::string>& old_public_accounts); 160 const std::vector<std::string>& old_public_accounts);
260 161
261 // Replaces the list of public accounts with those found in 162 // Replaces the list of public accounts with those found in
262 // |device_local_accounts|. Ensures that data belonging to accounts no longer 163 // |device_local_accounts|. Ensures that data belonging to accounts no longer
263 // on the list is removed. Returns |true| if the list has changed. 164 // 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 165 // Public accounts are defined by policy. This method is called whenever an
265 // updated list of public accounts is received from policy. 166 // updated list of public accounts is received from policy.
266 bool UpdateAndCleanUpPublicAccounts( 167 bool UpdateAndCleanUpPublicAccounts(
267 const std::vector<policy::DeviceLocalAccount>& device_local_accounts); 168 const std::vector<policy::DeviceLocalAccount>& device_local_accounts);
268 169
269 // Updates the display name for public account |username| from policy settings 170 // Updates the display name for public account |username| from policy settings
270 // associated with that username. 171 // associated with that username.
271 void UpdatePublicAccountDisplayName(const std::string& user_id); 172 void UpdatePublicAccountDisplayName(const std::string& user_id);
272 173
273 // Notifies the UI about a change to the user list. 174 // Notifies the UI about a change to the user list.
274 void NotifyUserListChanged(); 175 void NotifyUserListChanged();
275 176
276 // Notifies observers that merge session state had changed.
277 void NotifyMergeSessionStateChanged();
278
279 // Notifies observers that active user has changed.
280 void NotifyActiveUserChanged(const user_manager::User* active_user);
281
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.
286 void NotifyActiveUserHashChanged(const std::string& hash);
287
288 // Lazily creates default user flow. 177 // Lazily creates default user flow.
289 UserFlow* GetDefaultUserFlow() const; 178 UserFlow* GetDefaultUserFlow() const;
290 179
291 // Update the global LoginState.
292 void UpdateLoginState();
293
294 // Insert |user| at the front of the LRU user list.
295 void SetLRUUser(user_manager::User* user);
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.
302 void SendRegularUserLoginMetrics(const std::string& user_id);
303
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: 180 // MultiProfileUserControllerDelegate implementation:
316 virtual void OnUserNotAllowed(const std::string& user_email) OVERRIDE; 181 virtual void OnUserNotAllowed(const std::string& user_email) OVERRIDE;
317 182
318 // Sets account locale for user with id |user_id|.
319 virtual void UpdateUserAccountLocale(const std::string& user_id,
320 const std::string& locale);
321
322 // Updates user account after locale was resolved.
323 void DoUpdateAccountLocale(const std::string& user_id,
324 const std::string& resolved_locale);
325
326 // Update the number of users. 183 // Update the number of users.
327 void UpdateNumberOfUsers(); 184 void UpdateNumberOfUsers();
328 185
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. 186 // Interface to the signed settings store.
334 CrosSettings* cros_settings_; 187 CrosSettings* cros_settings_;
335 188
336 // Interface to device-local account definitions and associated policy. 189 // Interface to device-local account definitions and associated policy.
337 policy::DeviceLocalAccountPolicyService* device_local_account_policy_service_; 190 policy::DeviceLocalAccountPolicyService* device_local_account_policy_service_;
338 191
339 // Indicates stage of loading user from prefs.
340 UserLoadStage user_loading_stage_;
341
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
348 // instances in |users_|. Only one of them could be marked as active.
349 user_manager::UserList logged_in_users_;
350
351 // 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
353 // the active user should always be the first one in the list.
354 user_manager::UserList lru_logged_in_users_;
355
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.
370 bool session_started_;
371
372 // Cached flag of whether currently logged-in user is owner or not.
373 // May be accessed on different threads, requires locking.
374 bool is_current_user_owner_;
375 mutable base::Lock is_current_user_owner_lock_;
376
377 // Cached flag of whether the currently logged-in user existed before this
378 // login.
379 bool is_current_user_new_;
380
381 // 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
383 // such users by not adding them to the persistent user list, not downloading
384 // their custom avatars and mounting their cryptohomes using tmpfs. Defaults
385 // to |false|.
386 bool is_current_user_ephemeral_regular_user_;
387
388 // Cached flag indicating whether the ephemeral user policy is enabled.
389 // Defaults to |false| if the value has not been read from trusted device
390 // policy yet.
391 bool ephemeral_users_enabled_;
392
393 // Cached name of device owner. Defaults to empty string if the value has not
394 // been read from trusted device policy yet.
395 std::string owner_email_;
396
397 content::NotificationRegistrar registrar_; 192 content::NotificationRegistrar registrar_;
398 193
399 ObserverList<UserManager::Observer> observer_list_;
400
401 // TODO(nkostylev): Merge with session state refactoring CL.
402 ObserverList<UserManager::UserSessionStateObserver>
403 session_state_observer_list_;
404
405 // User avatar managers. 194 // User avatar managers.
406 UserImageManagerMap user_image_managers_; 195 UserImageManagerMap user_image_managers_;
407 196
408 // Supervised user manager. 197 // Supervised user manager.
409 scoped_ptr<SupervisedUserManagerImpl> supervised_user_manager_; 198 scoped_ptr<SupervisedUserManagerImpl> supervised_user_manager_;
410 199
411 // Session length limiter. 200 // Session length limiter.
412 scoped_ptr<SessionLengthLimiter> session_length_limiter_; 201 scoped_ptr<SessionLengthLimiter> session_length_limiter_;
413 202
414 typedef std::map<std::string, UserFlow*> FlowMap; 203 typedef std::map<std::string, UserFlow*> FlowMap;
415 204
416 // Lazy-initialized default flow. 205 // Lazy-initialized default flow.
417 mutable scoped_ptr<UserFlow> default_flow_; 206 mutable scoped_ptr<UserFlow> default_flow_;
418 207
419 // Specific flows by user e-mail. Keys should be canonicalized before 208 // Specific flows by user e-mail. Keys should be canonicalized before
420 // access. 209 // access.
421 FlowMap specific_flows_; 210 FlowMap specific_flows_;
422 211
423 // Time at which this object was created. 212 scoped_ptr<CrosSettings::ObserverSubscription> local_accounts_subscription_;
424 base::TimeTicks manager_creation_time_;
425
426 scoped_ptr<CrosSettings::ObserverSubscription>
427 local_accounts_subscription_;
428 213
429 scoped_ptr<MultiProfileUserController> multi_profile_user_controller_; 214 scoped_ptr<MultiProfileUserController> multi_profile_user_controller_;
430 215
431 // Observer for the policy that can be used to manage user images. 216 // Observer for the policy that can be used to manage user images.
432 scoped_ptr<policy::CloudExternalDataPolicyObserver> avatar_policy_observer_; 217 scoped_ptr<policy::CloudExternalDataPolicyObserver> avatar_policy_observer_;
433 218
434 // Observer for the policy that can be used to manage wallpapers. 219 // Observer for the policy that can be used to manage wallpapers.
435 scoped_ptr<policy::CloudExternalDataPolicyObserver> 220 scoped_ptr<policy::CloudExternalDataPolicyObserver>
436 wallpaper_policy_observer_; 221 wallpaper_policy_observer_;
437 222
438 // ID of the user just added to the session that needs to be activated 223 base::WeakPtrFactory<ChromeUserManager> weak_factory_;
439 // as soon as user's profile is loaded.
440 std::string pending_user_switch_;
441 224
442 DISALLOW_COPY_AND_ASSIGN(UserManagerImpl); 225 DISALLOW_COPY_AND_ASSIGN(ChromeUserManager);
443 }; 226 };
444 227
445 } // namespace chromeos 228 } // namespace chromeos
446 229
447 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USERS_USER_MANAGER_IMPL_H_ 230 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USERS_CHROME_USER_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698