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

Unified Diff: components/user_manager/user_manager_base.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 side-by-side diff with in-line comments
Download patch
Index: components/user_manager/user_manager_base.h
diff --git a/components/user_manager/user_manager_base.h b/components/user_manager/user_manager_base.h
index d8454efa620387eddf02c6e8fa3bc3cc7a06d9ea..ca6d8dc258f7f06987ac911a2bfaa01c9e29ff37 100644
--- a/components/user_manager/user_manager_base.h
+++ b/components/user_manager/user_manager_base.h
@@ -51,37 +51,37 @@ class USER_MANAGER_EXPORT UserManagerBase : public UserManager {
const UserList& GetUsers() const override;
const UserList& GetLoggedInUsers() const override;
const UserList& GetLRULoggedInUsers() const override;
- const std::string& GetOwnerEmail() const override;
- void UserLoggedIn(const std::string& user_id,
+ const UserID& GetOwnerID() const override;
+ void UserLoggedIn(const UserID& user_id,
const std::string& user_id_hash,
bool browser_restart) override;
- void SwitchActiveUser(const std::string& user_id) override;
+ void SwitchActiveUser(const UserID& user_id) override;
void SwitchToLastActiveUser() override;
void SessionStarted() override;
- void RemoveUser(const std::string& user_id,
+ void RemoveUser(const UserID& user_id,
RemoveUserDelegate* delegate) override;
- void RemoveUserFromList(const std::string& user_id) override;
- bool IsKnownUser(const std::string& user_id) const override;
- const User* FindUser(const std::string& user_id) const override;
- User* FindUserAndModify(const std::string& user_id) override;
+ void RemoveUserFromList(const UserID& user_id) override;
+ bool IsKnownUser(const UserID& user_id) const override;
+ const User* FindUser(const UserID& user_id) const override;
+ User* FindUserAndModify(const UserID& user_id) override;
const User* GetLoggedInUser() const override;
User* GetLoggedInUser() override;
const User* GetActiveUser() const override;
User* GetActiveUser() override;
const User* GetPrimaryUser() const override;
- void SaveUserOAuthStatus(const std::string& user_id,
+ void SaveUserOAuthStatus(const UserID& user_id,
User::OAuthTokenStatus oauth_token_status) override;
- void SaveForceOnlineSignin(const std::string& user_id,
+ void SaveForceOnlineSignin(const UserID& user_id,
bool force_online_signin) override;
- void SaveUserDisplayName(const std::string& user_id,
+ void SaveUserDisplayName(const UserID& user_id,
const base::string16& display_name) override;
- base::string16 GetUserDisplayName(const std::string& user_id) const override;
- void SaveUserDisplayEmail(const std::string& user_id,
+ base::string16 GetUserDisplayName(const UserID& user_id) const override;
+ void SaveUserDisplayEmail(const UserID& user_id,
const std::string& display_email) override;
- std::string GetUserDisplayEmail(const std::string& user_id) const override;
- void SaveUserType(const std::string& user_id,
+ std::string GetUserDisplayEmail(const UserID& user_id) const override;
+ void SaveUserType(const UserID& user_id,
const UserType& user_type) override;
- void UpdateUserAccountData(const std::string& user_id,
+ void UpdateUserAccountData(const UserID& user_id,
const UserAccountData& account_data) override;
bool IsCurrentUserOwner() const override;
bool IsCurrentUserNew() const override;
@@ -97,7 +97,7 @@ class USER_MANAGER_EXPORT UserManagerBase : public UserManager {
bool IsLoggedInAsStub() const override;
bool IsSessionStarted() const override;
bool IsUserNonCryptohomeDataEphemeral(
- const std::string& user_id) const override;
+ const UserID& user_id) const override;
void AddObserver(UserManager::Observer* obs) override;
void RemoveObserver(UserManager::Observer* obs) override;
void AddSessionStateObserver(
@@ -131,20 +131,20 @@ class USER_MANAGER_EXPORT UserManagerBase : public UserManager {
const int in_value) override;
void UpdateGaiaID(const UserID& user_id, const std::string& gaia_id) override;
bool FindGaiaID(const UserID& user_id, std::string* out_value) override;
- void UpdateUsingSAML(const std::string& user_id,
+ void UpdateUsingSAML(const UserID& user_id,
const bool using_saml) override;
- bool FindUsingSAML(const std::string& user_id) override;
+ bool FindUsingSAML(const UserID& user_id) override;
void SetKnownUserDeviceId(const UserID& user_id,
const std::string& device_id) override;
std::string GetKnownUserDeviceId(const UserID& user_id) override;
- void UpdateReauthReason(const std::string& user_id,
+ void UpdateReauthReason(const UserID& user_id,
const int reauth_reason) override;
- bool FindReauthReason(const std::string& user_id, int* out_value) override;
+ bool FindReauthReason(const UserID& user_id, int* out_value) override;
virtual void SetIsCurrentUserNew(bool is_new);
// TODO(xiyuan): Figure out a better way to expose this info.
- virtual bool HasPendingBootstrap(const std::string& user_id) const;
+ virtual bool HasPendingBootstrap(const UserID& user_id) const;
// Helper function that copies users from |users_list| to |users_vector| and
// |users_set|. Duplicates and users already present in |existing_users| are
@@ -182,7 +182,7 @@ class USER_MANAGER_EXPORT UserManagerBase : public UserManager {
// Handle OAuth token |status| change for |user_id|.
virtual void HandleUserOAuthTokenStatusChange(
- const std::string& user_id,
+ const UserID& user_id,
User::OAuthTokenStatus status) const = 0;
// Returns true if device is enterprise managed.
@@ -219,36 +219,36 @@ class USER_MANAGER_EXPORT UserManagerBase : public UserManager {
// Implementation for RemoveUser method. It is synchronous. It is called from
// RemoveUserInternal after owner check.
- virtual void RemoveNonOwnerUserInternal(const std::string& user_email,
+ virtual void RemoveNonOwnerUserInternal(const UserID& user_id,
RemoveUserDelegate* delegate);
// Removes a regular or supervised user from the user list.
// Returns the user if found or NULL otherwise.
// Also removes the user from the persistent user list.
- User* RemoveRegularOrSupervisedUserFromList(const std::string& user_id);
+ User* RemoveRegularOrSupervisedUserFromList(const UserID& user_id);
// Implementation for RemoveUser method. This is an asynchronous part of the
// method, that verifies that owner will not get deleted, and calls
// |RemoveNonOwnerUserInternal|.
- virtual void RemoveUserInternal(const std::string& user_email,
+ virtual void RemoveUserInternal(const UserID& user_id,
RemoveUserDelegate* delegate);
// Removes data stored or cached outside the user's cryptohome (wallpaper,
// avatar, OAuth token status, display name, display email).
- virtual void RemoveNonCryptohomeData(const std::string& user_id);
+ virtual void RemoveNonCryptohomeData(const UserID& user_id);
// Check for a particular user type.
// Returns true if |user_id| represents demo app.
- virtual bool IsDemoApp(const std::string& user_id) const = 0;
+ virtual bool IsDemoApp(const UserID& user_id) const = 0;
// Returns true if |user_id| represents kiosk app.
- virtual bool IsKioskApp(const std::string& user_id) const = 0;
+ virtual bool IsKioskApp(const UserID& user_id) const = 0;
// Returns true if |user_id| represents public account that has been marked
// for deletion.
virtual bool IsPublicAccountMarkedForRemoval(
- const std::string& user_id) const = 0;
+ const UserID& user_id) const = 0;
// These methods are called when corresponding user type has signed in.
@@ -265,13 +265,13 @@ class USER_MANAGER_EXPORT UserManagerBase : public UserManager {
virtual void PublicAccountUserLoggedIn(User* user) = 0;
// Indicates that a regular user just logged in.
- virtual void RegularUserLoggedIn(const std::string& user_id);
+ virtual void RegularUserLoggedIn(const UserID& user_id);
// Indicates that a regular user just logged in as ephemeral.
- virtual void RegularUserLoggedInAsEphemeral(const std::string& user_id);
+ virtual void RegularUserLoggedInAsEphemeral(const UserID& user_id);
// Indicates that a supervised user just logged in.
- virtual void SupervisedUserLoggedIn(const std::string& user_id) = 0;
+ virtual void SupervisedUserLoggedIn(const UserID& user_id) = 0;
// Getters/setters for private members.
@@ -280,10 +280,10 @@ class USER_MANAGER_EXPORT UserManagerBase : public UserManager {
virtual bool GetEphemeralUsersEnabled() const;
virtual void SetEphemeralUsersEnabled(bool enabled);
- virtual void SetOwnerEmail(std::string owner_user_id);
+ virtual void SetOwnerID(const UserID& owner_user_id);
- virtual const std::string& GetPendingUserSwitchID() const;
- virtual void SetPendingUserSwitchID(std::string user_id);
+ virtual const UserID& GetPendingUserSwitchID() const;
+ virtual void SetPendingUserSwitchID(const UserID& user_id);
// The logged-in user that is currently active in current session.
// NULL until a user has logged in, then points to one
@@ -320,21 +320,21 @@ class USER_MANAGER_EXPORT UserManagerBase : public UserManager {
// Returns the user with the given email address if found in the persistent
// list. Returns |NULL| otherwise.
- const User* FindUserInList(const std::string& user_id) const;
+ const User* FindUserInList(const UserID& user_id) const;
// Returns |true| if user with the given id is found in the persistent list.
// Returns |false| otherwise. Does not trigger user loading.
- bool UserExistsInList(const std::string& user_id) const;
+ bool UserExistsInList(const UserID& user_id) const;
// Same as FindUserInList but returns non-const pointer to User object.
- User* FindUserInListAndModify(const std::string& user_id);
+ User* FindUserInListAndModify(const UserID& user_id);
// Reads user's oauth token status from local state preferences.
- User::OAuthTokenStatus LoadUserOAuthStatus(const std::string& user_id) const;
+ User::OAuthTokenStatus LoadUserOAuthStatus(const UserID& user_id) const;
// Read a flag indicating whether online authentication against GAIA should
// be enforced during the user's next sign-in from local state preferences.
- bool LoadForceOnlineSignin(const std::string& user_id) const;
+ bool LoadForceOnlineSignin(const UserID& user_id) const;
// Notifies observers that merge session state had changed.
void NotifyMergeSessionStateChanged();
@@ -352,14 +352,14 @@ class USER_MANAGER_EXPORT UserManagerBase : public UserManager {
void SetLRUUser(User* user);
// Sends metrics in response to a user with gaia account (regular) logging in.
- void SendGaiaUserLoginMetrics(const std::string& user_id);
+ void SendGaiaUserLoginMetrics(const UserID& user_id);
// Sets account locale for user with id |user_id|.
- virtual void UpdateUserAccountLocale(const std::string& user_id,
+ virtual void UpdateUserAccountLocale(const UserID& user_id,
const std::string& locale);
// Updates user account after locale was resolved.
- void DoUpdateAccountLocale(const std::string& user_id,
+ void DoUpdateAccountLocale(const UserID& user_id,
scoped_ptr<std::string> resolved_locale);
// Removes all user preferences associated with |user_id|.
@@ -392,9 +392,9 @@ class USER_MANAGER_EXPORT UserManagerBase : public UserManager {
// policy yet.
bool ephemeral_users_enabled_;
- // Cached name of device owner. Defaults to empty string if the value has not
+ // Cached id of device owner. Defaults to empty id if the value has not
// been read from trusted device policy yet.
- std::string owner_email_;
+ UserID owner_id_;
ObserverList<UserManager::Observer> observer_list_;
@@ -407,12 +407,12 @@ class USER_MANAGER_EXPORT UserManagerBase : public UserManager {
// ID of the user just added to the session that needs to be activated
// as soon as user's profile is loaded.
- std::string pending_user_switch_;
+ user_manager::UserID pending_user_switch_;
// ID of the user that was active in the previous session.
// Preference value is stored here before first user signs in
// because pref will be overidden once session restore starts.
- std::string last_session_active_user_;
+ user_manager::UserID last_session_active_user_;
bool last_session_active_user_initialized_;
// TaskRunner for UI thread.

Powered by Google App Engine
This is Rietveld 408576698