diff options
author | rjkroege <rjkroege@chromium.org> | 2015-10-30 16:25:57 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-10-30 23:26:58 +0000 |
commit | 6fa8e13e56429c6cefbba3d5a76f2c41ce28581b (patch) | |
tree | 4a2835a8179802c61d1452e6cfde4414e2541736 /components/user_manager | |
parent | 3f73175145f4d2ae8d41ca974a1eb67ae3043df3 (diff) | |
download | chromium_src-6fa8e13e56429c6cefbba3d5a76f2c41ce28581b.zip chromium_src-6fa8e13e56429c6cefbba3d5a76f2c41ce28581b.tar.gz chromium_src-6fa8e13e56429c6cefbba3d5a76f2c41ce28581b.tar.bz2 |
Revert of This CL replaces user_manager::UserID with AccountId. (patchset #12 id:210001 of https://codereview.chromium.org/1412813003/ )
Reason for revert:
breaks the GN build on windows:
FAILED: E:/b/depot_tools/python276_bin/python.exe gyp-win-tool link-wrapper environment.x86 False link.exe /nologo /OUT:ash_unittests.exe /PDB:ash_unittests.exe.pdb @ash_unittests.exe.rsp
test_session_state_delegate.obj : error LNK2019: unresolved external symbol "public: __thiscall AccountId::AccountId(class AccountId const &)" (??0AccountId@@QAE@ABV0@@Z) referenced in function "public: virtual class AccountId __thiscall ash::test::MockUserInfo::GetAccountId(void)const " (?GetAccountId@MockUserInfo@test@ash@@UBE?AVAccountId@@XZ)
test_session_state_delegate.obj : error LNK2019: unresolved external symbol "public: bool __thiscall AccountId::operator==(class AccountId const &)const " (??8AccountId@@QBE_NABV0@@Z) referenced in function "public: virtual void __thiscall ash::test::TestSessionStateDelegate::SwitchActiveUser(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?SwitchActiveUser@TestSessionStateDelegate@test@ash@@UAEXABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)
test_session_state_delegate.obj : error LNK2019: unresolved external symbol "public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const & __thiscall AccountId::GetUserEmail(void)const " (?GetUserEmail@AccountId@@QBEABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ) referenced in function "public: virtual void __thiscall ash::test::TestSessionStateDelegate::SwitchActiveUser(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?SwitchActiveUser@TestSessionStateDelegate@test@ash@@UAEXABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)
test_session_state_delegate.obj : error LNK2019: unresolved external symbol "public: static class AccountId __cdecl AccountId::FromUserEmail(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?FromUserEmail@AccountId@@SA?AV1@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) referenced in function "class AccountId __cdecl ash::test::`anonymous namespace'::GetAccountIdFromEmail(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?GetAccountIdFromEmail@?A0x8b8d8028@test@ash@@YA?AVAccountId@@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)
ash_unittests.exe : fatal error LNK1120: 4 unresolved externals
ninja: build stopped: subcommand failed.
Original issue's description:
> This CL replaces user_manager::UserID with AccountId.
>
> This CL replaces API of user_manager::UserManager, thus modifying API of all
> child objects, and all calls to UserManager.
>
> This is part of transition to AccountId.
>
> BUG=468875
> TEST=manual
>
> Committed: https://crrev.com/cd06408625de9e0d5cf4c7c1ede412cb5c82542b
> Cr-Commit-Position: refs/heads/master@{#357119}
TBR=jochen@chromium.org,achuith@chromium.org,bshe@chromium.org,rogerta@chromium.org,sky@chromium.org,stevenjb@chromium.org,alemate@chromium.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=468875
Review URL: https://codereview.chromium.org/1425093004
Cr-Commit-Position: refs/heads/master@{#357219}
Diffstat (limited to 'components/user_manager')
-rw-r--r-- | components/user_manager/BUILD.gn | 3 | ||||
-rw-r--r-- | components/user_manager/DEPS | 1 | ||||
-rw-r--r-- | components/user_manager/empty_user_info.cc | 5 | ||||
-rw-r--r-- | components/user_manager/empty_user_info.h | 2 | ||||
-rw-r--r-- | components/user_manager/fake_user_manager.cc | 78 | ||||
-rw-r--r-- | components/user_manager/fake_user_manager.h | 64 | ||||
-rw-r--r-- | components/user_manager/user.cc | 71 | ||||
-rw-r--r-- | components/user_manager/user.h | 43 | ||||
-rw-r--r-- | components/user_manager/user_id.h | 17 | ||||
-rw-r--r-- | components/user_manager/user_info.h | 8 | ||||
-rw-r--r-- | components/user_manager/user_info_impl.cc | 5 | ||||
-rw-r--r-- | components/user_manager/user_info_impl.h | 2 | ||||
-rw-r--r-- | components/user_manager/user_manager.h | 142 | ||||
-rw-r--r-- | components/user_manager/user_manager_base.cc | 478 | ||||
-rw-r--r-- | components/user_manager/user_manager_base.h | 186 |
15 files changed, 543 insertions, 562 deletions
diff --git a/components/user_manager/BUILD.gn b/components/user_manager/BUILD.gn index 55ab2a2..0dfc852 100644 --- a/components/user_manager/BUILD.gn +++ b/components/user_manager/BUILD.gn @@ -6,6 +6,7 @@ component("user_manager") { sources = [ "empty_user_info.cc", "empty_user_info.h", + "user_id.h", "user_info.cc", "user_info.h", "user_info_impl.cc", @@ -15,7 +16,6 @@ component("user_manager") { deps = [ "//base", - "//components/signin/core/account_id", "//skia", "//ui/gfx", ] @@ -60,7 +60,6 @@ source_set("test_support") { deps = [ ":user_manager", "//base", - "//components/signin/core/account_id", "//skia", "//ui/base", ] diff --git a/components/user_manager/DEPS b/components/user_manager/DEPS index 5c77f80..c21fe3c 100644 --- a/components/user_manager/DEPS +++ b/components/user_manager/DEPS @@ -4,7 +4,6 @@ include_rules = [ "+chromeos/login/login_state.h", "+chromeos/login/user_names.h", "+components/session_manager/core/session_manager.h", -"+components/signin/core/account_id/account_id.h", "+google_apis/gaia/gaia_auth_util.h", "+third_party/skia/include", "+ui/base/l10n", diff --git a/components/user_manager/empty_user_info.cc b/components/user_manager/empty_user_info.cc index 08d4a19..ab886f1 100644 --- a/components/user_manager/empty_user_info.cc +++ b/components/user_manager/empty_user_info.cc @@ -6,7 +6,6 @@ #include "base/logging.h" #include "base/strings/utf_string_conversions.h" -#include "components/signin/core/account_id/account_id.h" namespace user_manager { @@ -31,9 +30,9 @@ std::string EmptyUserInfo::GetEmail() const { return std::string(); } -AccountId EmptyUserInfo::GetAccountId() const { +std::string EmptyUserInfo::GetUserID() const { NOTIMPLEMENTED(); - return EmptyAccountId(); + return std::string(); } const gfx::ImageSkia& EmptyUserInfo::GetImage() const { diff --git a/components/user_manager/empty_user_info.h b/components/user_manager/empty_user_info.h index 76c0d16..52d677c 100644 --- a/components/user_manager/empty_user_info.h +++ b/components/user_manager/empty_user_info.h @@ -25,7 +25,7 @@ class USER_MANAGER_EXPORT EmptyUserInfo : public UserInfo { base::string16 GetDisplayName() const override; base::string16 GetGivenName() const override; std::string GetEmail() const override; - AccountId GetAccountId() const override; + std::string GetUserID() const override; const gfx::ImageSkia& GetImage() const override; private: diff --git a/components/user_manager/fake_user_manager.cc b/components/user_manager/fake_user_manager.cc index 4caa1b3..39f63f1 100644 --- a/components/user_manager/fake_user_manager.cc +++ b/components/user_manager/fake_user_manager.cc @@ -31,30 +31,28 @@ namespace user_manager { FakeUserManager::FakeUserManager() : UserManagerBase(new FakeTaskRunner(), new FakeTaskRunner()), - primary_user_(nullptr) {} + primary_user_(NULL), + owner_email_(std::string()) { +} FakeUserManager::~FakeUserManager() { } -const user_manager::User* FakeUserManager::AddUser( - const AccountId& account_id) { - return AddUserWithAffiliation(account_id, false); +const user_manager::User* FakeUserManager::AddUser(const std::string& email) { + return AddUserWithAffiliation(email, false); } const user_manager::User* FakeUserManager::AddUserWithAffiliation( - const AccountId& account_id, - bool is_affiliated) { - user_manager::User* user = user_manager::User::CreateRegularUser(account_id); + const std::string& email, bool is_affiliated) { + user_manager::User* user = user_manager::User::CreateRegularUser(email); user->set_affiliation(is_affiliated); users_.push_back(user); return user; } -void FakeUserManager::RemoveUserFromList(const AccountId& account_id) { +void FakeUserManager::RemoveUserFromList(const std::string& email) { user_manager::UserList::iterator it = users_.begin(); - // TODO (alemate): Chenge this to GetAccountId(), once a real AccountId is - // passed. crbug.com/546876 - while (it != users_.end() && (*it)->GetEmail() != account_id.GetUserEmail()) + while (it != users_.end() && (*it)->email() != email) ++it; if (it != users_.end()) { delete *it; @@ -81,7 +79,7 @@ const user_manager::UserList& FakeUserManager::GetLoggedInUsers() const { return logged_in_users_; } -void FakeUserManager::UserLoggedIn(const AccountId& account_id, +void FakeUserManager::UserLoggedIn(const std::string& email, const std::string& username_hash, bool browser_restart) { for (user_manager::UserList::const_iterator it = users_.begin(); @@ -99,20 +97,17 @@ void FakeUserManager::UserLoggedIn(const AccountId& account_id, } user_manager::User* FakeUserManager::GetActiveUserInternal() const { - if (!users_.empty()) { - if (active_account_id_.is_valid()) { + if (users_.size()) { + if (!active_user_id_.empty()) { for (user_manager::UserList::const_iterator it = users_.begin(); it != users_.end(); ++it) { - // TODO (alemate): Chenge this to GetAccountId(), once a real AccountId - // is - // passed. crbug.com/546876 - if ((*it)->GetEmail() == active_account_id_.GetUserEmail()) + if ((*it)->email() == active_user_id_) return *it; } } return users_[0]; } - return nullptr; + return NULL; } const user_manager::User* FakeUserManager::GetActiveUser() const { @@ -123,15 +118,14 @@ user_manager::User* FakeUserManager::GetActiveUser() { return GetActiveUserInternal(); } -void FakeUserManager::SwitchActiveUser(const AccountId& account_id) {} +void FakeUserManager::SwitchActiveUser(const std::string& email) { +} -void FakeUserManager::SaveUserDisplayName(const AccountId& account_id, +void FakeUserManager::SaveUserDisplayName(const std::string& username, const base::string16& display_name) { for (user_manager::UserList::iterator it = users_.begin(); it != users_.end(); ++it) { - // TODO (alemate): Chenge this to GetAccountId(), once a real AccountId is - // passed. crbug.com/546876 - if ((*it)->GetEmail() == account_id.GetUserEmail()) { + if ((*it)->email() == username) { (*it)->set_display_name(display_name); return; } @@ -146,38 +140,36 @@ user_manager::UserList FakeUserManager::GetUnlockUsers() const { return users_; } -const AccountId& FakeUserManager::GetOwnerAccountId() const { - return owner_account_id_; +const std::string& FakeUserManager::GetOwnerEmail() const { + return owner_email_; } -bool FakeUserManager::IsKnownUser(const AccountId& account_id) const { +bool FakeUserManager::IsKnownUser(const std::string& email) const { return true; } const user_manager::User* FakeUserManager::FindUser( - const AccountId& account_id) const { + const std::string& email) const { const user_manager::UserList& users = GetUsers(); for (user_manager::UserList::const_iterator it = users.begin(); it != users.end(); ++it) { - // TODO (alemate): Chenge this to GetAccountId(), once a real AccountId is - // passed. crbug.com/546876 - if ((*it)->GetEmail() == account_id.GetUserEmail()) + if ((*it)->email() == email) return *it; } - return nullptr; + return NULL; } user_manager::User* FakeUserManager::FindUserAndModify( - const AccountId& account_id) { - return nullptr; + const std::string& email) { + return NULL; } const user_manager::User* FakeUserManager::GetLoggedInUser() const { - return nullptr; + return NULL; } user_manager::User* FakeUserManager::GetLoggedInUser() { - return nullptr; + return NULL; } const user_manager::User* FakeUserManager::GetPrimaryUser() const { @@ -185,12 +177,12 @@ const user_manager::User* FakeUserManager::GetPrimaryUser() const { } base::string16 FakeUserManager::GetUserDisplayName( - const AccountId& account_id) const { + const std::string& username) const { return base::string16(); } std::string FakeUserManager::GetUserDisplayEmail( - const AccountId& account_id) const { + const std::string& username) const { return std::string(); } @@ -246,7 +238,7 @@ bool FakeUserManager::IsSessionStarted() const { } bool FakeUserManager::IsUserNonCryptohomeDataEphemeral( - const AccountId& account_id) const { + const std::string& email) const { return false; } @@ -264,23 +256,23 @@ const std::string& FakeUserManager::GetApplicationLocale() const { } PrefService* FakeUserManager::GetLocalState() const { - return nullptr; + return NULL; } bool FakeUserManager::IsEnterpriseManaged() const { return false; } -bool FakeUserManager::IsDemoApp(const AccountId& account_id) const { +bool FakeUserManager::IsDemoApp(const std::string& user_id) const { return false; } -bool FakeUserManager::IsKioskApp(const AccountId& account_id) const { +bool FakeUserManager::IsKioskApp(const std::string& user_id) const { return false; } bool FakeUserManager::IsPublicAccountMarkedForRemoval( - const AccountId& account_id) const { + const std::string& user_id) const { return false; } diff --git a/components/user_manager/fake_user_manager.h b/components/user_manager/fake_user_manager.h index 77f1649..a40eed6 100644 --- a/components/user_manager/fake_user_manager.h +++ b/components/user_manager/fake_user_manager.h @@ -9,7 +9,6 @@ #include <string> #include "base/memory/scoped_ptr.h" -#include "components/signin/core/account_id/account_id.h" #include "components/user_manager/user.h" #include "components/user_manager/user_manager_base.h" @@ -24,16 +23,15 @@ class USER_MANAGER_EXPORT FakeUserManager : public UserManagerBase { // Create and add a new user. Created user is not affiliated with the domain, // that owns the device. - virtual const user_manager::User* AddUser(const AccountId& account_id); + virtual const user_manager::User* AddUser(const std::string& email); // The same as AddUser() but allows to specify user affiliation with the // domain, that owns the device. virtual const user_manager::User* AddUserWithAffiliation( - const AccountId& account_id, - bool is_affiliated); + const std::string& email, bool is_affiliated); // Calculates the user name hash and calls UserLoggedIn to login a user. - void LoginUser(const AccountId& account_id); + void LoginUser(const std::string& email); // UserManager overrides. const user_manager::UserList& GetUsers() const override; @@ -41,43 +39,42 @@ class USER_MANAGER_EXPORT FakeUserManager : public UserManagerBase { const user_manager::UserList& GetLoggedInUsers() const override; // Set the user as logged in. - void UserLoggedIn(const AccountId& account_id, + void UserLoggedIn(const std::string& email, const std::string& username_hash, bool browser_restart) override; const user_manager::User* GetActiveUser() const override; user_manager::User* GetActiveUser() override; - void SwitchActiveUser(const AccountId& account_id) override; - void SaveUserDisplayName(const AccountId& account_id, + void SwitchActiveUser(const std::string& email) override; + void SaveUserDisplayName(const std::string& username, const base::string16& display_name) override; // Not implemented. - void UpdateUserAccountData(const AccountId& account_id, + void UpdateUserAccountData(const std::string& user_id, const UserAccountData& account_data) override {} void Shutdown() override {} const user_manager::UserList& GetLRULoggedInUsers() const override; user_manager::UserList GetUnlockUsers() const override; - const AccountId& GetOwnerAccountId() const override; + const std::string& GetOwnerEmail() const override; void SessionStarted() override {} - void RemoveUser(const AccountId& account_id, + void RemoveUser(const std::string& email, user_manager::RemoveUserDelegate* delegate) override {} - void RemoveUserFromList(const AccountId& account_id) override; - bool IsKnownUser(const AccountId& account_id) const override; - const user_manager::User* FindUser( - const AccountId& account_id) const override; - user_manager::User* FindUserAndModify(const AccountId& account_id) override; + void RemoveUserFromList(const std::string& email) override; + bool IsKnownUser(const std::string& email) const override; + const user_manager::User* FindUser(const std::string& email) const override; + user_manager::User* FindUserAndModify(const std::string& email) override; const user_manager::User* GetLoggedInUser() const override; user_manager::User* GetLoggedInUser() override; const user_manager::User* GetPrimaryUser() const override; void SaveUserOAuthStatus( - const AccountId& account_id, + const std::string& username, user_manager::User::OAuthTokenStatus oauth_token_status) override {} - void SaveForceOnlineSignin(const AccountId& account_id, + void SaveForceOnlineSignin(const std::string& user_id, bool force_online_signin) override {} - base::string16 GetUserDisplayName(const AccountId& account_id) const override; - void SaveUserDisplayEmail(const AccountId& account_id, + base::string16 GetUserDisplayName(const std::string& username) const override; + void SaveUserDisplayEmail(const std::string& username, const std::string& display_email) override {} - std::string GetUserDisplayEmail(const AccountId& account_id) const override; + std::string GetUserDisplayEmail(const std::string& username) const override; bool IsCurrentUserOwner() const override; bool IsCurrentUserNew() const override; bool IsCurrentUserNonCryptohomeDataEphemeral() const override; @@ -91,7 +88,7 @@ class USER_MANAGER_EXPORT FakeUserManager : public UserManagerBase { bool IsLoggedInAsStub() const override; bool IsSessionStarted() const override; bool IsUserNonCryptohomeDataEphemeral( - const AccountId& account_id) const override; + const std::string& email) const override; void AddObserver(Observer* obs) override {} void RemoveObserver(Observer* obs) override {} void AddSessionStateObserver(UserSessionStateObserver* obs) override {} @@ -104,36 +101,37 @@ class USER_MANAGER_EXPORT FakeUserManager : public UserManagerBase { const std::string& GetApplicationLocale() const override; PrefService* GetLocalState() const override; void HandleUserOAuthTokenStatusChange( - const AccountId& account_id, + const std::string& user_id, user_manager::User::OAuthTokenStatus status) const override {} bool IsEnterpriseManaged() const override; - void LoadPublicAccounts(std::set<AccountId>* public_sessions_set) override {} + void LoadPublicAccounts(std::set<std::string>* public_sessions_set) override { + } void PerformPreUserListLoadingActions() override {} void PerformPostUserListLoadingActions() override {} void PerformPostUserLoggedInActions(bool browser_restart) override {} - bool IsDemoApp(const AccountId& account_id) const override; - bool IsKioskApp(const AccountId& account_id) const override; + bool IsDemoApp(const std::string& user_id) const override; + bool IsKioskApp(const std::string& user_id) const override; bool IsPublicAccountMarkedForRemoval( - const AccountId& account_id) const override; + const std::string& user_id) const override; void DemoAccountLoggedIn() override {} - void KioskAppLoggedIn(const AccountId& kiosk_app_account_id) override {} + void KioskAppLoggedIn(const std::string& app_id) override {} void PublicAccountUserLoggedIn(user_manager::User* user) override {} - void SupervisedUserLoggedIn(const AccountId& account_id) override {} - void OnUserRemoved(const AccountId& account_id) override {} + void SupervisedUserLoggedIn(const std::string& user_id) override {} + void OnUserRemoved(const std::string& user_id) override {} protected: user_manager::User* primary_user_; // If set this is the active user. If empty, the first created user is the // active user. - AccountId active_account_id_ = EmptyAccountId(); + std::string active_user_id_; private: // We use this internal function for const-correctness. user_manager::User* GetActiveUserInternal() const; - // stub, always empty. - AccountId owner_account_id_ = EmptyAccountId(); + // stub, always empty string. + std::string owner_email_; DISALLOW_COPY_AND_ASSIGN(FakeUserManager); }; diff --git a/components/user_manager/user.cc b/components/user_manager/user.cc index 39ef430..defc117 100644 --- a/components/user_manager/user.cc +++ b/components/user_manager/user.cc @@ -9,7 +9,6 @@ #include "base/strings/utf_string_conversions.h" #include "base/threading/thread_restrictions.h" #include "chromeos/login/user_names.h" -#include "components/signin/core/account_id/account_id.h" #include "components/user_manager/user_image/default_user_images.h" #include "google_apis/gaia/gaia_auth_util.h" #include "ui/base/resource/resource_bundle.h" @@ -35,14 +34,10 @@ bool User::TypeHasGaiaAccount(UserType user_type) { user_type == USER_TYPE_CHILD; } -const std::string& User::email() const { - return account_id_.GetUserEmail(); -} - // Also used for regular supervised users. class RegularUser : public User { public: - explicit RegularUser(const AccountId& account_id); + explicit RegularUser(const std::string& email); ~RegularUser() override; // Overridden from User: @@ -51,7 +46,7 @@ class RegularUser : public User { void SetIsChild(bool is_child) override; private: - bool is_child_ = false; + bool is_child_; DISALLOW_COPY_AND_ASSIGN(RegularUser); }; @@ -70,7 +65,7 @@ class GuestUser : public User { class KioskAppUser : public User { public: - explicit KioskAppUser(const AccountId& kiosk_app_account_id); + explicit KioskAppUser(const std::string& app_id); ~KioskAppUser() override; // Overridden from User: @@ -82,7 +77,7 @@ class KioskAppUser : public User { class SupervisedUser : public User { public: - explicit SupervisedUser(const AccountId& account_id); + explicit SupervisedUser(const std::string& username); ~SupervisedUser() override; // Overridden from User: @@ -95,7 +90,7 @@ class SupervisedUser : public User { class PublicAccountUser : public User { public: - explicit PublicAccountUser(const AccountId& account_id); + explicit PublicAccountUser(const std::string& email); ~PublicAccountUser() override; // Overridden from User: @@ -123,9 +118,8 @@ const gfx::ImageSkia& User::GetImage() const { return user_image_.image(); } -AccountId User::GetAccountId() const { - return AccountId::FromUserEmail( - gaia::CanonicalizeEmail(gaia::SanitizeEmail(email()))); +UserID User::GetUserID() const { + return gaia::CanonicalizeEmail(gaia::SanitizeEmail(email())); } void User::SetIsChild(bool is_child) { @@ -150,7 +144,7 @@ std::string User::GetAccountName(bool use_display_email) const { if (use_display_email && !display_email_.empty()) return GetUserName(display_email_); else - return GetUserName(account_id_.GetUserEmail()); + return GetUserName(email_); } bool User::HasDefaultImage() const { @@ -181,27 +175,39 @@ bool User::is_active() const { return is_active_; } -User* User::CreateRegularUser(const AccountId& account_id) { - return new RegularUser(account_id); +User* User::CreateRegularUser(const std::string& email) { + return new RegularUser(email); } User* User::CreateGuestUser() { return new GuestUser; } -User* User::CreateKioskAppUser(const AccountId& kiosk_app_account_id) { - return new KioskAppUser(kiosk_app_account_id); +User* User::CreateKioskAppUser(const std::string& kiosk_app_username) { + return new KioskAppUser(kiosk_app_username); } -User* User::CreateSupervisedUser(const AccountId& account_id) { - return new SupervisedUser(account_id); +User* User::CreateSupervisedUser(const std::string& username) { + return new SupervisedUser(username); } -User* User::CreatePublicAccountUser(const AccountId& account_id) { - return new PublicAccountUser(account_id); +User* User::CreatePublicAccountUser(const std::string& email) { + return new PublicAccountUser(email); } -User::User(const AccountId& account_id) : account_id_(account_id) {} +User::User(const std::string& email) + : email_(email), + oauth_token_status_(OAUTH_TOKEN_STATUS_UNKNOWN), + force_online_signin_(false), + image_index_(USER_IMAGE_INVALID), + image_is_stub_(false), + image_is_loading_(false), + can_lock_(false), + is_logged_in_(false), + is_active_(false), + profile_is_created_(false), + is_affiliated_(false){ +} User::~User() { } @@ -231,9 +237,10 @@ void User::SetStubImage(const UserImage& stub_user_image, image_is_loading_ = is_loading; } -RegularUser::RegularUser(const AccountId& account_id) : User(account_id) { +RegularUser::RegularUser(const std::string& email) + : User(email), is_child_(false) { set_can_lock(true); - set_display_email(account_id.GetUserEmail()); + set_display_email(email); } RegularUser::~RegularUser() { @@ -253,7 +260,7 @@ void RegularUser::SetIsChild(bool is_child) { is_child_ = is_child; } -GuestUser::GuestUser() : User(chromeos::login::GuestAccountId()) { +GuestUser::GuestUser() : User(chromeos::login::kGuestUserName) { set_display_email(std::string()); } @@ -264,9 +271,9 @@ UserType GuestUser::GetType() const { return user_manager::USER_TYPE_GUEST; } -KioskAppUser::KioskAppUser(const AccountId& kiosk_app_account_id) - : User(kiosk_app_account_id) { - set_display_email(kiosk_app_account_id.GetUserEmail()); +KioskAppUser::KioskAppUser(const std::string& kiosk_app_username) + : User(kiosk_app_username) { + set_display_email(kiosk_app_username); } KioskAppUser::~KioskAppUser() { @@ -276,7 +283,7 @@ UserType KioskAppUser::GetType() const { return user_manager::USER_TYPE_KIOSK_APP; } -SupervisedUser::SupervisedUser(const AccountId& account_id) : User(account_id) { +SupervisedUser::SupervisedUser(const std::string& username) : User(username) { set_can_lock(true); } @@ -291,8 +298,8 @@ std::string SupervisedUser::display_email() const { return base::UTF16ToUTF8(display_name()); } -PublicAccountUser::PublicAccountUser(const AccountId& account_id) - : User(account_id) {} +PublicAccountUser::PublicAccountUser(const std::string& email) : User(email) { +} PublicAccountUser::~PublicAccountUser() { } diff --git a/components/user_manager/user.h b/components/user_manager/user.h index fe0899e..d961acf 100644 --- a/components/user_manager/user.h +++ b/components/user_manager/user.h @@ -10,7 +10,7 @@ #include "base/basictypes.h" #include "base/strings/string16.h" -#include "components/signin/core/account_id/account_id.h" +#include "components/user_manager/user_id.h" #include "components/user_manager/user_image/user_image.h" #include "components/user_manager/user_info.h" #include "components/user_manager/user_manager_export.h" @@ -83,8 +83,7 @@ class USER_MANAGER_EXPORT User : public UserInfo { virtual UserType GetType() const = 0; // The email the user used to log in. - // TODO(alemate): rename this to GetUserEmail() (see crbug.com/548923) - const std::string& email() const; + const std::string& email() const { return email_; } // The displayed user name. base::string16 display_name() const { return display_name_; } @@ -97,7 +96,7 @@ class USER_MANAGER_EXPORT User : public UserInfo { base::string16 GetDisplayName() const override; base::string16 GetGivenName() const override; const gfx::ImageSkia& GetImage() const override; - AccountId GetAccountId() const override; + UserID GetUserID() const override; // Allows managing child status of the user. Used for RegularUser. virtual void SetIsChild(bool is_child); @@ -183,13 +182,13 @@ class USER_MANAGER_EXPORT User : public UserInfo { friend class chromeos::UserAddingScreenTest; // Do not allow anyone else to create new User instances. - static User* CreateRegularUser(const AccountId& account_id); + static User* CreateRegularUser(const UserID& email); static User* CreateGuestUser(); - static User* CreateKioskAppUser(const AccountId& kiosk_app_account_id); - static User* CreateSupervisedUser(const AccountId& account_id); - static User* CreatePublicAccountUser(const AccountId& account_id); + static User* CreateKioskAppUser(const UserID& kiosk_app_username); + static User* CreateSupervisedUser(const UserID& username); + static User* CreatePublicAccountUser(const UserID& email); - explicit User(const AccountId& account_id); + explicit User(const std::string& email); ~User() override; const std::string* GetAccountLocale() const { return account_locale_.get(); } @@ -252,15 +251,15 @@ class USER_MANAGER_EXPORT User : public UserInfo { } private: - AccountId account_id_; + std::string email_; base::string16 display_name_; base::string16 given_name_; // The displayed user email, defaults to |email_|. std::string display_email_; - bool using_saml_ = false; + bool using_saml_; UserImage user_image_; - OAuthTokenStatus oauth_token_status_ = OAUTH_TOKEN_STATUS_UNKNOWN; - bool force_online_signin_ = false; + OAuthTokenStatus oauth_token_status_; + bool force_online_signin_; // This is set to chromeos locale if account data has been downloaded. // (Or failed to download, but at least one download attempt finished). @@ -273,34 +272,34 @@ class USER_MANAGER_EXPORT User : public UserInfo { // Either index of a default image for the user, |USER_IMAGE_EXTERNAL| or // |USER_IMAGE_PROFILE|. - int image_index_ = USER_IMAGE_INVALID; + int image_index_; // True if current user image is a stub set by a |SetStubImage| call. - bool image_is_stub_ = false; + bool image_is_stub_; // True if current user image is being loaded from file. - bool image_is_loading_ = false; + bool image_is_loading_; // True if user is able to lock screen. - bool can_lock_ = false; + bool can_lock_; // True if user is currently logged in in current session. - bool is_logged_in_ = false; + bool is_logged_in_; // True if user is currently logged in and active in current session. - bool is_active_ = false; + bool is_active_; // True if user Profile is created - bool profile_is_created_ = false; + bool profile_is_created_; // True if the user is affiliated to the device. - bool is_affiliated_ = false; + bool is_affiliated_; DISALLOW_COPY_AND_ASSIGN(User); }; // List of known users. -using UserList = std::vector<User*>; +typedef std::vector<User*> UserList; } // namespace user_manager diff --git a/components/user_manager/user_id.h b/components/user_manager/user_id.h new file mode 100644 index 0000000..bf8730a --- /dev/null +++ b/components/user_manager/user_id.h @@ -0,0 +1,17 @@ +// Copyright 2015 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef COMPONENTS_USER_MANAGER_USER_ID_H_ +#define COMPONENTS_USER_MANAGER_USER_ID_H_ + +#include <string> + +namespace user_manager { + +// Type that contains enough information to identify user on ChromeOS. +typedef std::string UserID; + +} // namespace user_manager + +#endif // COMPONENTS_USER_MANAGER_USER_ID_H_ diff --git a/components/user_manager/user_info.h b/components/user_manager/user_info.h index 2f0cf19..cc613c1 100644 --- a/components/user_manager/user_info.h +++ b/components/user_manager/user_info.h @@ -8,10 +8,9 @@ #include <string> #include "base/strings/string16.h" +#include "components/user_manager/user_id.h" #include "components/user_manager/user_manager_export.h" -class AccountId; - namespace gfx { class ImageSkia; } @@ -35,8 +34,9 @@ class USER_MANAGER_EXPORT UserInfo { // as well as capitalized letters. For example: "Foo.Bar@mock.com". virtual std::string GetEmail() const = 0; - // Returns AccountId for the user. - virtual AccountId GetAccountId() const = 0; + // Gets the user id (sanitized email address) for the user. + // The function would return something like "foobar@mock.com". + virtual UserID GetUserID() const = 0; // Gets the avatar image for the user. virtual const gfx::ImageSkia& GetImage() const = 0; diff --git a/components/user_manager/user_info_impl.cc b/components/user_manager/user_info_impl.cc index cf6d2ad..6aa21a8 100644 --- a/components/user_manager/user_info_impl.cc +++ b/components/user_manager/user_info_impl.cc @@ -6,7 +6,6 @@ #include "base/logging.h" #include "base/strings/utf_string_conversions.h" -#include "components/signin/core/account_id/account_id.h" namespace user_manager { @@ -28,8 +27,8 @@ std::string UserInfoImpl::GetEmail() const { return "stub-user@domain.com"; } -AccountId UserInfoImpl::GetAccountId() const { - return AccountId::FromUserEmail(GetEmail()); +std::string UserInfoImpl::GetUserID() const { + return GetEmail(); } const gfx::ImageSkia& UserInfoImpl::GetImage() const { diff --git a/components/user_manager/user_info_impl.h b/components/user_manager/user_info_impl.h index 4922e36..d23ca0c 100644 --- a/components/user_manager/user_info_impl.h +++ b/components/user_manager/user_info_impl.h @@ -24,7 +24,7 @@ class USER_MANAGER_EXPORT UserInfoImpl : public UserInfo { base::string16 GetDisplayName() const override; base::string16 GetGivenName() const override; std::string GetEmail() const override; - AccountId GetAccountId() const override; + std::string GetUserID() const override; const gfx::ImageSkia& GetImage() const override; private: diff --git a/components/user_manager/user_manager.h b/components/user_manager/user_manager.h index 03a08d7..24b8c9a 100644 --- a/components/user_manager/user_manager.h +++ b/components/user_manager/user_manager.h @@ -8,11 +8,10 @@ #include <string> #include "components/user_manager/user.h" +#include "components/user_manager/user_id.h" #include "components/user_manager/user_manager_export.h" #include "components/user_manager/user_type.h" -class AccountId; - namespace base { class DictionaryValue; } @@ -55,7 +54,7 @@ class USER_MANAGER_EXPORT UserManager { virtual void UserAddedToSession(const User* added_user); // Called right before notifying on user change so that those who rely - // on account_id hash would be accessing up-to-date value. + // on user_id hash would be accessing up-to-date value. virtual void ActiveUserHashChanged(const std::string& hash); // Called when child status has changed. @@ -139,22 +138,21 @@ class USER_MANAGER_EXPORT UserManager { // All users that are unable to perform unlock are excluded from this list. virtual UserList GetUnlockUsers() const = 0; - // Returns account Id of the owner user. Returns an empty Id if there is + // Returns the email of the owner user. Returns an empty string if there is // no owner for the device. - virtual const AccountId& GetOwnerAccountId() const = 0; + virtual const std::string& GetOwnerEmail() const = 0; - // Indicates that a user with the given |account_id| has just logged in. The + // Indicates that a user with the given |user_id| has just logged in. The // persistent list is updated accordingly if the user is not ephemeral. // |browser_restart| is true when reloading Chrome after crash to distinguish // from normal sign in flow. // |username_hash| is used to identify homedir mount point. - virtual void UserLoggedIn(const AccountId& account_id, + virtual void UserLoggedIn(const std::string& user_id, const std::string& username_hash, bool browser_restart) = 0; - // Switches to active user identified by |account_id|. User has to be logged - // in. - virtual void SwitchActiveUser(const AccountId& account_id) = 0; + // Switches to active user identified by |user_id|. User has to be logged in. + virtual void SwitchActiveUser(const std::string& user_id) = 0; // Switches to the last active user (called after crash happens and session // restore has completed). @@ -172,25 +170,25 @@ class USER_MANAGER_EXPORT UserManager { // Removes the user from the device. Note, it will verify that the given user // isn't the owner, so calling this method for the owner will take no effect. // Note, |delegate| can be NULL. - virtual void RemoveUser(const AccountId& account_id, + virtual void RemoveUser(const std::string& user_id, RemoveUserDelegate* delegate) = 0; // Removes the user from the persistent list only. Also removes the user's // picture. - virtual void RemoveUserFromList(const AccountId& account_id) = 0; + virtual void RemoveUserFromList(const std::string& user_id) = 0; - // Returns true if a user with the given account id is found in the persistent + // Returns true if a user with the given user id is found in the persistent // list or currently logged in as ephemeral. - virtual bool IsKnownUser(const AccountId& account_id) const = 0; + virtual bool IsKnownUser(const std::string& user_id) const = 0; - // Returns the user with the given account id if found in the persistent + // Returns the user with the given user id if found in the persistent // list or currently logged in as ephemeral. Returns |NULL| otherwise. - virtual const User* FindUser(const AccountId& account_id) const = 0; + virtual const User* FindUser(const std::string& user_id) const = 0; - // Returns the user with the given account id if found in the persistent + // Returns the user with the given user id if found in the persistent // list or currently logged in as ephemeral. Returns |NULL| otherwise. // Same as FindUser but returns non-const pointer to User object. - virtual User* FindUserAndModify(const AccountId& account_id) = 0; + virtual User* FindUserAndModify(const std::string& user_id) = 0; // Returns the logged-in user. // TODO(nkostylev): Deprecate this call, move clients to GetActiveUser(). @@ -210,43 +208,42 @@ class USER_MANAGER_EXPORT UserManager { // Saves user's oauth token status in local state preferences. virtual void SaveUserOAuthStatus( - const AccountId& account_id, + const std::string& user_id, User::OAuthTokenStatus oauth_token_status) = 0; // Saves a flag indicating whether online authentication against GAIA should // be enforced during the user's next sign-in. - virtual void SaveForceOnlineSignin(const AccountId& account_id, + virtual void SaveForceOnlineSignin(const std::string& user_id, bool force_online_signin) = 0; // Saves user's displayed name in local state preferences. // Ignored If there is no such user. - virtual void SaveUserDisplayName(const AccountId& account_id, + virtual void SaveUserDisplayName(const std::string& user_id, const base::string16& display_name) = 0; // Updates data upon User Account download. - virtual void UpdateUserAccountData(const AccountId& account_id, + virtual void UpdateUserAccountData(const std::string& user_id, const UserAccountData& account_data) = 0; - // Returns the display name for user |account_id| if it is known (was + // Returns the display name for user |user_id| if it is known (was // previously set by a |SaveUserDisplayName| call). // Otherwise, returns an empty string. virtual base::string16 GetUserDisplayName( - const AccountId& account_id) const = 0; + const std::string& user_id) const = 0; // Saves user's displayed (non-canonical) email in local state preferences. // Ignored If there is no such user. - virtual void SaveUserDisplayEmail(const AccountId& account_id, + virtual void SaveUserDisplayEmail(const std::string& user_id, const std::string& display_email) = 0; - // Returns the display email for user |account_id| if it is known (was + // Returns the display email for user |user_id| if it is known (was // previously set by a |SaveUserDisplayEmail| call). - // Otherwise, returns |account_id| itself. - virtual std::string GetUserDisplayEmail( - const AccountId& account_id) const = 0; + // Otherwise, returns |user_id| itself. + virtual std::string GetUserDisplayEmail(const std::string& user_id) const = 0; - // Saves user's type for user |account_id| into local state preferences. + // Saves user's type for user |user_id| into local state preferences. // Ignored If there is no such user. - virtual void SaveUserType(const AccountId& account_id, + virtual void SaveUserType(const std::string& user_id, const UserType& user_type) = 0; // Returns true if current user is an owner. @@ -293,12 +290,11 @@ class USER_MANAGER_EXPORT UserManager { // or restart after crash. virtual bool IsSessionStarted() const = 0; - // Returns true if data stored or cached for the user with the given - // |account_id| + // Returns true if data stored or cached for the user with the given user id // address outside that user's cryptohome (wallpaper, avatar, OAuth token // status, display name, display email) is to be treated as ephemeral. virtual bool IsUserNonCryptohomeDataEphemeral( - const AccountId& account_id) const = 0; + const std::string& user_id) const = 0; virtual void AddObserver(Observer* obs) = 0; virtual void RemoveObserver(Observer* obs) = 0; @@ -317,101 +313,95 @@ class USER_MANAGER_EXPORT UserManager { // Methods for storage/retrieval of per-user properties in Local State. - // Performs a lookup of properties associated with |account_id|. If found, + // Performs a lookup of properties associated with |user_id|. If found, // returns |true| and fills |out_value|. |out_value| can be NULL, if // only existence check is required. - virtual bool FindKnownUserPrefs(const AccountId& account_id, + virtual bool FindKnownUserPrefs(const UserID& user_id, const base::DictionaryValue** out_value) = 0; - // Updates (or creates) properties associated with |account_id| based + // Updates (or creates) properties associated with |user_id| based // on |values|. |clear| defines if existing properties are cleared (|true|) // or if it is just a incremental update (|false|). - virtual void UpdateKnownUserPrefs(const AccountId& account_id, + virtual void UpdateKnownUserPrefs(const UserID& user_id, const base::DictionaryValue& values, bool clear) = 0; - // Returns true if |account_id| preference by |path| does exist, + // Returns true if |user_id| preference by |path| does exist, // fills in |out_value|. Otherwise returns false. - virtual bool GetKnownUserStringPref(const AccountId& account_id, + virtual bool GetKnownUserStringPref(const UserID& user_id, const std::string& path, std::string* out_value) = 0; - // Updates user's identified by |account_id| string preference |path|. - virtual void SetKnownUserStringPref(const AccountId& account_id, + // Updates user's identified by |user_id| string preference |path|. + virtual void SetKnownUserStringPref(const UserID& user_id, const std::string& path, const std::string& in_value) = 0; - // Returns true if |account_id| preference by |path| does exist, + // Returns true if |user_id| preference by |path| does exist, // fills in |out_value|. Otherwise returns false. - virtual bool GetKnownUserBooleanPref(const AccountId& account_id, + virtual bool GetKnownUserBooleanPref(const UserID& user_id, const std::string& path, bool* out_value) = 0; - // Updates user's identified by |account_id| boolean preference |path|. - virtual void SetKnownUserBooleanPref(const AccountId& account_id, + // Updates user's identified by |user_id| boolean preference |path|. + virtual void SetKnownUserBooleanPref(const UserID& user_id, const std::string& path, const bool in_value) = 0; - // Returns true if |account_id| preference by |path| does exist, + // Returns true if |user_id| preference by |path| does exist, // fills in |out_value|. Otherwise returns false. - virtual bool GetKnownUserIntegerPref(const AccountId& account_id, + virtual bool GetKnownUserIntegerPref(const UserID& user_id, const std::string& path, int* out_value) = 0; - // Updates user's identified by |account_id| integer preference |path|. - virtual void SetKnownUserIntegerPref(const AccountId& account_id, + // Updates user's identified by |user_id| integer preference |path|. + virtual void SetKnownUserIntegerPref(const UserID& user_id, const std::string& path, const int in_value) = 0; - // Returns true if user's AccountId was found. - // Returns it in |out_account_id|. - virtual bool GetKnownUserAccountId(const AccountId& authenticated_account_id, - AccountId* out_account_id) = 0; + // Returns true if user's canonical email was found. + // Returns it in |out_email|. + virtual bool GetKnownUserCanonicalEmail(const UserID& user_id, + std::string* out_email) = 0; - // Updates |gaia_id| for user with |account_id|. - // TODO(alemate): Update this once AccountId contains GAIA ID - // (crbug.com/548926). - virtual void UpdateGaiaID(const AccountId& account_id, + // Updates |gaia_id| for user with |user_id|. + // TODO(antrim): Update this once UserID contains GAIA ID. + virtual void UpdateGaiaID(const UserID& user_id, const std::string& gaia_id) = 0; - // Find GAIA ID for user with |account_id|, fill in |out_value| and return - // true + // Find GAIA ID for user with |user_id|, fill in |out_value| and return true // if GAIA ID was found or false otherwise. - // TODO(antrim): Update this once AccountId contains GAIA ID - // (crbug.com/548926). - virtual bool FindGaiaID(const AccountId& account_id, - std::string* out_value) = 0; + // TODO(antrim): Update this once UserID contains GAIA ID. + virtual bool FindGaiaID(const UserID& user_id, std::string* out_value) = 0; // Saves whether the user authenticates using SAML. - virtual void UpdateUsingSAML(const AccountId& account_id, + virtual void UpdateUsingSAML(const UserID& user_id, const bool using_saml) = 0; // Returns if SAML needs to be used for authentication of the user with - // |account_id|, if it is known (was set by a |UpdateUsingSaml| call). - // Otherwise + // |user_id|, if it is known (was set by a |UpdateUsingSaml| call). Otherwise // returns false. - virtual bool FindUsingSAML(const AccountId& account_id) = 0; + virtual bool FindUsingSAML(const UserID& user_id) = 0; // Setter and getter for DeviceId known user string preference. - virtual void SetKnownUserDeviceId(const AccountId& account_id, + virtual void SetKnownUserDeviceId(const UserID& user_id, const std::string& device_id) = 0; - virtual std::string GetKnownUserDeviceId(const AccountId& account_id) = 0; + virtual std::string GetKnownUserDeviceId(const UserID& user_id) = 0; // Setter and getter for GAPSCookie known user string preference. - virtual void SetKnownUserGAPSCookie(const AccountId& account_id, + virtual void SetKnownUserGAPSCookie(const UserID& user_id, const std::string& gaps_cookie) = 0; - virtual std::string GetKnownUserGAPSCookie(const AccountId& account_id) = 0; + virtual std::string GetKnownUserGAPSCookie(const UserID& user_id) = 0; // Saves why the user has to go through re-auth flow. - virtual void UpdateReauthReason(const AccountId& account_id, + virtual void UpdateReauthReason(const UserID& user_id, const int reauth_reason) = 0; - // Returns the reason why the user with |account_id| has to go through the + // Returns the reason why the user with |user_id| has to go through the // re-auth flow. Returns true if such a reason was recorded or false // otherwise. - virtual bool FindReauthReason(const AccountId& account_id, - int* out_value) = 0; + virtual bool FindReauthReason(const UserID& user_id, int* out_value) = 0; protected: // Sets UserManager instance. diff --git a/components/user_manager/user_manager_base.cc b/components/user_manager/user_manager_base.cc index 81a68ff..3bcb61c 100644 --- a/components/user_manager/user_manager_base.cc +++ b/components/user_manager/user_manager_base.cc @@ -115,26 +115,25 @@ void ResolveLocale(const std::string& raw_locale, ignore_result(l10n_util::CheckAndResolveLocale(raw_locale, resolved_locale)); } -// Checks if values in |dict| correspond with |account_id| identity. -bool UserMatches(const AccountId& account_id, - const base::DictionaryValue& dict) { +// Checks if values in |dict| correspond with |user_id| identity. +bool UserMatches(const UserID& user_id, const base::DictionaryValue& dict) { std::string value; bool has_email = dict.GetString(kCanonicalEmail, &value); - if (has_email && account_id.GetUserEmail() == value) + if (has_email && user_id == value) return true; // TODO(antrim): update code once user id is really a struct. bool has_gaia_id = dict.GetString(kGAIAIdKey, &value); - if (has_gaia_id && account_id.GetUserEmail() == value) + if (has_gaia_id && user_id == value) return true; return false; } -// Fills relevant |dict| values based on |account_id|. -void UpdateIdentity(const AccountId& account_id, base::DictionaryValue& dict) { - dict.SetString(kCanonicalEmail, account_id.GetUserEmail()); +// Fills relevant |dict| values based on |user_id|. +void UpdateIdentity(const UserID& user_id, base::DictionaryValue& dict) { + dict.SetString(kCanonicalEmail, user_id); } } // namespace @@ -156,7 +155,17 @@ void UserManagerBase::RegisterPrefs(PrefRegistrySimple* registry) { UserManagerBase::UserManagerBase( scoped_refptr<base::TaskRunner> task_runner, scoped_refptr<base::TaskRunner> blocking_task_runner) - : task_runner_(task_runner), + : active_user_(NULL), + primary_user_(NULL), + user_loading_stage_(STAGE_NOT_LOADED), + session_started_(false), + is_current_user_owner_(false), + is_current_user_new_(false), + is_current_user_ephemeral_regular_user_(false), + ephemeral_users_enabled_(false), + manager_creation_time_(base::TimeTicks::Now()), + last_session_active_user_initialized_(false), + task_runner_(task_runner), blocking_task_runner_(blocking_task_runner), weak_factory_(this) { UpdateLoginState(); @@ -192,22 +201,21 @@ const UserList& UserManagerBase::GetLRULoggedInUsers() const { return lru_logged_in_users_; } -const AccountId& UserManagerBase::GetOwnerAccountId() const { - return owner_account_id_; +const std::string& UserManagerBase::GetOwnerEmail() const { + return owner_email_; } -void UserManagerBase::UserLoggedIn(const AccountId& account_id, +void UserManagerBase::UserLoggedIn(const std::string& user_id, const std::string& username_hash, bool browser_restart) { DCHECK(task_runner_->RunsTasksOnCurrentThread()); - if (!last_session_active_account_id_initialized_) { - last_session_active_account_id_ = - AccountId::FromUserEmail(GetLocalState()->GetString(kLastActiveUser)); - last_session_active_account_id_initialized_ = true; + if (!last_session_active_user_initialized_) { + last_session_active_user_ = GetLocalState()->GetString(kLastActiveUser); + last_session_active_user_initialized_ = true; } - User* user = FindUserInListAndModify(account_id); + User* user = FindUserInListAndModify(user_id); if (active_user_ && user) { user->set_is_logged_in(true); user->set_username_hash(username_hash); @@ -221,11 +229,11 @@ void UserManagerBase::UserLoggedIn(const AccountId& account_id, return; } - if (account_id == chromeos::login::GuestAccountId()) { + if (user_id == chromeos::login::kGuestUserName) { GuestUserLoggedIn(); - } else if (IsKioskApp(account_id)) { - KioskAppLoggedIn(account_id); - } else if (IsDemoApp(account_id)) { + } else if (IsKioskApp(user_id)) { + KioskAppLoggedIn(user_id); + } else if (IsDemoApp(user_id)) { DemoAccountLoggedIn(); } else { EnsureUsersLoaded(); @@ -234,16 +242,16 @@ void UserManagerBase::UserLoggedIn(const AccountId& account_id, PublicAccountUserLoggedIn(user); } else if ((user && user->GetType() == USER_TYPE_SUPERVISED) || (!user && - gaia::ExtractDomainName(account_id.GetUserEmail()) == + gaia::ExtractDomainName(user_id) == chromeos::login::kSupervisedUserDomain)) { - SupervisedUserLoggedIn(account_id); - } else if (browser_restart && IsPublicAccountMarkedForRemoval(account_id)) { - PublicAccountUserLoggedIn(User::CreatePublicAccountUser(account_id)); - } else if (account_id != GetOwnerAccountId() && !user && + SupervisedUserLoggedIn(user_id); + } else if (browser_restart && IsPublicAccountMarkedForRemoval(user_id)) { + PublicAccountUserLoggedIn(User::CreatePublicAccountUser(user_id)); + } else if (user_id != GetOwnerEmail() && !user && (AreEphemeralUsersEnabled() || browser_restart)) { - RegularUserLoggedInAsEphemeral(account_id); + RegularUserLoggedInAsEphemeral(user_id); } else { - RegularUserLoggedIn(account_id); + RegularUserLoggedIn(user_id); } } @@ -259,22 +267,21 @@ void UserManagerBase::UserLoggedIn(const AccountId& account_id, if (!primary_user_) { primary_user_ = active_user_; if (primary_user_->HasGaiaAccount()) - SendGaiaUserLoginMetrics(account_id); + SendGaiaUserLoginMetrics(user_id); } UMA_HISTOGRAM_ENUMERATION( "UserManager.LoginUserType", active_user_->GetType(), NUM_USER_TYPES); GetLocalState()->SetString( - kLastLoggedInGaiaUser, - active_user_->HasGaiaAccount() ? account_id.GetUserEmail() : ""); + kLastLoggedInGaiaUser, active_user_->HasGaiaAccount() ? user_id : ""); NotifyOnLogin(); PerformPostUserLoggedInActions(browser_restart); } -void UserManagerBase::SwitchActiveUser(const AccountId& account_id) { - User* user = FindUserAndModify(account_id); +void UserManagerBase::SwitchActiveUser(const std::string& user_id) { + User* user = FindUserAndModify(user_id); if (!user) { NOTREACHED() << "Switching to a non-existing user"; return; @@ -310,15 +317,14 @@ void UserManagerBase::SwitchActiveUser(const AccountId& account_id) { } void UserManagerBase::SwitchToLastActiveUser() { - if (!last_session_active_account_id_.is_valid()) + if (last_session_active_user_.empty()) return; - if (AccountId::FromUserEmail(GetActiveUser()->email()) != - last_session_active_account_id_) - SwitchActiveUser(last_session_active_account_id_); + if (GetActiveUser()->email() != last_session_active_user_) + SwitchActiveUser(last_session_active_user_); // Make sure that this function gets run only once. - last_session_active_account_id_.clear(); + last_session_active_user_.clear(); } void UserManagerBase::SessionStarted() { @@ -335,48 +341,47 @@ void UserManagerBase::SessionStarted() { } } -void UserManagerBase::RemoveUser(const AccountId& account_id, +void UserManagerBase::RemoveUser(const std::string& user_id, RemoveUserDelegate* delegate) { DCHECK(task_runner_->RunsTasksOnCurrentThread()); - if (!CanUserBeRemoved(FindUser(account_id))) + if (!CanUserBeRemoved(FindUser(user_id))) return; - RemoveUserInternal(account_id, delegate); + RemoveUserInternal(user_id, delegate); } -void UserManagerBase::RemoveUserInternal(const AccountId& account_id, +void UserManagerBase::RemoveUserInternal(const std::string& user_email, RemoveUserDelegate* delegate) { - RemoveNonOwnerUserInternal(account_id, delegate); + RemoveNonOwnerUserInternal(user_email, delegate); } -void UserManagerBase::RemoveNonOwnerUserInternal(const AccountId& account_id, +void UserManagerBase::RemoveNonOwnerUserInternal(const std::string& user_email, RemoveUserDelegate* delegate) { if (delegate) - delegate->OnBeforeUserRemoved(account_id.GetUserEmail()); - RemoveUserFromList(account_id); + delegate->OnBeforeUserRemoved(user_email); + RemoveUserFromList(user_email); cryptohome::AsyncMethodCaller::GetInstance()->AsyncRemove( - account_id.GetUserEmail(), - base::Bind(&OnRemoveUserComplete, account_id.GetUserEmail())); + user_email, base::Bind(&OnRemoveUserComplete, user_email)); if (delegate) - delegate->OnUserRemoved(account_id.GetUserEmail()); + delegate->OnUserRemoved(user_email); } -void UserManagerBase::RemoveUserFromList(const AccountId& account_id) { +void UserManagerBase::RemoveUserFromList(const std::string& user_id) { DCHECK(task_runner_->RunsTasksOnCurrentThread()); - RemoveNonCryptohomeData(account_id); + RemoveNonCryptohomeData(user_id); if (user_loading_stage_ == STAGE_LOADED) { - DeleteUser(RemoveRegularOrSupervisedUserFromList(account_id)); + DeleteUser(RemoveRegularOrSupervisedUserFromList(user_id)); } else if (user_loading_stage_ == STAGE_LOADING) { - DCHECK(gaia::ExtractDomainName(account_id.GetUserEmail()) == + DCHECK(gaia::ExtractDomainName(user_id) == chromeos::login::kSupervisedUserDomain || - HasPendingBootstrap(account_id)); + HasPendingBootstrap(user_id)); // Special case, removing partially-constructed supervised user or // boostrapping user during user list loading. ListPrefUpdate users_update(GetLocalState(), kRegularUsers); - users_update->Remove(base::StringValue(account_id.GetUserEmail()), nullptr); - OnUserRemoved(account_id); + users_update->Remove(base::StringValue(user_id), NULL); + OnUserRemoved(user_id); } else { NOTREACHED() << "Users are not loaded yet."; return; @@ -386,22 +391,22 @@ void UserManagerBase::RemoveUserFromList(const AccountId& account_id) { GetLocalState()->CommitPendingWrite(); } -bool UserManagerBase::IsKnownUser(const AccountId& account_id) const { - return FindUser(account_id) != nullptr; +bool UserManagerBase::IsKnownUser(const std::string& user_id) const { + return FindUser(user_id) != NULL; } -const User* UserManagerBase::FindUser(const AccountId& account_id) const { +const User* UserManagerBase::FindUser(const std::string& user_id) const { DCHECK(task_runner_->RunsTasksOnCurrentThread()); - if (active_user_ && active_user_->GetAccountId() == account_id) + if (active_user_ && active_user_->email() == user_id) return active_user_; - return FindUserInList(account_id); + return FindUserInList(user_id); } -User* UserManagerBase::FindUserAndModify(const AccountId& account_id) { +User* UserManagerBase::FindUserAndModify(const std::string& user_id) { DCHECK(task_runner_->RunsTasksOnCurrentThread()); - if (active_user_ && active_user_->GetAccountId() == account_id) + if (active_user_ && active_user_->email() == user_id) return active_user_; - return FindUserInListAndModify(account_id); + return FindUserInListAndModify(user_id); } const User* UserManagerBase::GetLoggedInUser() const { @@ -430,73 +435,73 @@ const User* UserManagerBase::GetPrimaryUser() const { } void UserManagerBase::SaveUserOAuthStatus( - const AccountId& account_id, + const std::string& user_id, User::OAuthTokenStatus oauth_token_status) { DCHECK(task_runner_->RunsTasksOnCurrentThread()); DVLOG(1) << "Saving user OAuth token status in Local State"; - User* user = FindUserAndModify(account_id); + User* user = FindUserAndModify(user_id); if (user) user->set_oauth_token_status(oauth_token_status); // Do not update local state if data stored or cached outside the user's // cryptohome is to be treated as ephemeral. - if (IsUserNonCryptohomeDataEphemeral(account_id)) + if (IsUserNonCryptohomeDataEphemeral(user_id)) return; DictionaryPrefUpdate oauth_status_update(GetLocalState(), kUserOAuthTokenStatus); oauth_status_update->SetWithoutPathExpansion( - account_id.GetUserEmail(), + user_id, new base::FundamentalValue(static_cast<int>(oauth_token_status))); } -void UserManagerBase::SaveForceOnlineSignin(const AccountId& account_id, +void UserManagerBase::SaveForceOnlineSignin(const std::string& user_id, bool force_online_signin) { DCHECK(task_runner_->RunsTasksOnCurrentThread()); // Do not update local state if data stored or cached outside the user's // cryptohome is to be treated as ephemeral. - if (IsUserNonCryptohomeDataEphemeral(account_id)) + if (IsUserNonCryptohomeDataEphemeral(user_id)) return; DictionaryPrefUpdate force_online_update(GetLocalState(), kUserForceOnlineSignin); - force_online_update->SetBooleanWithoutPathExpansion(account_id.GetUserEmail(), + force_online_update->SetBooleanWithoutPathExpansion(user_id, force_online_signin); } -void UserManagerBase::SaveUserDisplayName(const AccountId& account_id, +void UserManagerBase::SaveUserDisplayName(const std::string& user_id, const base::string16& display_name) { DCHECK(task_runner_->RunsTasksOnCurrentThread()); - if (User* user = FindUserAndModify(account_id)) { + if (User* user = FindUserAndModify(user_id)) { user->set_display_name(display_name); // Do not update local state if data stored or cached outside the user's // cryptohome is to be treated as ephemeral. - if (!IsUserNonCryptohomeDataEphemeral(account_id)) { + if (!IsUserNonCryptohomeDataEphemeral(user_id)) { DictionaryPrefUpdate display_name_update(GetLocalState(), kUserDisplayName); display_name_update->SetWithoutPathExpansion( - account_id.GetUserEmail(), new base::StringValue(display_name)); + user_id, new base::StringValue(display_name)); } } } base::string16 UserManagerBase::GetUserDisplayName( - const AccountId& account_id) const { - const User* user = FindUser(account_id); + const std::string& user_id) const { + const User* user = FindUser(user_id); return user ? user->display_name() : base::string16(); } -void UserManagerBase::SaveUserDisplayEmail(const AccountId& account_id, +void UserManagerBase::SaveUserDisplayEmail(const std::string& user_id, const std::string& display_email) { DCHECK(task_runner_->RunsTasksOnCurrentThread()); - User* user = FindUserAndModify(account_id); + User* user = FindUserAndModify(user_id); if (!user) { - LOG(ERROR) << "User not found: " << account_id.GetUserEmail(); + LOG(ERROR) << "User not found: " << user_id; return; // Ignore if there is no such user. } @@ -504,89 +509,88 @@ void UserManagerBase::SaveUserDisplayEmail(const AccountId& account_id, // Do not update local state if data stored or cached outside the user's // cryptohome is to be treated as ephemeral. - if (IsUserNonCryptohomeDataEphemeral(account_id)) + if (IsUserNonCryptohomeDataEphemeral(user_id)) return; DictionaryPrefUpdate display_email_update(GetLocalState(), kUserDisplayEmail); display_email_update->SetWithoutPathExpansion( - account_id.GetUserEmail(), new base::StringValue(display_email)); + user_id, new base::StringValue(display_email)); } std::string UserManagerBase::GetUserDisplayEmail( - const AccountId& account_id) const { - const User* user = FindUser(account_id); - return user ? user->display_email() : account_id.GetUserEmail(); + const std::string& user_id) const { + const User* user = FindUser(user_id); + return user ? user->display_email() : user_id; } -void UserManagerBase::SaveUserType(const AccountId& account_id, +void UserManagerBase::SaveUserType(const std::string& user_id, const UserType& user_type) { DCHECK(task_runner_->RunsTasksOnCurrentThread()); - User* user = FindUserAndModify(account_id); + User* user = FindUserAndModify(user_id); if (!user) { - LOG(ERROR) << "User not found: " << account_id.GetUserEmail(); + LOG(ERROR) << "User not found: " << user_id; return; // Ignore if there is no such user. } // Do not update local state if data stored or cached outside the user's // cryptohome is to be treated as ephemeral. - if (IsUserNonCryptohomeDataEphemeral(account_id)) + if (IsUserNonCryptohomeDataEphemeral(user_id)) return; DictionaryPrefUpdate user_type_update(GetLocalState(), kUserType); user_type_update->SetWithoutPathExpansion( - account_id.GetUserEmail(), - new base::FundamentalValue(static_cast<int>(user_type))); + user_id, new base::FundamentalValue(static_cast<int>(user_type))); GetLocalState()->CommitPendingWrite(); } -void UserManagerBase::UpdateUsingSAML(const AccountId& account_id, +void UserManagerBase::UpdateUsingSAML(const std::string& user_id, const bool using_saml) { - SetKnownUserBooleanPref(account_id, kUsingSAMLKey, using_saml); + SetKnownUserBooleanPref(user_id, kUsingSAMLKey, using_saml); } -bool UserManagerBase::FindUsingSAML(const AccountId& account_id) { +bool UserManagerBase::FindUsingSAML(const std::string& user_id) { bool using_saml; - if (GetKnownUserBooleanPref(account_id, kUsingSAMLKey, &using_saml)) + if (GetKnownUserBooleanPref(user_id, kUsingSAMLKey, &using_saml)) return using_saml; return false; } -void UserManagerBase::UpdateReauthReason(const AccountId& account_id, +void UserManagerBase::UpdateReauthReason(const std::string& user_id, const int reauth_reason) { - SetKnownUserIntegerPref(account_id, kReauthReasonKey, reauth_reason); + SetKnownUserIntegerPref(user_id, kReauthReasonKey, reauth_reason); } -bool UserManagerBase::FindReauthReason(const AccountId& account_id, +bool UserManagerBase::FindReauthReason(const std::string& user_id, int* out_value) { - return GetKnownUserIntegerPref(account_id, kReauthReasonKey, out_value); + return GetKnownUserIntegerPref(user_id, kReauthReasonKey, out_value); } void UserManagerBase::UpdateUserAccountData( - const AccountId& account_id, + const std::string& user_id, const UserAccountData& account_data) { DCHECK(task_runner_->RunsTasksOnCurrentThread()); - SaveUserDisplayName(account_id, account_data.display_name()); + SaveUserDisplayName(user_id, account_data.display_name()); - if (User* user = FindUserAndModify(account_id)) { + if (User* user = FindUserAndModify(user_id)) { base::string16 given_name = account_data.given_name(); user->set_given_name(given_name); - if (!IsUserNonCryptohomeDataEphemeral(account_id)) { + if (!IsUserNonCryptohomeDataEphemeral(user_id)) { DictionaryPrefUpdate given_name_update(GetLocalState(), kUserGivenName); given_name_update->SetWithoutPathExpansion( - account_id.GetUserEmail(), new base::StringValue(given_name)); + user_id, new base::StringValue(given_name)); } } - UpdateUserAccountLocale(account_id, account_data.locale()); + UpdateUserAccountLocale(user_id, account_data.locale()); } // static void UserManagerBase::ParseUserList(const base::ListValue& users_list, - const std::set<AccountId>& existing_users, - std::vector<AccountId>* users_vector, - std::set<AccountId>* users_set) { + const std::set<std::string>& existing_users, + std::vector<std::string>* users_vector, + std::set<std::string>* users_set) { users_vector->clear(); users_set->clear(); for (size_t i = 0; i < users_list.GetSize(); ++i) { @@ -595,13 +599,12 @@ void UserManagerBase::ParseUserList(const base::ListValue& users_list, LOG(ERROR) << "Corrupt entry in user list at index " << i << "."; continue; } - const AccountId account_id(AccountId::FromUserEmail(email)); - if (existing_users.find(account_id) != existing_users.end() || - !users_set->insert(account_id).second) { + if (existing_users.find(email) != existing_users.end() || + !users_set->insert(email).second) { LOG(ERROR) << "Duplicate user: " << email; continue; } - users_vector->push_back(account_id); + users_vector->push_back(email); } } @@ -628,7 +631,7 @@ bool UserManagerBase::IsCurrentUserNew() const { bool UserManagerBase::IsCurrentUserNonCryptohomeDataEphemeral() const { DCHECK(task_runner_->RunsTasksOnCurrentThread()); return IsUserLoggedIn() && - IsUserNonCryptohomeDataEphemeral(GetLoggedInUser()->GetAccountId()); + IsUserNonCryptohomeDataEphemeral(GetLoggedInUser()->email()); } bool UserManagerBase::CanCurrentUserLock() const { @@ -684,17 +687,17 @@ bool UserManagerBase::IsSessionStarted() const { } bool UserManagerBase::IsUserNonCryptohomeDataEphemeral( - const AccountId& account_id) const { + const std::string& user_id) const { // Data belonging to the guest and stub users is always ephemeral. - if (account_id == chromeos::login::GuestAccountId() || - account_id == chromeos::login::StubAccountId()) { + if (user_id == chromeos::login::kGuestUserName || + user_id == chromeos::login::kStubUser) { return true; } // Data belonging to the owner, anyone found on the user list and obsolete // public accounts whose data has not been removed yet is not ephemeral. - if (account_id == GetOwnerAccountId() || UserExistsInList(account_id) || - IsPublicAccountMarkedForRemoval(account_id)) { + if (user_id == GetOwnerEmail() || UserExistsInList(user_id) || + IsPublicAccountMarkedForRemoval(user_id)) { return false; } @@ -703,7 +706,7 @@ bool UserManagerBase::IsUserNonCryptohomeDataEphemeral( // policy was enabled. // - or - // b) The user logged into any other account type. - if (IsUserLoggedIn() && (account_id == GetLoggedInUser()->GetAccountId()) && + if (IsUserLoggedIn() && (user_id == GetLoggedInUser()->email()) && (is_current_user_ephemeral_regular_user_ || !IsLoggedInAsUserWithGaiaAccount())) { return true; @@ -783,20 +786,20 @@ void UserManagerBase::SetIsCurrentUserNew(bool is_new) { is_current_user_new_ = is_new; } -bool UserManagerBase::HasPendingBootstrap(const AccountId& account_id) const { +bool UserManagerBase::HasPendingBootstrap(const std::string& user_id) const { return false; } -void UserManagerBase::SetOwnerId(const AccountId& owner_account_id) { - owner_account_id_ = owner_account_id; +void UserManagerBase::SetOwnerEmail(const std::string& owner_user_id) { + owner_email_ = owner_user_id; } -const AccountId& UserManagerBase::GetPendingUserSwitchID() const { +const std::string& UserManagerBase::GetPendingUserSwitchID() const { return pending_user_switch_; } -void UserManagerBase::SetPendingUserSwitchId(const AccountId& account_id) { - pending_user_switch_ = account_id; +void UserManagerBase::SetPendingUserSwitchID(const std::string& user_id) { + pending_user_switch_ = user_id; } void UserManagerBase::EnsureUsersLoaded() { @@ -824,27 +827,27 @@ void UserManagerBase::EnsureUsersLoaded() { local_state->GetDictionary(kUserType); // Load public sessions first. - std::set<AccountId> public_sessions_set; + std::set<std::string> public_sessions_set; LoadPublicAccounts(&public_sessions_set); // Load regular users and supervised users. - std::vector<AccountId> regular_users; - std::set<AccountId> regular_users_set; + std::vector<std::string> regular_users; + std::set<std::string> regular_users_set; ParseUserList(*prefs_regular_users, public_sessions_set, ®ular_users, ®ular_users_set); - for (std::vector<AccountId>::const_iterator it = regular_users.begin(); - it != regular_users.end(); ++it) { - User* user = nullptr; - const std::string domain = gaia::ExtractDomainName(it->GetUserEmail()); + for (std::vector<std::string>::const_iterator it = regular_users.begin(); + it != regular_users.end(); + ++it) { + User* user = NULL; + const std::string domain = gaia::ExtractDomainName(*it); if (domain == chromeos::login::kSupervisedUserDomain) { user = User::CreateSupervisedUser(*it); } else { user = User::CreateRegularUser(*it); int user_type; - if (prefs_user_types->GetIntegerWithoutPathExpansion(it->GetUserEmail(), - &user_type) && + if (prefs_user_types->GetIntegerWithoutPathExpansion(*it, &user_type) && user_type == USER_TYPE_CHILD) { ChangeUserChildStatus(user, true /* is child */); } @@ -855,19 +858,18 @@ void UserManagerBase::EnsureUsersLoaded() { users_.push_back(user); base::string16 display_name; - if (prefs_display_names->GetStringWithoutPathExpansion(it->GetUserEmail(), + if (prefs_display_names->GetStringWithoutPathExpansion(*it, &display_name)) { user->set_display_name(display_name); } base::string16 given_name; - if (prefs_given_names->GetStringWithoutPathExpansion(it->GetUserEmail(), - &given_name)) { + if (prefs_given_names->GetStringWithoutPathExpansion(*it, &given_name)) { user->set_given_name(given_name); } std::string display_email; - if (prefs_display_emails->GetStringWithoutPathExpansion(it->GetUserEmail(), + if (prefs_display_emails->GetStringWithoutPathExpansion(*it, &display_email)) { user->set_display_email(display_email); } @@ -883,32 +885,32 @@ UserList& UserManagerBase::GetUsersAndModify() { return users_; } -const User* UserManagerBase::FindUserInList(const AccountId& account_id) const { +const User* UserManagerBase::FindUserInList(const std::string& user_id) const { const UserList& users = GetUsers(); for (UserList::const_iterator it = users.begin(); it != users.end(); ++it) { - if ((*it)->GetAccountId() == account_id) + if ((*it)->email() == user_id) return *it; } - return nullptr; + return NULL; } -bool UserManagerBase::UserExistsInList(const AccountId& account_id) const { +bool UserManagerBase::UserExistsInList(const std::string& user_id) const { const base::ListValue* user_list = GetLocalState()->GetList(kRegularUsers); for (size_t i = 0; i < user_list->GetSize(); ++i) { std::string email; - if (user_list->GetString(i, &email) && (account_id.GetUserEmail() == email)) + if (user_list->GetString(i, &email) && (user_id == email)) return true; } return false; } -User* UserManagerBase::FindUserInListAndModify(const AccountId& account_id) { +User* UserManagerBase::FindUserInListAndModify(const std::string& user_id) { UserList& users = GetUsersAndModify(); for (UserList::iterator it = users.begin(); it != users.end(); ++it) { - if ((*it)->GetAccountId() == account_id) + if ((*it)->email() == user_id) return *it; } - return nullptr; + return NULL; } void UserManagerBase::GuestUserLoggedIn() { @@ -923,16 +925,16 @@ void UserManagerBase::AddUserRecord(User* user) { users_.insert(users_.begin(), user); } -void UserManagerBase::RegularUserLoggedIn(const AccountId& account_id) { +void UserManagerBase::RegularUserLoggedIn(const std::string& user_id) { // Remove the user from the user list. - active_user_ = RemoveRegularOrSupervisedUserFromList(account_id); + active_user_ = RemoveRegularOrSupervisedUserFromList(user_id); // If the user was not found on the user list, create a new user. SetIsCurrentUserNew(!active_user_); if (IsCurrentUserNew()) { - active_user_ = User::CreateRegularUser(account_id); - active_user_->set_oauth_token_status(LoadUserOAuthStatus(account_id)); - SaveUserDisplayName(active_user_->GetAccountId(), + active_user_ = User::CreateRegularUser(user_id); + active_user_->set_oauth_token_status(LoadUserOAuthStatus(user_id)); + SaveUserDisplayName(active_user_->email(), base::UTF8ToUTF16(active_user_->GetAccountName(true))); } @@ -943,11 +945,11 @@ void UserManagerBase::RegularUserLoggedIn(const AccountId& account_id) { } void UserManagerBase::RegularUserLoggedInAsEphemeral( - const AccountId& account_id) { + const std::string& user_id) { DCHECK(task_runner_->RunsTasksOnCurrentThread()); SetIsCurrentUserNew(true); is_current_user_ephemeral_regular_user_ = true; - active_user_ = User::CreateRegularUser(account_id); + active_user_ = User::CreateRegularUser(user_id); } void UserManagerBase::NotifyOnLogin() { @@ -959,83 +961,77 @@ void UserManagerBase::NotifyOnLogin() { } User::OAuthTokenStatus UserManagerBase::LoadUserOAuthStatus( - const AccountId& account_id) const { + const std::string& user_id) const { DCHECK(task_runner_->RunsTasksOnCurrentThread()); const base::DictionaryValue* prefs_oauth_status = GetLocalState()->GetDictionary(kUserOAuthTokenStatus); int oauth_token_status = User::OAUTH_TOKEN_STATUS_UNKNOWN; if (prefs_oauth_status && - prefs_oauth_status->GetIntegerWithoutPathExpansion( - account_id.GetUserEmail(), &oauth_token_status)) { + prefs_oauth_status->GetIntegerWithoutPathExpansion(user_id, + &oauth_token_status)) { User::OAuthTokenStatus status = static_cast<User::OAuthTokenStatus>(oauth_token_status); - HandleUserOAuthTokenStatusChange(account_id, status); + HandleUserOAuthTokenStatusChange(user_id, status); return status; } return User::OAUTH_TOKEN_STATUS_UNKNOWN; } -bool UserManagerBase::LoadForceOnlineSignin(const AccountId& account_id) const { +bool UserManagerBase::LoadForceOnlineSignin(const std::string& user_id) const { DCHECK(task_runner_->RunsTasksOnCurrentThread()); const base::DictionaryValue* prefs_force_online = GetLocalState()->GetDictionary(kUserForceOnlineSignin); bool force_online_signin = false; if (prefs_force_online) { - prefs_force_online->GetBooleanWithoutPathExpansion( - account_id.GetUserEmail(), &force_online_signin); + prefs_force_online->GetBooleanWithoutPathExpansion(user_id, + &force_online_signin); } return force_online_signin; } -void UserManagerBase::RemoveNonCryptohomeData(const AccountId& account_id) { +void UserManagerBase::RemoveNonCryptohomeData(const std::string& user_id) { PrefService* prefs = GetLocalState(); DictionaryPrefUpdate prefs_display_name_update(prefs, kUserDisplayName); - prefs_display_name_update->RemoveWithoutPathExpansion( - account_id.GetUserEmail(), nullptr); + prefs_display_name_update->RemoveWithoutPathExpansion(user_id, NULL); DictionaryPrefUpdate prefs_given_name_update(prefs, kUserGivenName); - prefs_given_name_update->RemoveWithoutPathExpansion(account_id.GetUserEmail(), - nullptr); + prefs_given_name_update->RemoveWithoutPathExpansion(user_id, NULL); DictionaryPrefUpdate prefs_display_email_update(prefs, kUserDisplayEmail); - prefs_display_email_update->RemoveWithoutPathExpansion( - account_id.GetUserEmail(), nullptr); + prefs_display_email_update->RemoveWithoutPathExpansion(user_id, NULL); DictionaryPrefUpdate prefs_oauth_update(prefs, kUserOAuthTokenStatus); - prefs_oauth_update->RemoveWithoutPathExpansion(account_id.GetUserEmail(), - nullptr); + prefs_oauth_update->RemoveWithoutPathExpansion(user_id, NULL); DictionaryPrefUpdate prefs_force_online_update(prefs, kUserForceOnlineSignin); - prefs_force_online_update->RemoveWithoutPathExpansion( - account_id.GetUserEmail(), nullptr); + prefs_force_online_update->RemoveWithoutPathExpansion(user_id, NULL); - RemoveKnownUserPrefs(account_id); + RemoveKnownUserPrefs(user_id); - const AccountId last_active_user = - AccountId::FromUserEmail(GetLocalState()->GetString(kLastActiveUser)); - if (account_id == last_active_user) + std::string last_active_user = GetLocalState()->GetString(kLastActiveUser); + if (user_id == last_active_user) GetLocalState()->SetString(kLastActiveUser, std::string()); } bool UserManagerBase::FindKnownUserPrefs( - const AccountId& account_id, + const UserID& user_id, const base::DictionaryValue** out_value) { PrefService* local_state = GetLocalState(); // Local State may not be initialized in tests. if (!local_state) return false; - if (IsUserNonCryptohomeDataEphemeral(account_id)) + if (IsUserNonCryptohomeDataEphemeral(user_id)) return false; const base::ListValue* known_users = local_state->GetList(kKnownUsers); for (size_t i = 0; i < known_users->GetSize(); ++i) { const base::DictionaryValue* element = nullptr; if (known_users->GetDictionary(i, &element)) { - if (UserMatches(account_id, *element)) { + if (UserMatches(user_id, *element)) { known_users->GetDictionary(i, out_value); return true; } @@ -1044,7 +1040,7 @@ bool UserManagerBase::FindKnownUserPrefs( return false; } -void UserManagerBase::UpdateKnownUserPrefs(const AccountId& account_id, +void UserManagerBase::UpdateKnownUserPrefs(const UserID& user_id, const base::DictionaryValue& values, bool clear) { PrefService* local_state = GetLocalState(); @@ -1053,39 +1049,39 @@ void UserManagerBase::UpdateKnownUserPrefs(const AccountId& account_id, if (!local_state) return; - if (IsUserNonCryptohomeDataEphemeral(account_id)) + if (IsUserNonCryptohomeDataEphemeral(user_id)) return; ListPrefUpdate update(local_state, kKnownUsers); for (size_t i = 0; i < update->GetSize(); ++i) { base::DictionaryValue* element = nullptr; if (update->GetDictionary(i, &element)) { - if (UserMatches(account_id, *element)) { + if (UserMatches(user_id, *element)) { if (clear) element->Clear(); element->MergeDictionary(&values); - UpdateIdentity(account_id, *element); + UpdateIdentity(user_id, *element); return; } } } scoped_ptr<base::DictionaryValue> new_value(new base::DictionaryValue()); new_value->MergeDictionary(&values); - UpdateIdentity(account_id, *new_value); + UpdateIdentity(user_id, *new_value); update->Append(new_value.release()); } -bool UserManagerBase::GetKnownUserStringPref(const AccountId& account_id, +bool UserManagerBase::GetKnownUserStringPref(const UserID& user_id, const std::string& path, std::string* out_value) { const base::DictionaryValue* user_pref_dict = nullptr; - if (!FindKnownUserPrefs(account_id, &user_pref_dict)) + if (!FindKnownUserPrefs(user_id, &user_pref_dict)) return false; return user_pref_dict->GetString(path, out_value); } -void UserManagerBase::SetKnownUserStringPref(const AccountId& account_id, +void UserManagerBase::SetKnownUserStringPref(const UserID& user_id, const std::string& path, const std::string& in_value) { PrefService* local_state = GetLocalState(); @@ -1097,20 +1093,20 @@ void UserManagerBase::SetKnownUserStringPref(const AccountId& account_id, ListPrefUpdate update(local_state, kKnownUsers); base::DictionaryValue dict; dict.SetString(path, in_value); - UpdateKnownUserPrefs(account_id, dict, false); + UpdateKnownUserPrefs(user_id, dict, false); } -bool UserManagerBase::GetKnownUserBooleanPref(const AccountId& account_id, +bool UserManagerBase::GetKnownUserBooleanPref(const UserID& user_id, const std::string& path, bool* out_value) { const base::DictionaryValue* user_pref_dict = nullptr; - if (!FindKnownUserPrefs(account_id, &user_pref_dict)) + if (!FindKnownUserPrefs(user_id, &user_pref_dict)) return false; return user_pref_dict->GetBoolean(path, out_value); } -void UserManagerBase::SetKnownUserBooleanPref(const AccountId& account_id, +void UserManagerBase::SetKnownUserBooleanPref(const UserID& user_id, const std::string& path, const bool in_value) { PrefService* local_state = GetLocalState(); @@ -1122,19 +1118,19 @@ void UserManagerBase::SetKnownUserBooleanPref(const AccountId& account_id, ListPrefUpdate update(local_state, kKnownUsers); base::DictionaryValue dict; dict.SetBoolean(path, in_value); - UpdateKnownUserPrefs(account_id, dict, false); + UpdateKnownUserPrefs(user_id, dict, false); } -bool UserManagerBase::GetKnownUserIntegerPref(const AccountId& account_id, +bool UserManagerBase::GetKnownUserIntegerPref(const UserID& user_id, const std::string& path, int* out_value) { const base::DictionaryValue* user_pref_dict = nullptr; - if (!FindKnownUserPrefs(account_id, &user_pref_dict)) + if (!FindKnownUserPrefs(user_id, &user_pref_dict)) return false; return user_pref_dict->GetInteger(path, out_value); } -void UserManagerBase::SetKnownUserIntegerPref(const AccountId& account_id, +void UserManagerBase::SetKnownUserIntegerPref(const UserID& user_id, const std::string& path, const int in_value) { PrefService* local_state = GetLocalState(); @@ -1146,92 +1142,80 @@ void UserManagerBase::SetKnownUserIntegerPref(const AccountId& account_id, ListPrefUpdate update(local_state, kKnownUsers); base::DictionaryValue dict; dict.SetInteger(path, in_value); - UpdateKnownUserPrefs(account_id, dict, false); + UpdateKnownUserPrefs(user_id, dict, false); } -bool UserManagerBase::GetKnownUserAccountId( - const AccountId& authenticated_account_id, - AccountId* out_account_id) { - DCHECK(!authenticated_account_id.GetGaiaId().empty()); - std::string canonical_email; - if (!GetKnownUserStringPref( - AccountId::FromGaiaId(authenticated_account_id.GetGaiaId()), - kCanonicalEmail, &canonical_email)) - return false; - - *out_account_id = authenticated_account_id; - out_account_id->SetUserEmail(canonical_email); - return true; +bool UserManagerBase::GetKnownUserCanonicalEmail(const UserID& user_id, + std::string* out_email) { + return GetKnownUserStringPref(user_id, kCanonicalEmail, out_email); } -void UserManagerBase::UpdateGaiaID(const AccountId& account_id, +void UserManagerBase::UpdateGaiaID(const UserID& user_id, const std::string& gaia_id) { - SetKnownUserStringPref(account_id, kGAIAIdKey, gaia_id); + SetKnownUserStringPref(user_id, kGAIAIdKey, gaia_id); } -bool UserManagerBase::FindGaiaID(const AccountId& account_id, +bool UserManagerBase::FindGaiaID(const UserID& user_id, std::string* out_value) { - return GetKnownUserStringPref(account_id, kGAIAIdKey, out_value); + return GetKnownUserStringPref(user_id, kGAIAIdKey, out_value); } -void UserManagerBase::SetKnownUserDeviceId(const AccountId& account_id, +void UserManagerBase::SetKnownUserDeviceId(const UserID& user_id, const std::string& device_id) { - const std::string known_device_id = GetKnownUserDeviceId(account_id); + const std::string known_device_id = GetKnownUserDeviceId(user_id); if (!known_device_id.empty() && device_id != known_device_id) { NOTREACHED() << "Trying to change device ID for known user."; } - SetKnownUserStringPref(account_id, kDeviceId, device_id); + SetKnownUserStringPref(user_id, kDeviceId, device_id); } -std::string UserManagerBase::GetKnownUserDeviceId(const AccountId& account_id) { +std::string UserManagerBase::GetKnownUserDeviceId(const UserID& user_id) { std::string device_id; - if (GetKnownUserStringPref(account_id, kDeviceId, &device_id)) { + if (GetKnownUserStringPref(user_id, kDeviceId, &device_id)) { return device_id; } return std::string(); } -void UserManagerBase::SetKnownUserGAPSCookie(const AccountId& account_id, +void UserManagerBase::SetKnownUserGAPSCookie(const UserID& user_id, const std::string& gaps_cookie) { - SetKnownUserStringPref(account_id, kGAPSCookie, gaps_cookie); + SetKnownUserStringPref(user_id, kGAPSCookie, gaps_cookie); } -std::string UserManagerBase::GetKnownUserGAPSCookie( - const AccountId& account_id) { +std::string UserManagerBase::GetKnownUserGAPSCookie(const UserID& user_id) { std::string gaps_cookie; - if (GetKnownUserStringPref(account_id, kGAPSCookie, &gaps_cookie)) { + if (GetKnownUserStringPref(user_id, kGAPSCookie, &gaps_cookie)) { return gaps_cookie; } return std::string(); } User* UserManagerBase::RemoveRegularOrSupervisedUserFromList( - const AccountId& account_id) { + const std::string& user_id) { ListPrefUpdate prefs_users_update(GetLocalState(), kRegularUsers); prefs_users_update->Clear(); - User* user = nullptr; + User* user = NULL; for (UserList::iterator it = users_.begin(); it != users_.end();) { - if ((*it)->GetAccountId() == account_id) { + const std::string user_email = (*it)->email(); + if (user_email == user_id) { user = *it; it = users_.erase(it); } else { - if ((*it)->HasGaiaAccount() || (*it)->IsSupervised()) { - const std::string user_email = (*it)->email(); + if ((*it)->HasGaiaAccount() || (*it)->IsSupervised()) prefs_users_update->Append(new base::StringValue(user_email)); - } ++it; } } - OnUserRemoved(account_id); + OnUserRemoved(user_id); return user; } -void UserManagerBase::RemoveKnownUserPrefs(const AccountId& account_id) { +void UserManagerBase::RemoveKnownUserPrefs(const UserID& user_id) { ListPrefUpdate update(GetLocalState(), kKnownUsers); for (size_t i = 0; i < update->GetSize(); ++i) { base::DictionaryValue* element = nullptr; if (update->GetDictionary(i, &element)) { - if (UserMatches(account_id, *element)) { + if (UserMatches(user_id, *element)) { update->Remove(i, nullptr); break; } @@ -1266,9 +1250,8 @@ void UserManagerBase::ChangeUserChildStatus(User* user, bool is_child) { if (user->IsSupervised() == is_child) return; user->SetIsChild(is_child); - SaveUserType(user->GetAccountId(), is_child - ? user_manager::USER_TYPE_CHILD - : user_manager::USER_TYPE_REGULAR); + SaveUserType(user->email(), is_child ? user_manager::USER_TYPE_CHILD + : user_manager::USER_TYPE_REGULAR); FOR_EACH_OBSERVER(UserManager::UserSessionStateObserver, session_state_observer_list_, UserChangedChildStatus(user)); @@ -1318,7 +1301,7 @@ void UserManagerBase::SetLRUUser(User* user) { lru_logged_in_users_.insert(lru_logged_in_users_.begin(), user); } -void UserManagerBase::SendGaiaUserLoginMetrics(const AccountId& account_id) { +void UserManagerBase::SendGaiaUserLoginMetrics(const std::string& user_id) { // If this isn't the first time Chrome was run after the system booted, // assume that Chrome was restarted because a previous session ended. if (!base::CommandLine::ForCurrentProcess()->HasSwitch( @@ -1327,8 +1310,7 @@ void UserManagerBase::SendGaiaUserLoginMetrics(const AccountId& account_id) { GetLocalState()->GetString(kLastLoggedInGaiaUser); const base::TimeDelta time_to_login = base::TimeTicks::Now() - manager_creation_time_; - if (!last_email.empty() && - account_id != AccountId::FromUserEmail(last_email) && + if (!last_email.empty() && user_id != last_email && time_to_login.InSeconds() <= kLogoutToLoginDelayMaxSec) { UMA_HISTOGRAM_CUSTOM_COUNTS("UserManager.LogoutToLoginDelay", time_to_login.InSeconds(), @@ -1339,29 +1321,31 @@ void UserManagerBase::SendGaiaUserLoginMetrics(const AccountId& account_id) { } } -void UserManagerBase::UpdateUserAccountLocale(const AccountId& account_id, +void UserManagerBase::UpdateUserAccountLocale(const std::string& user_id, const std::string& locale) { scoped_ptr<std::string> resolved_locale(new std::string()); if (!locale.empty() && locale != GetApplicationLocale()) { - // base::Pased will nullptr out |resolved_locale|, so cache the underlying - // ptr. + // base::Pased will NULL out |resolved_locale|, so cache the underlying ptr. std::string* raw_resolved_locale = resolved_locale.get(); blocking_task_runner_->PostTaskAndReply( - FROM_HERE, base::Bind(ResolveLocale, locale, - base::Unretained(raw_resolved_locale)), + FROM_HERE, + base::Bind(ResolveLocale, + locale, + base::Unretained(raw_resolved_locale)), base::Bind(&UserManagerBase::DoUpdateAccountLocale, - weak_factory_.GetWeakPtr(), account_id, + weak_factory_.GetWeakPtr(), + user_id, base::Passed(&resolved_locale))); } else { resolved_locale.reset(new std::string(locale)); - DoUpdateAccountLocale(account_id, resolved_locale.Pass()); + DoUpdateAccountLocale(user_id, resolved_locale.Pass()); } } void UserManagerBase::DoUpdateAccountLocale( - const AccountId& account_id, + const std::string& user_id, scoped_ptr<std::string> resolved_locale) { - User* user = FindUserAndModify(account_id); + User* user = FindUserAndModify(user_id); if (user && resolved_locale) user->SetAccountLocale(*resolved_locale); } @@ -1370,7 +1354,7 @@ void UserManagerBase::DeleteUser(User* user) { const bool is_active_user = (user == active_user_); delete user; if (is_active_user) - active_user_ = nullptr; + active_user_ = NULL; } } // namespace user_manager diff --git a/components/user_manager/user_manager_base.h b/components/user_manager/user_manager_base.h index ead7d44..a5f5f8f 100644 --- a/components/user_manager/user_manager_base.h +++ b/components/user_manager/user_manager_base.h @@ -15,8 +15,8 @@ #include "base/observer_list.h" #include "base/synchronization/lock.h" #include "base/time/time.h" -#include "components/signin/core/account_id/account_id.h" #include "components/user_manager/user.h" +#include "components/user_manager/user_id.h" #include "components/user_manager/user_manager.h" #include "components/user_manager/user_manager_export.h" #include "components/user_manager/user_type.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 AccountId& GetOwnerAccountId() const override; - void UserLoggedIn(const AccountId& account_id, + const std::string& GetOwnerEmail() const override; + void UserLoggedIn(const std::string& user_id, const std::string& user_id_hash, bool browser_restart) override; - void SwitchActiveUser(const AccountId& account_id) override; + void SwitchActiveUser(const std::string& user_id) override; void SwitchToLastActiveUser() override; void SessionStarted() override; - void RemoveUser(const AccountId& account_id, + void RemoveUser(const std::string& user_id, RemoveUserDelegate* delegate) override; - void RemoveUserFromList(const AccountId& account_id) override; - bool IsKnownUser(const AccountId& account_id) const override; - const User* FindUser(const AccountId& account_id) const override; - User* FindUserAndModify(const AccountId& account_id) 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; const User* GetLoggedInUser() const override; User* GetLoggedInUser() override; const User* GetActiveUser() const override; User* GetActiveUser() override; const User* GetPrimaryUser() const override; - void SaveUserOAuthStatus(const AccountId& account_id, + void SaveUserOAuthStatus(const std::string& user_id, User::OAuthTokenStatus oauth_token_status) override; - void SaveForceOnlineSignin(const AccountId& account_id, + void SaveForceOnlineSignin(const std::string& user_id, bool force_online_signin) override; - void SaveUserDisplayName(const AccountId& account_id, + void SaveUserDisplayName(const std::string& user_id, const base::string16& display_name) override; - base::string16 GetUserDisplayName(const AccountId& account_id) const override; - void SaveUserDisplayEmail(const AccountId& account_id, + base::string16 GetUserDisplayName(const std::string& user_id) const override; + void SaveUserDisplayEmail(const std::string& user_id, const std::string& display_email) override; - std::string GetUserDisplayEmail(const AccountId& account_id) const override; - void SaveUserType(const AccountId& account_id, + std::string GetUserDisplayEmail(const std::string& user_id) const override; + void SaveUserType(const std::string& user_id, const UserType& user_type) override; - void UpdateUserAccountData(const AccountId& account_id, + void UpdateUserAccountData(const std::string& 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 AccountId& account_id) const override; + const std::string& user_id) const override; void AddObserver(UserManager::Observer* obs) override; void RemoveObserver(UserManager::Observer* obs) override; void AddSessionStateObserver( @@ -106,61 +106,58 @@ class USER_MANAGER_EXPORT UserManagerBase : public UserManager { UserManager::UserSessionStateObserver* obs) override; void NotifyLocalStateChanged() override; void ChangeUserChildStatus(User* user, bool is_child) override; - bool FindKnownUserPrefs(const AccountId& account_id, + bool FindKnownUserPrefs(const UserID& user_id, const base::DictionaryValue** out_value) override; - void UpdateKnownUserPrefs(const AccountId& account_id, + void UpdateKnownUserPrefs(const UserID& user_id, const base::DictionaryValue& values, bool clear) override; - bool GetKnownUserStringPref(const AccountId& account_id, + bool GetKnownUserStringPref(const UserID& user_id, const std::string& path, std::string* out_value) override; - void SetKnownUserStringPref(const AccountId& account_id, + void SetKnownUserStringPref(const UserID& user_id, const std::string& path, const std::string& in_value) override; - bool GetKnownUserBooleanPref(const AccountId& account_id, + bool GetKnownUserBooleanPref(const UserID& user_id, const std::string& path, bool* out_value) override; - void SetKnownUserBooleanPref(const AccountId& account_id, + void SetKnownUserBooleanPref(const UserID& user_id, const std::string& path, const bool in_value) override; - bool GetKnownUserIntegerPref(const AccountId& account_id, + bool GetKnownUserIntegerPref(const UserID& user_id, const std::string& path, int* out_value) override; - void SetKnownUserIntegerPref(const AccountId& account_id, + void SetKnownUserIntegerPref(const UserID& user_id, const std::string& path, - int in_value) override; - bool GetKnownUserAccountId(const AccountId& authenticated_account_id, - AccountId* out_account_id) override; - void UpdateGaiaID(const AccountId& account_id, - const std::string& gaia_id) override; - bool FindGaiaID(const AccountId& account_id, std::string* out_value) override; - void UpdateUsingSAML(const AccountId& account_id, + const int in_value) override; + bool GetKnownUserCanonicalEmail(const UserID& user_id, + std::string* out_email) 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, const bool using_saml) override; - bool FindUsingSAML(const AccountId& account_id) override; - void SetKnownUserDeviceId(const AccountId& account_id, + bool FindUsingSAML(const std::string& user_id) override; + void SetKnownUserDeviceId(const UserID& user_id, const std::string& device_id) override; - std::string GetKnownUserDeviceId(const AccountId& account_id) override; - void SetKnownUserGAPSCookie(const AccountId& account_id, + std::string GetKnownUserDeviceId(const UserID& user_id) override; + void SetKnownUserGAPSCookie(const UserID& user_id, const std::string& gaps_cookie) override; - std::string GetKnownUserGAPSCookie(const AccountId& account_id) override; - void UpdateReauthReason(const AccountId& account_id, - int reauth_reason) override; - bool FindReauthReason(const AccountId& account_id, int* out_value) override; + std::string GetKnownUserGAPSCookie(const UserID& user_id) override; + void UpdateReauthReason(const std::string& user_id, + const int reauth_reason) override; + bool FindReauthReason(const std::string& user_id, int* out_value) override; - // This method updates "User was added to the device in this session nad is - // not full initialized yet" flag. virtual void SetIsCurrentUserNew(bool is_new); // TODO(xiyuan): Figure out a better way to expose this info. - virtual bool HasPendingBootstrap(const AccountId& account_id) const; + virtual bool HasPendingBootstrap(const std::string& 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 // skipped. static void ParseUserList(const base::ListValue& users_list, - const std::set<AccountId>& existing_users, - std::vector<AccountId>* users_vector, - std::set<AccountId>* users_set); + const std::set<std::string>& existing_users, + std::vector<std::string>* users_vector, + std::set<std::string>* users_set); // Returns true if trusted device policies have successfully been retrieved // and ephemeral users are enabled. @@ -188,9 +185,9 @@ class USER_MANAGER_EXPORT UserManagerBase : public UserManager { // Subsequent calls have no effect. Must be called on the UI thread. virtual void EnsureUsersLoaded(); - // Handle OAuth token |status| change for |account_id|. + // Handle OAuth token |status| change for |user_id|. virtual void HandleUserOAuthTokenStatusChange( - const AccountId& account_id, + const std::string& user_id, User::OAuthTokenStatus status) const = 0; // Returns true if device is enterprise managed. @@ -201,7 +198,8 @@ class USER_MANAGER_EXPORT UserManagerBase : public UserManager { // skipped. // Loads public accounts from the Local state and fills in // |public_sessions_set|. - virtual void LoadPublicAccounts(std::set<AccountId>* public_sessions_set) = 0; + virtual void LoadPublicAccounts( + std::set<std::string>* public_sessions_set) = 0; // Notifies that user has logged in. virtual void NotifyOnLogin(); @@ -226,36 +224,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 AccountId& account_id, + virtual void RemoveNonOwnerUserInternal(const std::string& user_email, 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 AccountId& account_id); + User* RemoveRegularOrSupervisedUserFromList(const std::string& 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 AccountId& account_id, + virtual void RemoveUserInternal(const std::string& user_email, 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 AccountId& account_id); + virtual void RemoveNonCryptohomeData(const std::string& user_id); // Check for a particular user type. - // Returns true if |account_id| represents demo app. - virtual bool IsDemoApp(const AccountId& account_id) const = 0; + // Returns true if |user_id| represents demo app. + virtual bool IsDemoApp(const std::string& user_id) const = 0; - // Returns true if |account_id| represents kiosk app. - virtual bool IsKioskApp(const AccountId& account_id) const = 0; + // Returns true if |user_id| represents kiosk app. + virtual bool IsKioskApp(const std::string& user_id) const = 0; - // Returns true if |account_id| represents public account that has been marked + // Returns true if |user_id| represents public account that has been marked // for deletion. virtual bool IsPublicAccountMarkedForRemoval( - const AccountId& account_id) const = 0; + const std::string& user_id) const = 0; // These methods are called when corresponding user type has signed in. @@ -266,22 +264,22 @@ class USER_MANAGER_EXPORT UserManagerBase : public UserManager { virtual void GuestUserLoggedIn(); // Indicates that a kiosk app robot just logged in. - virtual void KioskAppLoggedIn(const AccountId& kiosk_app_account_id) = 0; + virtual void KioskAppLoggedIn(const std::string& app_id) = 0; // Indicates that a user just logged into a public session. virtual void PublicAccountUserLoggedIn(User* user) = 0; // Indicates that a regular user just logged in. - virtual void RegularUserLoggedIn(const AccountId& account_id); + virtual void RegularUserLoggedIn(const std::string& user_id); // Indicates that a regular user just logged in as ephemeral. - virtual void RegularUserLoggedInAsEphemeral(const AccountId& account_id); + virtual void RegularUserLoggedInAsEphemeral(const std::string& user_id); // Indicates that a supervised user just logged in. - virtual void SupervisedUserLoggedIn(const AccountId& account_id) = 0; + virtual void SupervisedUserLoggedIn(const std::string& user_id) = 0; // Should be called when regular user was removed. - virtual void OnUserRemoved(const AccountId& account_id) = 0; + virtual void OnUserRemoved(const std::string& user_id) = 0; // Getters/setters for private members. @@ -290,20 +288,20 @@ class USER_MANAGER_EXPORT UserManagerBase : public UserManager { virtual bool GetEphemeralUsersEnabled() const; virtual void SetEphemeralUsersEnabled(bool enabled); - virtual void SetOwnerId(const AccountId& owner_account_id); + virtual void SetOwnerEmail(const std::string& owner_user_id); - virtual const AccountId& GetPendingUserSwitchID() const; - virtual void SetPendingUserSwitchId(const AccountId& account_id); + virtual const std::string& GetPendingUserSwitchID() const; + virtual void SetPendingUserSwitchID(const std::string& user_id); // The logged-in user that is currently active in current session. // NULL until a user has logged in, then points to one // of the User instances in |users_|, the |guest_user_| instance or an // ephemeral user instance. - User* active_user_ = nullptr; + User* active_user_; // The primary user of the current session. It is recorded for the first // signed-in user and does not change thereafter. - User* primary_user_ = nullptr; + User* primary_user_; // List of all known users. User instances are owned by |this|. Regular users // are removed by |RemoveUserFromList|, public accounts by @@ -330,21 +328,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 AccountId& account_id) const; + const User* FindUserInList(const std::string& 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 AccountId& account_id) const; + bool UserExistsInList(const std::string& user_id) const; // Same as FindUserInList but returns non-const pointer to User object. - User* FindUserInListAndModify(const AccountId& account_id); + User* FindUserInListAndModify(const std::string& user_id); // Reads user's oauth token status from local state preferences. - User::OAuthTokenStatus LoadUserOAuthStatus(const AccountId& account_id) const; + User::OAuthTokenStatus LoadUserOAuthStatus(const std::string& 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 AccountId& account_id) const; + bool LoadForceOnlineSignin(const std::string& user_id) const; // Notifies observers that merge session state had changed. void NotifyMergeSessionStateChanged(); @@ -352,7 +350,7 @@ class USER_MANAGER_EXPORT UserManagerBase : public UserManager { // Notifies observers that active user has changed. void NotifyActiveUserChanged(const User* active_user); - // Notifies observers that active account_id hash has changed. + // Notifies observers that active user_id hash has changed. void NotifyActiveUserHashChanged(const std::string& hash); // Update the global LoginState. @@ -362,49 +360,49 @@ 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 AccountId& account_id); + void SendGaiaUserLoginMetrics(const std::string& user_id); - // Sets account locale for user with id |account_id|. - virtual void UpdateUserAccountLocale(const AccountId& account_id, + // Sets account locale for user with id |user_id|. + virtual void UpdateUserAccountLocale(const std::string& user_id, const std::string& locale); // Updates user account after locale was resolved. - void DoUpdateAccountLocale(const AccountId& account_id, + void DoUpdateAccountLocale(const std::string& user_id, scoped_ptr<std::string> resolved_locale); - // Removes all user preferences associated with |account_id|. - void RemoveKnownUserPrefs(const AccountId& account_id); + // Removes all user preferences associated with |user_id|. + void RemoveKnownUserPrefs(const UserID& user_id); // Indicates stage of loading user from prefs. - UserLoadStage user_loading_stage_ = STAGE_NOT_LOADED; + UserLoadStage user_loading_stage_; // True if SessionStarted() has been called. - bool session_started_ = false; + bool session_started_; // Cached flag of whether currently logged-in user is owner or not. // May be accessed on different threads, requires locking. - bool is_current_user_owner_ = false; + bool is_current_user_owner_; mutable base::Lock is_current_user_owner_lock_; // Cached flag of whether the currently logged-in user existed before this // login. - bool is_current_user_new_ = false; + bool is_current_user_new_; // Cached flag of whether the currently logged-in user is a regular user who // logged in as ephemeral. Storage of persistent information is avoided for // such users by not adding them to the persistent user list, not downloading // their custom avatars and mounting their cryptohomes using tmpfs. Defaults // to |false|. - bool is_current_user_ephemeral_regular_user_ = false; + bool is_current_user_ephemeral_regular_user_; // Cached flag indicating whether the ephemeral user policy is enabled. // Defaults to |false| if the value has not been read from trusted device // policy yet. - bool ephemeral_users_enabled_ = false; + bool ephemeral_users_enabled_; - // Cached name of device owner. Defaults to empty if the value has not + // Cached name of device owner. Defaults to empty string if the value has not // been read from trusted device policy yet. - AccountId owner_account_id_ = EmptyAccountId(); + std::string owner_email_; base::ObserverList<UserManager::Observer> observer_list_; @@ -413,17 +411,17 @@ class USER_MANAGER_EXPORT UserManagerBase : public UserManager { session_state_observer_list_; // Time at which this object was created. - base::TimeTicks manager_creation_time_ = base::TimeTicks::Now(); + base::TimeTicks manager_creation_time_; // ID of the user just added to the session that needs to be activated // as soon as user's profile is loaded. - AccountId pending_user_switch_ = EmptyAccountId(); + std::string 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. - AccountId last_session_active_account_id_ = EmptyAccountId(); - bool last_session_active_account_id_initialized_ = false; + std::string last_session_active_user_; + bool last_session_active_user_initialized_; // TaskRunner for UI thread. scoped_refptr<base::TaskRunner> task_runner_; |