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

Side by Side Diff: components/user_manager/user_manager_base.h

Issue 1412813003: This CL replaces user_manager::UserID with AccountId. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@468875--Chrome-OS-handles-deletion-of-Gmail-account-poorly--Create-AccountID-structure-part2--user_names
Patch Set: Update after review. Created 5 years, 1 month 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
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 COMPONENTS_USER_MANAGER_USER_MANAGER_BASE_H_ 5 #ifndef COMPONENTS_USER_MANAGER_USER_MANAGER_BASE_H_
6 #define COMPONENTS_USER_MANAGER_USER_MANAGER_BASE_H_ 6 #define COMPONENTS_USER_MANAGER_USER_MANAGER_BASE_H_
7 7
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/basictypes.h" 13 #include "base/basictypes.h"
14 #include "base/memory/weak_ptr.h" 14 #include "base/memory/weak_ptr.h"
15 #include "base/observer_list.h" 15 #include "base/observer_list.h"
16 #include "base/synchronization/lock.h" 16 #include "base/synchronization/lock.h"
17 #include "base/time/time.h" 17 #include "base/time/time.h"
18 #include "components/signin/core/account_id/account_id.h"
18 #include "components/user_manager/user.h" 19 #include "components/user_manager/user.h"
19 #include "components/user_manager/user_id.h"
20 #include "components/user_manager/user_manager.h" 20 #include "components/user_manager/user_manager.h"
21 #include "components/user_manager/user_manager_export.h" 21 #include "components/user_manager/user_manager_export.h"
22 #include "components/user_manager/user_type.h" 22 #include "components/user_manager/user_type.h"
23 23
24 class PrefService; 24 class PrefService;
25 class PrefRegistrySimple; 25 class PrefRegistrySimple;
26 26
27 namespace base { 27 namespace base {
28 class DictionaryValue; 28 class DictionaryValue;
29 class ListValue; 29 class ListValue;
(...skipping 14 matching lines...) Expand all
44 ~UserManagerBase() override; 44 ~UserManagerBase() override;
45 45
46 // Registers UserManagerBase preferences. 46 // Registers UserManagerBase preferences.
47 static void RegisterPrefs(PrefRegistrySimple* registry); 47 static void RegisterPrefs(PrefRegistrySimple* registry);
48 48
49 // UserManager implementation: 49 // UserManager implementation:
50 void Shutdown() override; 50 void Shutdown() override;
51 const UserList& GetUsers() const override; 51 const UserList& GetUsers() const override;
52 const UserList& GetLoggedInUsers() const override; 52 const UserList& GetLoggedInUsers() const override;
53 const UserList& GetLRULoggedInUsers() const override; 53 const UserList& GetLRULoggedInUsers() const override;
54 const std::string& GetOwnerEmail() const override; 54 const AccountId& GetOwnerAccountId() const override;
55 void UserLoggedIn(const std::string& user_id, 55 void UserLoggedIn(const AccountId& account_id,
56 const std::string& user_id_hash, 56 const std::string& user_id_hash,
57 bool browser_restart) override; 57 bool browser_restart) override;
58 void SwitchActiveUser(const std::string& user_id) override; 58 void SwitchActiveUser(const AccountId& account_id) override;
59 void SwitchToLastActiveUser() override; 59 void SwitchToLastActiveUser() override;
60 void SessionStarted() override; 60 void SessionStarted() override;
61 void RemoveUser(const std::string& user_id, 61 void RemoveUser(const AccountId& account_id,
62 RemoveUserDelegate* delegate) override; 62 RemoveUserDelegate* delegate) override;
63 void RemoveUserFromList(const std::string& user_id) override; 63 void RemoveUserFromList(const AccountId& account_id) override;
64 bool IsKnownUser(const std::string& user_id) const override; 64 bool IsKnownUser(const AccountId& account_id) const override;
65 const User* FindUser(const std::string& user_id) const override; 65 const User* FindUser(const AccountId& account_id) const override;
66 User* FindUserAndModify(const std::string& user_id) override; 66 User* FindUserAndModify(const AccountId& account_id) override;
67 const User* GetLoggedInUser() const override; 67 const User* GetLoggedInUser() const override;
68 User* GetLoggedInUser() override; 68 User* GetLoggedInUser() override;
69 const User* GetActiveUser() const override; 69 const User* GetActiveUser() const override;
70 User* GetActiveUser() override; 70 User* GetActiveUser() override;
71 const User* GetPrimaryUser() const override; 71 const User* GetPrimaryUser() const override;
72 void SaveUserOAuthStatus(const std::string& user_id, 72 void SaveUserOAuthStatus(const AccountId& account_id,
73 User::OAuthTokenStatus oauth_token_status) override; 73 User::OAuthTokenStatus oauth_token_status) override;
74 void SaveForceOnlineSignin(const std::string& user_id, 74 void SaveForceOnlineSignin(const AccountId& account_id,
75 bool force_online_signin) override; 75 bool force_online_signin) override;
76 void SaveUserDisplayName(const std::string& user_id, 76 void SaveUserDisplayName(const AccountId& account_id,
77 const base::string16& display_name) override; 77 const base::string16& display_name) override;
78 base::string16 GetUserDisplayName(const std::string& user_id) const override; 78 base::string16 GetUserDisplayName(const AccountId& account_id) const override;
79 void SaveUserDisplayEmail(const std::string& user_id, 79 void SaveUserDisplayEmail(const AccountId& account_id,
80 const std::string& display_email) override; 80 const std::string& display_email) override;
81 std::string GetUserDisplayEmail(const std::string& user_id) const override; 81 std::string GetUserDisplayEmail(const AccountId& account_id) const override;
82 void SaveUserType(const std::string& user_id, 82 void SaveUserType(const AccountId& account_id,
83 const UserType& user_type) override; 83 const UserType& user_type) override;
84 void UpdateUserAccountData(const std::string& user_id, 84 void UpdateUserAccountData(const AccountId& account_id,
85 const UserAccountData& account_data) override; 85 const UserAccountData& account_data) override;
86 bool IsCurrentUserOwner() const override; 86 bool IsCurrentUserOwner() const override;
87 bool IsCurrentUserNew() const override; 87 bool IsCurrentUserNew() const override;
88 bool IsCurrentUserNonCryptohomeDataEphemeral() const override; 88 bool IsCurrentUserNonCryptohomeDataEphemeral() const override;
89 bool CanCurrentUserLock() const override; 89 bool CanCurrentUserLock() const override;
90 bool IsUserLoggedIn() const override; 90 bool IsUserLoggedIn() const override;
91 bool IsLoggedInAsUserWithGaiaAccount() const override; 91 bool IsLoggedInAsUserWithGaiaAccount() const override;
92 bool IsLoggedInAsChildUser() const override; 92 bool IsLoggedInAsChildUser() const override;
93 bool IsLoggedInAsPublicAccount() const override; 93 bool IsLoggedInAsPublicAccount() const override;
94 bool IsLoggedInAsGuest() const override; 94 bool IsLoggedInAsGuest() const override;
95 bool IsLoggedInAsSupervisedUser() const override; 95 bool IsLoggedInAsSupervisedUser() const override;
96 bool IsLoggedInAsKioskApp() const override; 96 bool IsLoggedInAsKioskApp() const override;
97 bool IsLoggedInAsStub() const override; 97 bool IsLoggedInAsStub() const override;
98 bool IsSessionStarted() const override; 98 bool IsSessionStarted() const override;
99 bool IsUserNonCryptohomeDataEphemeral( 99 bool IsUserNonCryptohomeDataEphemeral(
100 const std::string& user_id) const override; 100 const AccountId& account_id) const override;
101 void AddObserver(UserManager::Observer* obs) override; 101 void AddObserver(UserManager::Observer* obs) override;
102 void RemoveObserver(UserManager::Observer* obs) override; 102 void RemoveObserver(UserManager::Observer* obs) override;
103 void AddSessionStateObserver( 103 void AddSessionStateObserver(
104 UserManager::UserSessionStateObserver* obs) override; 104 UserManager::UserSessionStateObserver* obs) override;
105 void RemoveSessionStateObserver( 105 void RemoveSessionStateObserver(
106 UserManager::UserSessionStateObserver* obs) override; 106 UserManager::UserSessionStateObserver* obs) override;
107 void NotifyLocalStateChanged() override; 107 void NotifyLocalStateChanged() override;
108 void ChangeUserChildStatus(User* user, bool is_child) override; 108 void ChangeUserChildStatus(User* user, bool is_child) override;
109 bool FindKnownUserPrefs(const UserID& user_id, 109 bool FindKnownUserPrefs(const AccountId& account_id,
110 const base::DictionaryValue** out_value) override; 110 const base::DictionaryValue** out_value) override;
111 void UpdateKnownUserPrefs(const UserID& user_id, 111 void UpdateKnownUserPrefs(const AccountId& account_id,
112 const base::DictionaryValue& values, 112 const base::DictionaryValue& values,
113 bool clear) override; 113 bool clear) override;
114 bool GetKnownUserStringPref(const UserID& user_id, 114 bool GetKnownUserStringPref(const AccountId& account_id,
115 const std::string& path, 115 const std::string& path,
116 std::string* out_value) override; 116 std::string* out_value) override;
117 void SetKnownUserStringPref(const UserID& user_id, 117 void SetKnownUserStringPref(const AccountId& account_id,
118 const std::string& path, 118 const std::string& path,
119 const std::string& in_value) override; 119 const std::string& in_value) override;
120 bool GetKnownUserBooleanPref(const UserID& user_id, 120 bool GetKnownUserBooleanPref(const AccountId& account_id,
121 const std::string& path, 121 const std::string& path,
122 bool* out_value) override; 122 bool* out_value) override;
123 void SetKnownUserBooleanPref(const UserID& user_id, 123 void SetKnownUserBooleanPref(const AccountId& account_id,
124 const std::string& path, 124 const std::string& path,
125 const bool in_value) override; 125 const bool in_value) override;
126 bool GetKnownUserIntegerPref(const UserID& user_id, 126 bool GetKnownUserIntegerPref(const AccountId& account_id,
127 const std::string& path, 127 const std::string& path,
128 int* out_value) override; 128 int* out_value) override;
129 void SetKnownUserIntegerPref(const UserID& user_id, 129 void SetKnownUserIntegerPref(const AccountId& account_id,
130 const std::string& path, 130 const std::string& path,
131 const int in_value) override; 131 const int in_value) override;
132 bool GetKnownUserCanonicalEmail(const UserID& user_id, 132 bool GetKnownUserAccountId(const AccountId& authenticated_account_id,
133 std::string* out_email) override; 133 AccountId* out_id) override;
134 void UpdateGaiaID(const UserID& user_id, const std::string& gaia_id) override; 134 void UpdateGaiaID(const AccountId& account_id,
135 bool FindGaiaID(const UserID& user_id, std::string* out_value) override; 135 const std::string& gaia_id) override;
136 void UpdateUsingSAML(const std::string& user_id, 136 bool FindGaiaID(const AccountId& account_id, std::string* out_value) override;
137 void UpdateUsingSAML(const AccountId& account_id,
137 const bool using_saml) override; 138 const bool using_saml) override;
138 bool FindUsingSAML(const std::string& user_id) override; 139 bool FindUsingSAML(const AccountId& account_id) override;
139 void SetKnownUserDeviceId(const UserID& user_id, 140 void SetKnownUserDeviceId(const AccountId& account_id,
140 const std::string& device_id) override; 141 const std::string& device_id) override;
141 std::string GetKnownUserDeviceId(const UserID& user_id) override; 142 std::string GetKnownUserDeviceId(const AccountId& account_id) override;
142 void SetKnownUserGAPSCookie(const UserID& user_id, 143 void SetKnownUserGAPSCookie(const AccountId& account_id,
143 const std::string& gaps_cookie) override; 144 const std::string& gaps_cookie) override;
144 std::string GetKnownUserGAPSCookie(const UserID& user_id) override; 145 std::string GetKnownUserGAPSCookie(const AccountId& account_id) override;
145 void UpdateReauthReason(const std::string& user_id, 146 void UpdateReauthReason(const AccountId& account_id,
146 const int reauth_reason) override; 147 const int reauth_reason) override;
achuithb 2015/10/28 23:11:47 don't need const here
Alexander Alekseev 2015/10/29 02:00:43 Done.
147 bool FindReauthReason(const std::string& user_id, int* out_value) override; 148 bool FindReauthReason(const AccountId& account_id, int* out_value) override;
148 149
149 virtual void SetIsCurrentUserNew(bool is_new); 150 virtual void SetIsCurrentUserNew(bool is_new);
achuithb 2015/10/28 23:11:47 Could you add a comment for this?
Alexander Alekseev 2015/10/29 02:00:43 Done.
150 151
151 // TODO(xiyuan): Figure out a better way to expose this info. 152 // TODO(xiyuan): Figure out a better way to expose this info.
152 virtual bool HasPendingBootstrap(const std::string& user_id) const; 153 virtual bool HasPendingBootstrap(const AccountId& account_id) const;
153 154
154 // Helper function that copies users from |users_list| to |users_vector| and 155 // Helper function that copies users from |users_list| to |users_vector| and
155 // |users_set|. Duplicates and users already present in |existing_users| are 156 // |users_set|. Duplicates and users already present in |existing_users| are
156 // skipped. 157 // skipped.
157 static void ParseUserList(const base::ListValue& users_list, 158 static void ParseUserList(const base::ListValue& users_list,
158 const std::set<std::string>& existing_users, 159 const std::set<AccountId>& existing_users,
159 std::vector<std::string>* users_vector, 160 std::vector<AccountId>* users_vector,
160 std::set<std::string>* users_set); 161 std::set<AccountId>* users_set);
161 162
162 // Returns true if trusted device policies have successfully been retrieved 163 // Returns true if trusted device policies have successfully been retrieved
163 // and ephemeral users are enabled. 164 // and ephemeral users are enabled.
164 virtual bool AreEphemeralUsersEnabled() const = 0; 165 virtual bool AreEphemeralUsersEnabled() const = 0;
165 166
166 protected: 167 protected:
167 // Adds |user| to users list, and adds it to front of LRU list. It is assumed 168 // Adds |user| to users list, and adds it to front of LRU list. It is assumed
168 // that there is no user with same id. 169 // that there is no user with same id.
169 virtual void AddUserRecord(User* user); 170 virtual void AddUserRecord(User* user);
170 171
171 // Returns true if user may be removed. 172 // Returns true if user may be removed.
172 virtual bool CanUserBeRemoved(const User* user) const; 173 virtual bool CanUserBeRemoved(const User* user) const;
173 174
174 // A wrapper around C++ delete operator. Deletes |user|, and when |user| 175 // A wrapper around C++ delete operator. Deletes |user|, and when |user|
175 // equals to active_user_, active_user_ is reset to NULL. 176 // equals to active_user_, active_user_ is reset to NULL.
176 virtual void DeleteUser(User* user); 177 virtual void DeleteUser(User* user);
177 178
178 // Returns the locale used by the application. 179 // Returns the locale used by the application.
179 virtual const std::string& GetApplicationLocale() const = 0; 180 virtual const std::string& GetApplicationLocale() const = 0;
180 181
181 // Returns "Local State" PrefService instance. 182 // Returns "Local State" PrefService instance.
182 virtual PrefService* GetLocalState() const = 0; 183 virtual PrefService* GetLocalState() const = 0;
183 184
184 // Loads |users_| from Local State if the list has not been loaded yet. 185 // Loads |users_| from Local State if the list has not been loaded yet.
185 // Subsequent calls have no effect. Must be called on the UI thread. 186 // Subsequent calls have no effect. Must be called on the UI thread.
186 virtual void EnsureUsersLoaded(); 187 virtual void EnsureUsersLoaded();
187 188
188 // Handle OAuth token |status| change for |user_id|. 189 // Handle OAuth token |status| change for |account_id|.
189 virtual void HandleUserOAuthTokenStatusChange( 190 virtual void HandleUserOAuthTokenStatusChange(
190 const std::string& user_id, 191 const AccountId& account_id,
191 User::OAuthTokenStatus status) const = 0; 192 User::OAuthTokenStatus status) const = 0;
192 193
193 // Returns true if device is enterprise managed. 194 // Returns true if device is enterprise managed.
194 virtual bool IsEnterpriseManaged() const = 0; 195 virtual bool IsEnterpriseManaged() const = 0;
195 196
196 // Helper function that copies users from |users_list| to |users_vector| and 197 // Helper function that copies users from |users_list| to |users_vector| and
197 // |users_set|. Duplicates and users already present in |existing_users| are 198 // |users_set|. Duplicates and users already present in |existing_users| are
198 // skipped. 199 // skipped.
199 // Loads public accounts from the Local state and fills in 200 // Loads public accounts from the Local state and fills in
200 // |public_sessions_set|. 201 // |public_sessions_set|.
201 virtual void LoadPublicAccounts( 202 virtual void LoadPublicAccounts(std::set<AccountId>* public_sessions_set) = 0;
202 std::set<std::string>* public_sessions_set) = 0;
203 203
204 // Notifies that user has logged in. 204 // Notifies that user has logged in.
205 virtual void NotifyOnLogin(); 205 virtual void NotifyOnLogin();
206 206
207 // Notifies observers that another user was added to the session. 207 // Notifies observers that another user was added to the session.
208 // If |user_switch_pending| is true this means that user has not been fully 208 // If |user_switch_pending| is true this means that user has not been fully
209 // initialized yet like waiting for profile to be loaded. 209 // initialized yet like waiting for profile to be loaded.
210 virtual void NotifyUserAddedToSession(const User* added_user, 210 virtual void NotifyUserAddedToSession(const User* added_user,
211 bool user_switch_pending); 211 bool user_switch_pending);
212 212
213 // Performs any additional actions before user list is loaded. 213 // Performs any additional actions before user list is loaded.
214 virtual void PerformPreUserListLoadingActions() = 0; 214 virtual void PerformPreUserListLoadingActions() = 0;
215 215
216 // Performs any additional actions after user list is loaded. 216 // Performs any additional actions after user list is loaded.
217 virtual void PerformPostUserListLoadingActions() = 0; 217 virtual void PerformPostUserListLoadingActions() = 0;
218 218
219 // Performs any additional actions after UserLoggedIn() execution has been 219 // Performs any additional actions after UserLoggedIn() execution has been
220 // completed. 220 // completed.
221 // |browser_restart| is true when reloading Chrome after crash to distinguish 221 // |browser_restart| is true when reloading Chrome after crash to distinguish
222 // from normal sign in flow. 222 // from normal sign in flow.
223 virtual void PerformPostUserLoggedInActions(bool browser_restart) = 0; 223 virtual void PerformPostUserLoggedInActions(bool browser_restart) = 0;
224 224
225 // Implementation for RemoveUser method. It is synchronous. It is called from 225 // Implementation for RemoveUser method. It is synchronous. It is called from
226 // RemoveUserInternal after owner check. 226 // RemoveUserInternal after owner check.
227 virtual void RemoveNonOwnerUserInternal(const std::string& user_email, 227 virtual void RemoveNonOwnerUserInternal(const AccountId& account_id,
228 RemoveUserDelegate* delegate); 228 RemoveUserDelegate* delegate);
229 229
230 // Removes a regular or supervised user from the user list. 230 // Removes a regular or supervised user from the user list.
231 // Returns the user if found or NULL otherwise. 231 // Returns the user if found or NULL otherwise.
232 // Also removes the user from the persistent user list. 232 // Also removes the user from the persistent user list.
233 User* RemoveRegularOrSupervisedUserFromList(const std::string& user_id); 233 User* RemoveRegularOrSupervisedUserFromList(const AccountId& account_id);
234 234
235 // Implementation for RemoveUser method. This is an asynchronous part of the 235 // Implementation for RemoveUser method. This is an asynchronous part of the
236 // method, that verifies that owner will not get deleted, and calls 236 // method, that verifies that owner will not get deleted, and calls
237 // |RemoveNonOwnerUserInternal|. 237 // |RemoveNonOwnerUserInternal|.
238 virtual void RemoveUserInternal(const std::string& user_email, 238 virtual void RemoveUserInternal(const AccountId& account_id,
239 RemoveUserDelegate* delegate); 239 RemoveUserDelegate* delegate);
240 240
241 // Removes data stored or cached outside the user's cryptohome (wallpaper, 241 // Removes data stored or cached outside the user's cryptohome (wallpaper,
242 // avatar, OAuth token status, display name, display email). 242 // avatar, OAuth token status, display name, display email).
243 virtual void RemoveNonCryptohomeData(const std::string& user_id); 243 virtual void RemoveNonCryptohomeData(const AccountId& account_id);
244 244
245 // Check for a particular user type. 245 // Check for a particular user type.
246 246
247 // Returns true if |user_id| represents demo app. 247 // Returns true if |account_id| represents demo app.
248 virtual bool IsDemoApp(const std::string& user_id) const = 0; 248 virtual bool IsDemoApp(const AccountId& account_id) const = 0;
249 249
250 // Returns true if |user_id| represents kiosk app. 250 // Returns true if |account_id| represents kiosk app.
251 virtual bool IsKioskApp(const std::string& user_id) const = 0; 251 virtual bool IsKioskApp(const AccountId& account_id) const = 0;
252 252
253 // Returns true if |user_id| represents public account that has been marked 253 // Returns true if |account_id| represents public account that has been marked
254 // for deletion. 254 // for deletion.
255 virtual bool IsPublicAccountMarkedForRemoval( 255 virtual bool IsPublicAccountMarkedForRemoval(
256 const std::string& user_id) const = 0; 256 const AccountId& account_id) const = 0;
257 257
258 // These methods are called when corresponding user type has signed in. 258 // These methods are called when corresponding user type has signed in.
259 259
260 // Indicates that the demo account has just logged in. 260 // Indicates that the demo account has just logged in.
261 virtual void DemoAccountLoggedIn() = 0; 261 virtual void DemoAccountLoggedIn() = 0;
262 262
263 // Indicates that a user just logged in as guest. 263 // Indicates that a user just logged in as guest.
264 virtual void GuestUserLoggedIn(); 264 virtual void GuestUserLoggedIn();
265 265
266 // Indicates that a kiosk app robot just logged in. 266 // Indicates that a kiosk app robot just logged in.
267 virtual void KioskAppLoggedIn(const std::string& app_id) = 0; 267 virtual void KioskAppLoggedIn(const AccountId& kiosk_app_account_id) = 0;
268 268
269 // Indicates that a user just logged into a public session. 269 // Indicates that a user just logged into a public session.
270 virtual void PublicAccountUserLoggedIn(User* user) = 0; 270 virtual void PublicAccountUserLoggedIn(User* user) = 0;
271 271
272 // Indicates that a regular user just logged in. 272 // Indicates that a regular user just logged in.
273 virtual void RegularUserLoggedIn(const std::string& user_id); 273 virtual void RegularUserLoggedIn(const AccountId& account_id);
274 274
275 // Indicates that a regular user just logged in as ephemeral. 275 // Indicates that a regular user just logged in as ephemeral.
276 virtual void RegularUserLoggedInAsEphemeral(const std::string& user_id); 276 virtual void RegularUserLoggedInAsEphemeral(const AccountId& account_id);
277 277
278 // Indicates that a supervised user just logged in. 278 // Indicates that a supervised user just logged in.
279 virtual void SupervisedUserLoggedIn(const std::string& user_id) = 0; 279 virtual void SupervisedUserLoggedIn(const AccountId& account_id) = 0;
280 280
281 // Should be called when regular user was removed. 281 // Should be called when regular user was removed.
282 virtual void OnUserRemoved(const std::string& user_id) = 0; 282 virtual void OnUserRemoved(const AccountId& account_id) = 0;
283 283
284 // Getters/setters for private members. 284 // Getters/setters for private members.
285 285
286 virtual void SetCurrentUserIsOwner(bool is_current_user_owner); 286 virtual void SetCurrentUserIsOwner(bool is_current_user_owner);
287 287
288 virtual bool GetEphemeralUsersEnabled() const; 288 virtual bool GetEphemeralUsersEnabled() const;
289 virtual void SetEphemeralUsersEnabled(bool enabled); 289 virtual void SetEphemeralUsersEnabled(bool enabled);
290 290
291 virtual void SetOwnerEmail(const std::string& owner_user_id); 291 virtual void SetOwnerId(const AccountId& owner_account_id);
292 292
293 virtual const std::string& GetPendingUserSwitchID() const; 293 virtual const AccountId& GetPendingUserSwitchID() const;
294 virtual void SetPendingUserSwitchID(const std::string& user_id); 294 virtual void SetPendingUserSwitchId(const AccountId& account_id);
295 295
296 // The logged-in user that is currently active in current session. 296 // The logged-in user that is currently active in current session.
297 // NULL until a user has logged in, then points to one 297 // NULL until a user has logged in, then points to one
298 // of the User instances in |users_|, the |guest_user_| instance or an 298 // of the User instances in |users_|, the |guest_user_| instance or an
299 // ephemeral user instance. 299 // ephemeral user instance.
300 User* active_user_; 300 User* active_user_ = nullptr;
301 301
302 // The primary user of the current session. It is recorded for the first 302 // The primary user of the current session. It is recorded for the first
303 // signed-in user and does not change thereafter. 303 // signed-in user and does not change thereafter.
304 User* primary_user_; 304 User* primary_user_ = nullptr;
305 305
306 // List of all known users. User instances are owned by |this|. Regular users 306 // List of all known users. User instances are owned by |this|. Regular users
307 // are removed by |RemoveUserFromList|, public accounts by 307 // are removed by |RemoveUserFromList|, public accounts by
308 // |UpdateAndCleanUpPublicAccounts|. 308 // |UpdateAndCleanUpPublicAccounts|.
309 UserList users_; 309 UserList users_;
310 310
311 // 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
312 // 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.
313 UserList logged_in_users_; 313 UserList logged_in_users_;
314 314
315 // 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
316 // |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
317 // 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.
318 UserList lru_logged_in_users_; 318 UserList lru_logged_in_users_;
319 319
320 private: 320 private:
321 // Stages of loading user list from preferences. Some methods can have 321 // Stages of loading user list from preferences. Some methods can have
322 // different behavior depending on stage. 322 // different behavior depending on stage.
323 enum UserLoadStage { STAGE_NOT_LOADED = 0, STAGE_LOADING, STAGE_LOADED }; 323 enum UserLoadStage { STAGE_NOT_LOADED = 0, STAGE_LOADING, STAGE_LOADED };
324 324
325 // Returns a list of users who have logged into this device previously. 325 // Returns a list of users who have logged into this device previously.
326 // Same as GetUsers but used if you need to modify User from that list. 326 // Same as GetUsers but used if you need to modify User from that list.
327 UserList& GetUsersAndModify(); 327 UserList& GetUsersAndModify();
328 328
329 // Returns the user with the given email address if found in the persistent 329 // Returns the user with the given email address if found in the persistent
330 // list. Returns |NULL| otherwise. 330 // list. Returns |NULL| otherwise.
331 const User* FindUserInList(const std::string& user_id) const; 331 const User* FindUserInList(const AccountId& account_id) const;
332 332
333 // Returns |true| if user with the given id is found in the persistent list. 333 // Returns |true| if user with the given id is found in the persistent list.
334 // Returns |false| otherwise. Does not trigger user loading. 334 // Returns |false| otherwise. Does not trigger user loading.
335 bool UserExistsInList(const std::string& user_id) const; 335 bool UserExistsInList(const AccountId& account_id) const;
336 336
337 // Same as FindUserInList but returns non-const pointer to User object. 337 // Same as FindUserInList but returns non-const pointer to User object.
338 User* FindUserInListAndModify(const std::string& user_id); 338 User* FindUserInListAndModify(const AccountId& account_id);
339 339
340 // Reads user's oauth token status from local state preferences. 340 // Reads user's oauth token status from local state preferences.
341 User::OAuthTokenStatus LoadUserOAuthStatus(const std::string& user_id) const; 341 User::OAuthTokenStatus LoadUserOAuthStatus(const AccountId& account_id) const;
342 342
343 // Read a flag indicating whether online authentication against GAIA should 343 // Read a flag indicating whether online authentication against GAIA should
344 // be enforced during the user's next sign-in from local state preferences. 344 // be enforced during the user's next sign-in from local state preferences.
345 bool LoadForceOnlineSignin(const std::string& user_id) const; 345 bool LoadForceOnlineSignin(const AccountId& account_id) const;
346 346
347 // Notifies observers that merge session state had changed. 347 // Notifies observers that merge session state had changed.
348 void NotifyMergeSessionStateChanged(); 348 void NotifyMergeSessionStateChanged();
349 349
350 // Notifies observers that active user has changed. 350 // Notifies observers that active user has changed.
351 void NotifyActiveUserChanged(const User* active_user); 351 void NotifyActiveUserChanged(const User* active_user);
352 352
353 // Notifies observers that active user_id hash has changed. 353 // Notifies observers that active account_id hash has changed.
354 void NotifyActiveUserHashChanged(const std::string& hash); 354 void NotifyActiveUserHashChanged(const std::string& hash);
355 355
356 // Update the global LoginState. 356 // Update the global LoginState.
357 void UpdateLoginState(); 357 void UpdateLoginState();
358 358
359 // Insert |user| at the front of the LRU user list. 359 // Insert |user| at the front of the LRU user list.
360 void SetLRUUser(User* user); 360 void SetLRUUser(User* user);
361 361
362 // Sends metrics in response to a user with gaia account (regular) logging in. 362 // Sends metrics in response to a user with gaia account (regular) logging in.
363 void SendGaiaUserLoginMetrics(const std::string& user_id); 363 void SendGaiaUserLoginMetrics(const AccountId& account_id);
364 364
365 // Sets account locale for user with id |user_id|. 365 // Sets account locale for user with id |account_id|.
366 virtual void UpdateUserAccountLocale(const std::string& user_id, 366 virtual void UpdateUserAccountLocale(const AccountId& account_id,
367 const std::string& locale); 367 const std::string& locale);
368 368
369 // Updates user account after locale was resolved. 369 // Updates user account after locale was resolved.
370 void DoUpdateAccountLocale(const std::string& user_id, 370 void DoUpdateAccountLocale(const AccountId& account_id,
371 scoped_ptr<std::string> resolved_locale); 371 scoped_ptr<std::string> resolved_locale);
372 372
373 // Removes all user preferences associated with |user_id|. 373 // Removes all user preferences associated with |account_id|.
374 void RemoveKnownUserPrefs(const UserID& user_id); 374 void RemoveKnownUserPrefs(const AccountId& account_id);
375 375
376 // Indicates stage of loading user from prefs. 376 // Indicates stage of loading user from prefs.
377 UserLoadStage user_loading_stage_; 377 UserLoadStage user_loading_stage_ = STAGE_NOT_LOADED;
378 378
379 // True if SessionStarted() has been called. 379 // True if SessionStarted() has been called.
380 bool session_started_; 380 bool session_started_ = false;
381 381
382 // Cached flag of whether currently logged-in user is owner or not. 382 // Cached flag of whether currently logged-in user is owner or not.
383 // May be accessed on different threads, requires locking. 383 // May be accessed on different threads, requires locking.
384 bool is_current_user_owner_; 384 bool is_current_user_owner_ = false;
385 mutable base::Lock is_current_user_owner_lock_; 385 mutable base::Lock is_current_user_owner_lock_;
386 386
387 // Cached flag of whether the currently logged-in user existed before this 387 // Cached flag of whether the currently logged-in user existed before this
388 // login. 388 // login.
389 bool is_current_user_new_; 389 bool is_current_user_new_ = false;
390 390
391 // Cached flag of whether the currently logged-in user is a regular user who 391 // Cached flag of whether the currently logged-in user is a regular user who
392 // logged in as ephemeral. Storage of persistent information is avoided for 392 // logged in as ephemeral. Storage of persistent information is avoided for
393 // such users by not adding them to the persistent user list, not downloading 393 // such users by not adding them to the persistent user list, not downloading
394 // their custom avatars and mounting their cryptohomes using tmpfs. Defaults 394 // their custom avatars and mounting their cryptohomes using tmpfs. Defaults
395 // to |false|. 395 // to |false|.
396 bool is_current_user_ephemeral_regular_user_; 396 bool is_current_user_ephemeral_regular_user_ = false;
397 397
398 // Cached flag indicating whether the ephemeral user policy is enabled. 398 // Cached flag indicating whether the ephemeral user policy is enabled.
399 // Defaults to |false| if the value has not been read from trusted device 399 // Defaults to |false| if the value has not been read from trusted device
400 // policy yet. 400 // policy yet.
401 bool ephemeral_users_enabled_; 401 bool ephemeral_users_enabled_ = false;
402 402
403 // Cached name of device owner. Defaults to empty string if the value has not 403 // Cached name of device owner. Defaults to empty if the value has not
404 // been read from trusted device policy yet. 404 // been read from trusted device policy yet.
405 std::string owner_email_; 405 AccountId owner_account_id_ = EmptyAccountId();
406 406
407 base::ObserverList<UserManager::Observer> observer_list_; 407 base::ObserverList<UserManager::Observer> observer_list_;
408 408
409 // TODO(nkostylev): Merge with session state refactoring CL. 409 // TODO(nkostylev): Merge with session state refactoring CL.
410 base::ObserverList<UserManager::UserSessionStateObserver> 410 base::ObserverList<UserManager::UserSessionStateObserver>
411 session_state_observer_list_; 411 session_state_observer_list_;
412 412
413 // Time at which this object was created. 413 // Time at which this object was created.
414 base::TimeTicks manager_creation_time_; 414 base::TimeTicks manager_creation_time_ = base::TimeTicks::Now();
415 415
416 // ID of the user just added to the session that needs to be activated 416 // ID of the user just added to the session that needs to be activated
417 // as soon as user's profile is loaded. 417 // as soon as user's profile is loaded.
418 std::string pending_user_switch_; 418 AccountId pending_user_switch_ = EmptyAccountId();
419 419
420 // ID of the user that was active in the previous session. 420 // ID of the user that was active in the previous session.
421 // Preference value is stored here before first user signs in 421 // Preference value is stored here before first user signs in
422 // because pref will be overidden once session restore starts. 422 // because pref will be overidden once session restore starts.
423 std::string last_session_active_user_; 423 AccountId last_session_active_account_id_ = EmptyAccountId();
424 bool last_session_active_user_initialized_; 424 bool last_session_active_account_id_initialized_ = false;
425 425
426 // TaskRunner for UI thread. 426 // TaskRunner for UI thread.
427 scoped_refptr<base::TaskRunner> task_runner_; 427 scoped_refptr<base::TaskRunner> task_runner_;
428 428
429 // TaskRunner for SequencedWorkerPool. 429 // TaskRunner for SequencedWorkerPool.
430 scoped_refptr<base::TaskRunner> blocking_task_runner_; 430 scoped_refptr<base::TaskRunner> blocking_task_runner_;
431 431
432 base::WeakPtrFactory<UserManagerBase> weak_factory_; 432 base::WeakPtrFactory<UserManagerBase> weak_factory_;
433 433
434 DISALLOW_COPY_AND_ASSIGN(UserManagerBase); 434 DISALLOW_COPY_AND_ASSIGN(UserManagerBase);
435 }; 435 };
436 436
437 } // namespace user_manager 437 } // namespace user_manager
438 438
439 #endif // COMPONENTS_USER_MANAGER_USER_MANAGER_BASE_H_ 439 #endif // COMPONENTS_USER_MANAGER_USER_MANAGER_BASE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698