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

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

Issue 1165323004: We should use UserID object to identify users instead of username. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 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
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_H_ 5 #ifndef COMPONENTS_USER_MANAGER_USER_MANAGER_H_
6 #define COMPONENTS_USER_MANAGER_USER_MANAGER_H_ 6 #define COMPONENTS_USER_MANAGER_USER_MANAGER_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "components/user_manager/user.h" 10 #include "components/user_manager/user.h"
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 virtual const UserList& GetLRULoggedInUsers() const = 0; 131 virtual const UserList& GetLRULoggedInUsers() const = 0;
132 132
133 // Returns a list of users who can unlock the device. 133 // Returns a list of users who can unlock the device.
134 // This list is based on policy and whether user is able to do unlock. 134 // This list is based on policy and whether user is able to do unlock.
135 // Policy: 135 // Policy:
136 // * If user has primary-only policy then it is the only user in unlock users. 136 // * If user has primary-only policy then it is the only user in unlock users.
137 // * Otherwise all users with unrestricted policy are added to this list. 137 // * Otherwise all users with unrestricted policy are added to this list.
138 // All users that are unable to perform unlock are excluded from this list. 138 // All users that are unable to perform unlock are excluded from this list.
139 virtual UserList GetUnlockUsers() const = 0; 139 virtual UserList GetUnlockUsers() const = 0;
140 140
141 // Returns the email of the owner user. Returns an empty string if there is 141 // Returns the id of the owner user. Returns an empty id if there is
142 // no owner for the device. 142 // no owner for the device.
143 virtual const std::string& GetOwnerEmail() const = 0; 143 virtual const UserID& GetOwnerID() const = 0;
144 144
145 // Indicates that a user with the given |user_id| has just logged in. The 145 // Indicates that a user with the given |user_id| has just logged in. The
146 // persistent list is updated accordingly if the user is not ephemeral. 146 // persistent list is updated accordingly if the user is not ephemeral.
147 // |browser_restart| is true when reloading Chrome after crash to distinguish 147 // |browser_restart| is true when reloading Chrome after crash to distinguish
148 // from normal sign in flow. 148 // from normal sign in flow.
149 // |username_hash| is used to identify homedir mount point. 149 // |username_hash| is used to identify homedir mount point.
150 virtual void UserLoggedIn(const std::string& user_id, 150 virtual void UserLoggedIn(const UserID& user_id,
151 const std::string& username_hash, 151 const std::string& username_hash,
152 bool browser_restart) = 0; 152 bool browser_restart) = 0;
153 153
154 // Switches to active user identified by |user_id|. User has to be logged in. 154 // Switches to active user identified by |user_id|. User has to be logged in.
155 virtual void SwitchActiveUser(const std::string& user_id) = 0; 155 virtual void SwitchActiveUser(const UserID& user_id) = 0;
156 156
157 // Switches to the last active user (called after crash happens and session 157 // Switches to the last active user (called after crash happens and session
158 // restore has completed). 158 // restore has completed).
159 virtual void SwitchToLastActiveUser() = 0; 159 virtual void SwitchToLastActiveUser() = 0;
160 160
161 // Called when browser session is started i.e. after 161 // Called when browser session is started i.e. after
162 // browser_creator.LaunchBrowser(...) was called after user sign in. 162 // browser_creator.LaunchBrowser(...) was called after user sign in.
163 // When user is at the image screen IsUserLoggedIn() will return true 163 // When user is at the image screen IsUserLoggedIn() will return true
164 // but IsSessionStarted() will return false. During the kiosk splash screen, 164 // but IsSessionStarted() will return false. During the kiosk splash screen,
165 // we perform additional initialization after the user is logged in but 165 // we perform additional initialization after the user is logged in but
166 // before the session has been started. 166 // before the session has been started.
167 // Fires NOTIFICATION_SESSION_STARTED. 167 // Fires NOTIFICATION_SESSION_STARTED.
168 virtual void SessionStarted() = 0; 168 virtual void SessionStarted() = 0;
169 169
170 // Removes the user from the device. Note, it will verify that the given user 170 // Removes the user from the device. Note, it will verify that the given user
171 // isn't the owner, so calling this method for the owner will take no effect. 171 // isn't the owner, so calling this method for the owner will take no effect.
172 // Note, |delegate| can be NULL. 172 // Note, |delegate| can be NULL.
173 virtual void RemoveUser(const std::string& user_id, 173 virtual void RemoveUser(const UserID& user_id,
174 RemoveUserDelegate* delegate) = 0; 174 RemoveUserDelegate* delegate) = 0;
175 175
176 // Removes the user from the persistent list only. Also removes the user's 176 // Removes the user from the persistent list only. Also removes the user's
177 // picture. 177 // picture.
178 virtual void RemoveUserFromList(const std::string& user_id) = 0; 178 virtual void RemoveUserFromList(const UserID& user_id) = 0;
179 179
180 // Returns true if a user with the given user id is found in the persistent 180 // Returns true if a user with the given user id is found in the persistent
181 // list or currently logged in as ephemeral. 181 // list or currently logged in as ephemeral.
182 virtual bool IsKnownUser(const std::string& user_id) const = 0; 182 virtual bool IsKnownUser(const UserID& user_id) const = 0;
183 183
184 // Returns the user with the given user id if found in the persistent 184 // Returns the user with the given user id if found in the persistent
185 // list or currently logged in as ephemeral. Returns |NULL| otherwise. 185 // list or currently logged in as ephemeral. Returns |NULL| otherwise.
186 virtual const User* FindUser(const std::string& user_id) const = 0; 186 virtual const User* FindUser(const UserID& user_id) const = 0;
187 187
188 // Returns the user with the given user id if found in the persistent 188 // Returns the user with the given user id if found in the persistent
189 // list or currently logged in as ephemeral. Returns |NULL| otherwise. 189 // list or currently logged in as ephemeral. Returns |NULL| otherwise.
190 // Same as FindUser but returns non-const pointer to User object. 190 // Same as FindUser but returns non-const pointer to User object.
191 virtual User* FindUserAndModify(const std::string& user_id) = 0; 191 virtual User* FindUserAndModify(const UserID& user_id) = 0;
192 192
193 // Returns the logged-in user. 193 // Returns the logged-in user.
194 // TODO(nkostylev): Deprecate this call, move clients to GetActiveUser(). 194 // TODO(nkostylev): Deprecate this call, move clients to GetActiveUser().
195 // http://crbug.com/230852 195 // http://crbug.com/230852
196 virtual const User* GetLoggedInUser() const = 0; 196 virtual const User* GetLoggedInUser() const = 0;
197 virtual User* GetLoggedInUser() = 0; 197 virtual User* GetLoggedInUser() = 0;
198 198
199 // Returns the logged-in user that is currently active within this session. 199 // Returns the logged-in user that is currently active within this session.
200 // There could be multiple users logged in at the the same but for now 200 // There could be multiple users logged in at the the same but for now
201 // we support only one of them being active. 201 // we support only one of them being active.
202 virtual const User* GetActiveUser() const = 0; 202 virtual const User* GetActiveUser() const = 0;
203 virtual User* GetActiveUser() = 0; 203 virtual User* GetActiveUser() = 0;
204 204
205 // Returns the primary user of the current session. It is recorded for the 205 // Returns the primary user of the current session. It is recorded for the
206 // first signed-in user and does not change thereafter. 206 // first signed-in user and does not change thereafter.
207 virtual const User* GetPrimaryUser() const = 0; 207 virtual const User* GetPrimaryUser() const = 0;
208 208
209 // Saves user's oauth token status in local state preferences. 209 // Saves user's oauth token status in local state preferences.
210 virtual void SaveUserOAuthStatus( 210 virtual void SaveUserOAuthStatus(
211 const std::string& user_id, 211 const UserID& user_id,
212 User::OAuthTokenStatus oauth_token_status) = 0; 212 User::OAuthTokenStatus oauth_token_status) = 0;
213 213
214 // Saves a flag indicating whether online authentication against GAIA should 214 // Saves a flag indicating whether online authentication against GAIA should
215 // be enforced during the user's next sign-in. 215 // be enforced during the user's next sign-in.
216 virtual void SaveForceOnlineSignin(const std::string& user_id, 216 virtual void SaveForceOnlineSignin(const UserID& user_id,
217 bool force_online_signin) = 0; 217 bool force_online_signin) = 0;
218 218
219 // Saves user's displayed name in local state preferences. 219 // Saves user's displayed name in local state preferences.
220 // Ignored If there is no such user. 220 // Ignored If there is no such user.
221 virtual void SaveUserDisplayName(const std::string& user_id, 221 virtual void SaveUserDisplayName(const UserID& user_id,
222 const base::string16& display_name) = 0; 222 const base::string16& display_name) = 0;
223 223
224 // Updates data upon User Account download. 224 // Updates data upon User Account download.
225 virtual void UpdateUserAccountData(const std::string& user_id, 225 virtual void UpdateUserAccountData(const UserID& user_id,
226 const UserAccountData& account_data) = 0; 226 const UserAccountData& account_data) = 0;
227 227
228 // Returns the display name for user |user_id| if it is known (was 228 // Returns the display name for user |user_id| if it is known (was
229 // previously set by a |SaveUserDisplayName| call). 229 // previously set by a |SaveUserDisplayName| call).
230 // Otherwise, returns an empty string. 230 // Otherwise, returns an empty string.
231 virtual base::string16 GetUserDisplayName( 231 virtual base::string16 GetUserDisplayName(
232 const std::string& user_id) const = 0; 232 const UserID& user_id) const = 0;
233 233
234 // Saves user's displayed (non-canonical) email in local state preferences. 234 // Saves user's displayed (non-canonical) email in local state preferences.
235 // Ignored If there is no such user. 235 // Ignored If there is no such user.
236 virtual void SaveUserDisplayEmail(const std::string& user_id, 236 virtual void SaveUserDisplayEmail(const UserID& user_id,
237 const std::string& display_email) = 0; 237 const std::string& display_email) = 0;
238 238
239 // Returns the display email for user |user_id| if it is known (was 239 // Returns the display email for user |user_id| if it is known (was
240 // previously set by a |SaveUserDisplayEmail| call). 240 // previously set by a |SaveUserDisplayEmail| call).
241 // Otherwise, returns |user_id| itself. 241 // Otherwise, returns |user_id| itself.
242 virtual std::string GetUserDisplayEmail(const std::string& user_id) const = 0; 242 virtual std::string GetUserDisplayEmail(const UserID& user_id) const = 0;
243 243
244 // Saves user's type for user |user_id| into local state preferences. 244 // Saves user's type for user |user_id| into local state preferences.
245 // Ignored If there is no such user. 245 // Ignored If there is no such user.
246 virtual void SaveUserType(const std::string& user_id, 246 virtual void SaveUserType(const UserID& user_id,
247 const UserType& user_type) = 0; 247 const UserType& user_type) = 0;
248 248
249 // Returns true if current user is an owner. 249 // Returns true if current user is an owner.
250 virtual bool IsCurrentUserOwner() const = 0; 250 virtual bool IsCurrentUserOwner() const = 0;
251 251
252 // Returns true if current user is not existing one (hasn't signed in before). 252 // Returns true if current user is not existing one (hasn't signed in before).
253 virtual bool IsCurrentUserNew() const = 0; 253 virtual bool IsCurrentUserNew() const = 0;
254 254
255 // Returns true if data stored or cached for the current user outside that 255 // Returns true if data stored or cached for the current user outside that
256 // user's cryptohome (wallpaper, avatar, OAuth token status, display name, 256 // user's cryptohome (wallpaper, avatar, OAuth token status, display name,
(...skipping 30 matching lines...) Expand all
287 287
288 // Returns true if we're logged in and browser has been started i.e. 288 // Returns true if we're logged in and browser has been started i.e.
289 // browser_creator.LaunchBrowser(...) was called after sign in 289 // browser_creator.LaunchBrowser(...) was called after sign in
290 // or restart after crash. 290 // or restart after crash.
291 virtual bool IsSessionStarted() const = 0; 291 virtual bool IsSessionStarted() const = 0;
292 292
293 // Returns true if data stored or cached for the user with the given user id 293 // Returns true if data stored or cached for the user with the given user id
294 // address outside that user's cryptohome (wallpaper, avatar, OAuth token 294 // address outside that user's cryptohome (wallpaper, avatar, OAuth token
295 // status, display name, display email) is to be treated as ephemeral. 295 // status, display name, display email) is to be treated as ephemeral.
296 virtual bool IsUserNonCryptohomeDataEphemeral( 296 virtual bool IsUserNonCryptohomeDataEphemeral(
297 const std::string& user_id) const = 0; 297 const UserID& user_id) const = 0;
298 298
299 virtual void AddObserver(Observer* obs) = 0; 299 virtual void AddObserver(Observer* obs) = 0;
300 virtual void RemoveObserver(Observer* obs) = 0; 300 virtual void RemoveObserver(Observer* obs) = 0;
301 301
302 virtual void AddSessionStateObserver(UserSessionStateObserver* obs) = 0; 302 virtual void AddSessionStateObserver(UserSessionStateObserver* obs) = 0;
303 virtual void RemoveSessionStateObserver(UserSessionStateObserver* obs) = 0; 303 virtual void RemoveSessionStateObserver(UserSessionStateObserver* obs) = 0;
304 304
305 virtual void NotifyLocalStateChanged() = 0; 305 virtual void NotifyLocalStateChanged() = 0;
306 306
307 // Changes the child status and notifies observers. 307 // Changes the child status and notifies observers.
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 static UserManager* GetForTesting(); 410 static UserManager* GetForTesting();
411 411
412 // Sets UserManager instance to the given |user_manager|. 412 // Sets UserManager instance to the given |user_manager|.
413 // Returns the previous value of the instance. 413 // Returns the previous value of the instance.
414 static UserManager* SetForTesting(UserManager* user_manager); 414 static UserManager* SetForTesting(UserManager* user_manager);
415 }; 415 };
416 416
417 } // namespace user_manager 417 } // namespace user_manager
418 418
419 #endif // COMPONENTS_USER_MANAGER_USER_MANAGER_H_ 419 #endif // COMPONENTS_USER_MANAGER_USER_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698