| Index: components/user_manager/user_manager_base.cc
|
| diff --git a/components/user_manager/user_manager_base.cc b/components/user_manager/user_manager_base.cc
|
| index 3e11ff871068bace74871ce0cb3bbe828229cce5..430d94c048e99b4ec6c0e8201a260a6ad03a1fa5 100644
|
| --- a/components/user_manager/user_manager_base.cc
|
| +++ b/components/user_manager/user_manager_base.cc
|
| @@ -96,12 +96,12 @@ const char kReauthReasonKey[] = "reauth_reason";
|
| const int kLogoutToLoginDelayMaxSec = 1800;
|
|
|
| // Callback that is called after user removal is complete.
|
| -void OnRemoveUserComplete(const std::string& user_email,
|
| +void OnRemoveUserComplete(const UserID& user_id,
|
| bool success,
|
| cryptohome::MountError return_code) {
|
| // Log the error, but there's not much we can do.
|
| if (!success) {
|
| - LOG(ERROR) << "Removal of cryptohome for " << user_email
|
| + LOG(ERROR) << "Removal of cryptohome for " << user_id.GetUserEmail()
|
| << " failed, return code: " << return_code;
|
| }
|
| }
|
| @@ -117,12 +117,12 @@ bool UserMatches(const UserID& user_id, const base::DictionaryValue& dict) {
|
| std::string value;
|
|
|
| bool has_email = dict.GetString(kCanonicalEmail, &value);
|
| - if (has_email && user_id == value)
|
| + if (has_email && user_id == UserID::FromUserEmail(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 && user_id == value)
|
| + if (has_gaia_id && user_id.GetGaiaId() == value)
|
| return true;
|
|
|
| return false;
|
| @@ -130,7 +130,7 @@ bool UserMatches(const UserID& user_id, const base::DictionaryValue& dict) {
|
|
|
| // Fills relevant |dict| values based on |user_id|.
|
| void UpdateIdentity(const UserID& user_id, base::DictionaryValue& dict) {
|
| - dict.SetString(kCanonicalEmail, user_id);
|
| + dict.SetString(kCanonicalEmail, user_id.GetUserEmail());
|
| }
|
|
|
| } // namespace
|
| @@ -160,7 +160,10 @@ UserManagerBase::UserManagerBase(
|
| is_current_user_new_(false),
|
| is_current_user_ephemeral_regular_user_(false),
|
| ephemeral_users_enabled_(false),
|
| + owner_id_(std::string(), std::string()),
|
| manager_creation_time_(base::TimeTicks::Now()),
|
| + pending_user_switch_(std::string(), std::string()),
|
| + last_session_active_user_(std::string(), std::string()),
|
| last_session_active_user_initialized_(false),
|
| task_runner_(task_runner),
|
| blocking_task_runner_(blocking_task_runner),
|
| @@ -198,17 +201,17 @@ const UserList& UserManagerBase::GetLRULoggedInUsers() const {
|
| return lru_logged_in_users_;
|
| }
|
|
|
| -const std::string& UserManagerBase::GetOwnerEmail() const {
|
| - return owner_email_;
|
| +const UserID& UserManagerBase::GetOwnerID() const {
|
| + return owner_id_;
|
| }
|
|
|
| -void UserManagerBase::UserLoggedIn(const std::string& user_id,
|
| +void UserManagerBase::UserLoggedIn(const UserID& user_id,
|
| const std::string& username_hash,
|
| bool browser_restart) {
|
| DCHECK(task_runner_->RunsTasksOnCurrentThread());
|
|
|
| if (!last_session_active_user_initialized_) {
|
| - last_session_active_user_ = GetLocalState()->GetString(kLastActiveUser);
|
| + last_session_active_user_ = UserID::FromUserEmail(GetLocalState()->GetString(kLastActiveUser));
|
| last_session_active_user_initialized_ = true;
|
| }
|
|
|
| @@ -226,10 +229,10 @@ void UserManagerBase::UserLoggedIn(const std::string& user_id,
|
| return;
|
| }
|
|
|
| - if (user_id == chromeos::login::kGuestUserName) {
|
| + if (user_id == chromeos::login::GetGuestUserID()) {
|
| GuestUserLoggedIn();
|
| } else if (IsKioskApp(user_id)) {
|
| - KioskAppLoggedIn(user_id);
|
| + KioskAppLoggedIn(user_id.GetUserEmail());
|
| } else if (IsDemoApp(user_id)) {
|
| DemoAccountLoggedIn();
|
| } else {
|
| @@ -239,12 +242,12 @@ void UserManagerBase::UserLoggedIn(const std::string& user_id,
|
| PublicAccountUserLoggedIn(user);
|
| } else if ((user && user->GetType() == USER_TYPE_SUPERVISED) ||
|
| (!user &&
|
| - gaia::ExtractDomainName(user_id) ==
|
| + gaia::ExtractDomainName(user_id.GetUserEmail()) ==
|
| chromeos::login::kSupervisedUserDomain)) {
|
| SupervisedUserLoggedIn(user_id);
|
| } else if (browser_restart && IsPublicAccountMarkedForRemoval(user_id)) {
|
| PublicAccountUserLoggedIn(User::CreatePublicAccountUser(user_id));
|
| - } else if (user_id != GetOwnerEmail() && !user &&
|
| + } else if (user_id != owner_id_ && !user &&
|
| (AreEphemeralUsersEnabled() || browser_restart)) {
|
| RegularUserLoggedInAsEphemeral(user_id);
|
| } else {
|
| @@ -271,13 +274,13 @@ void UserManagerBase::UserLoggedIn(const std::string& user_id,
|
| "UserManager.LoginUserType", active_user_->GetType(), NUM_USER_TYPES);
|
|
|
| GetLocalState()->SetString(
|
| - kLastLoggedInGaiaUser, active_user_->HasGaiaAccount() ? user_id : "");
|
| + kLastLoggedInGaiaUser, active_user_->HasGaiaAccount() ? user_id.GetUserEmail() : "");
|
|
|
| NotifyOnLogin();
|
| PerformPostUserLoggedInActions(browser_restart);
|
| }
|
|
|
| -void UserManagerBase::SwitchActiveUser(const std::string& user_id) {
|
| +void UserManagerBase::SwitchActiveUser(const UserID& user_id) {
|
| User* user = FindUserAndModify(user_id);
|
| if (!user) {
|
| NOTREACHED() << "Switching to a non-existing user";
|
| @@ -317,7 +320,7 @@ void UserManagerBase::SwitchToLastActiveUser() {
|
| if (last_session_active_user_.empty())
|
| return;
|
|
|
| - if (GetActiveUser()->email() != last_session_active_user_)
|
| + if (GetActiveUser()->GetUserID() != last_session_active_user_)
|
| SwitchActiveUser(last_session_active_user_);
|
|
|
| // Make sure that this function gets run only once.
|
| @@ -338,7 +341,7 @@ void UserManagerBase::SessionStarted() {
|
| }
|
| }
|
|
|
| -void UserManagerBase::RemoveUser(const std::string& user_id,
|
| +void UserManagerBase::RemoveUser(const UserID& user_id,
|
| RemoveUserDelegate* delegate) {
|
| DCHECK(task_runner_->RunsTasksOnCurrentThread());
|
|
|
| @@ -348,36 +351,36 @@ void UserManagerBase::RemoveUser(const std::string& user_id,
|
| RemoveUserInternal(user_id, delegate);
|
| }
|
|
|
| -void UserManagerBase::RemoveUserInternal(const std::string& user_email,
|
| +void UserManagerBase::RemoveUserInternal(const UserID& user_id,
|
| RemoveUserDelegate* delegate) {
|
| - RemoveNonOwnerUserInternal(user_email, delegate);
|
| + RemoveNonOwnerUserInternal(user_id, delegate);
|
| }
|
|
|
| -void UserManagerBase::RemoveNonOwnerUserInternal(const std::string& user_email,
|
| +void UserManagerBase::RemoveNonOwnerUserInternal(const UserID& user_id,
|
| RemoveUserDelegate* delegate) {
|
| if (delegate)
|
| - delegate->OnBeforeUserRemoved(user_email);
|
| - RemoveUserFromList(user_email);
|
| + delegate->OnBeforeUserRemoved(user_id);
|
| + RemoveUserFromList(user_id);
|
| cryptohome::AsyncMethodCaller::GetInstance()->AsyncRemove(
|
| - user_email, base::Bind(&OnRemoveUserComplete, user_email));
|
| + user_id, base::Bind(&OnRemoveUserComplete, user_id));
|
|
|
| if (delegate)
|
| - delegate->OnUserRemoved(user_email);
|
| + delegate->OnUserRemoved(user_id);
|
| }
|
|
|
| -void UserManagerBase::RemoveUserFromList(const std::string& user_id) {
|
| +void UserManagerBase::RemoveUserFromList(const UserID& user_id) {
|
| DCHECK(task_runner_->RunsTasksOnCurrentThread());
|
| RemoveNonCryptohomeData(user_id);
|
| if (user_loading_stage_ == STAGE_LOADED) {
|
| DeleteUser(RemoveRegularOrSupervisedUserFromList(user_id));
|
| } else if (user_loading_stage_ == STAGE_LOADING) {
|
| - DCHECK(gaia::ExtractDomainName(user_id) ==
|
| + DCHECK(gaia::ExtractDomainName(user_id.GetUserEmail()) ==
|
| chromeos::login::kSupervisedUserDomain ||
|
| 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(user_id), NULL);
|
| + users_update->Remove(base::StringValue(user_id.GetUserEmail()), NULL);
|
| } else {
|
| NOTREACHED() << "Users are not loaded yet.";
|
| return;
|
| @@ -387,20 +390,20 @@ void UserManagerBase::RemoveUserFromList(const std::string& user_id) {
|
| GetLocalState()->CommitPendingWrite();
|
| }
|
|
|
| -bool UserManagerBase::IsKnownUser(const std::string& user_id) const {
|
| +bool UserManagerBase::IsKnownUser(const UserID& user_id) const {
|
| return FindUser(user_id) != NULL;
|
| }
|
|
|
| -const User* UserManagerBase::FindUser(const std::string& user_id) const {
|
| +const User* UserManagerBase::FindUser(const UserID& user_id) const {
|
| DCHECK(task_runner_->RunsTasksOnCurrentThread());
|
| - if (active_user_ && active_user_->email() == user_id)
|
| + if (active_user_ && active_user_->GetUserID() == user_id)
|
| return active_user_;
|
| return FindUserInList(user_id);
|
| }
|
|
|
| -User* UserManagerBase::FindUserAndModify(const std::string& user_id) {
|
| +User* UserManagerBase::FindUserAndModify(const UserID& user_id) {
|
| DCHECK(task_runner_->RunsTasksOnCurrentThread());
|
| - if (active_user_ && active_user_->email() == user_id)
|
| + if (active_user_ && active_user_->GetUserID() == user_id)
|
| return active_user_;
|
| return FindUserInListAndModify(user_id);
|
| }
|
| @@ -431,7 +434,7 @@ const User* UserManagerBase::GetPrimaryUser() const {
|
| }
|
|
|
| void UserManagerBase::SaveUserOAuthStatus(
|
| - const std::string& user_id,
|
| + const UserID& user_id,
|
| User::OAuthTokenStatus oauth_token_status) {
|
| DCHECK(task_runner_->RunsTasksOnCurrentThread());
|
|
|
| @@ -448,11 +451,11 @@ void UserManagerBase::SaveUserOAuthStatus(
|
| DictionaryPrefUpdate oauth_status_update(GetLocalState(),
|
| kUserOAuthTokenStatus);
|
| oauth_status_update->SetWithoutPathExpansion(
|
| - user_id,
|
| + user_id.GetUserEmail(),
|
| new base::FundamentalValue(static_cast<int>(oauth_token_status)));
|
| }
|
|
|
| -void UserManagerBase::SaveForceOnlineSignin(const std::string& user_id,
|
| +void UserManagerBase::SaveForceOnlineSignin(const UserID& user_id,
|
| bool force_online_signin) {
|
| DCHECK(task_runner_->RunsTasksOnCurrentThread());
|
|
|
| @@ -463,11 +466,11 @@ void UserManagerBase::SaveForceOnlineSignin(const std::string& user_id,
|
|
|
| DictionaryPrefUpdate force_online_update(GetLocalState(),
|
| kUserForceOnlineSignin);
|
| - force_online_update->SetBooleanWithoutPathExpansion(user_id,
|
| + force_online_update->SetBooleanWithoutPathExpansion(user_id.GetUserEmail(),
|
| force_online_signin);
|
| }
|
|
|
| -void UserManagerBase::SaveUserDisplayName(const std::string& user_id,
|
| +void UserManagerBase::SaveUserDisplayName(const UserID& user_id,
|
| const base::string16& display_name) {
|
| DCHECK(task_runner_->RunsTasksOnCurrentThread());
|
|
|
| @@ -480,24 +483,24 @@ void UserManagerBase::SaveUserDisplayName(const std::string& user_id,
|
| DictionaryPrefUpdate display_name_update(GetLocalState(),
|
| kUserDisplayName);
|
| display_name_update->SetWithoutPathExpansion(
|
| - user_id, new base::StringValue(display_name));
|
| + user_id.GetUserEmail(), new base::StringValue(display_name));
|
| }
|
| }
|
| }
|
|
|
| base::string16 UserManagerBase::GetUserDisplayName(
|
| - const std::string& user_id) const {
|
| + const UserID& user_id) const {
|
| const User* user = FindUser(user_id);
|
| return user ? user->display_name() : base::string16();
|
| }
|
|
|
| -void UserManagerBase::SaveUserDisplayEmail(const std::string& user_id,
|
| +void UserManagerBase::SaveUserDisplayEmail(const UserID& user_id,
|
| const std::string& display_email) {
|
| DCHECK(task_runner_->RunsTasksOnCurrentThread());
|
|
|
| User* user = FindUserAndModify(user_id);
|
| if (!user) {
|
| - LOG(ERROR) << "User not found: " << user_id;
|
| + LOG(ERROR) << "User not found: " << user_id.GetUserEmail();
|
| return; // Ignore if there is no such user.
|
| }
|
|
|
| @@ -510,22 +513,22 @@ void UserManagerBase::SaveUserDisplayEmail(const std::string& user_id,
|
|
|
| DictionaryPrefUpdate display_email_update(GetLocalState(), kUserDisplayEmail);
|
| display_email_update->SetWithoutPathExpansion(
|
| - user_id, new base::StringValue(display_email));
|
| + user_id.GetUserEmail(), new base::StringValue(display_email));
|
| }
|
|
|
| std::string UserManagerBase::GetUserDisplayEmail(
|
| - const std::string& user_id) const {
|
| + const UserID& user_id) const {
|
| const User* user = FindUser(user_id);
|
| - return user ? user->display_email() : user_id;
|
| + return user ? user->display_email() : user_id.GetUserEmail();
|
| }
|
|
|
| -void UserManagerBase::SaveUserType(const std::string& user_id,
|
| +void UserManagerBase::SaveUserType(const UserID& user_id,
|
| const UserType& user_type) {
|
| DCHECK(task_runner_->RunsTasksOnCurrentThread());
|
|
|
| User* user = FindUserAndModify(user_id);
|
| if (!user) {
|
| - LOG(ERROR) << "User not found: " << user_id;
|
| + LOG(ERROR) << "User not found: " << user_id.GetUserEmail();
|
| return; // Ignore if there is no such user.
|
| }
|
|
|
| @@ -536,34 +539,34 @@ void UserManagerBase::SaveUserType(const std::string& user_id,
|
|
|
| DictionaryPrefUpdate user_type_update(GetLocalState(), kUserType);
|
| user_type_update->SetWithoutPathExpansion(
|
| - user_id, new base::FundamentalValue(static_cast<int>(user_type)));
|
| + user_id.GetUserEmail(), new base::FundamentalValue(static_cast<int>(user_type)));
|
| GetLocalState()->CommitPendingWrite();
|
| }
|
|
|
| -void UserManagerBase::UpdateUsingSAML(const std::string& user_id,
|
| +void UserManagerBase::UpdateUsingSAML(const UserID& user_id,
|
| const bool using_saml) {
|
| SetKnownUserBooleanPref(user_id, kUsingSAMLKey, using_saml);
|
| }
|
|
|
| -bool UserManagerBase::FindUsingSAML(const std::string& user_id) {
|
| +bool UserManagerBase::FindUsingSAML(const UserID& user_id) {
|
| bool using_saml;
|
| if (GetKnownUserBooleanPref(user_id, kUsingSAMLKey, &using_saml))
|
| return using_saml;
|
| return false;
|
| }
|
|
|
| -void UserManagerBase::UpdateReauthReason(const std::string& user_id,
|
| +void UserManagerBase::UpdateReauthReason(const UserID& user_id,
|
| const int reauth_reason) {
|
| SetKnownUserIntegerPref(user_id, kReauthReasonKey, reauth_reason);
|
| }
|
|
|
| -bool UserManagerBase::FindReauthReason(const std::string& user_id,
|
| +bool UserManagerBase::FindReauthReason(const UserID& user_id,
|
| int* out_value) {
|
| return GetKnownUserIntegerPref(user_id, kReauthReasonKey, out_value);
|
| }
|
|
|
| void UserManagerBase::UpdateUserAccountData(
|
| - const std::string& user_id,
|
| + const UserID& user_id,
|
| const UserAccountData& account_data) {
|
| DCHECK(task_runner_->RunsTasksOnCurrentThread());
|
|
|
| @@ -575,7 +578,7 @@ void UserManagerBase::UpdateUserAccountData(
|
| if (!IsUserNonCryptohomeDataEphemeral(user_id)) {
|
| DictionaryPrefUpdate given_name_update(GetLocalState(), kUserGivenName);
|
| given_name_update->SetWithoutPathExpansion(
|
| - user_id, new base::StringValue(given_name));
|
| + user_id.GetUserEmail(), new base::StringValue(given_name));
|
| }
|
| }
|
|
|
| @@ -627,7 +630,7 @@ bool UserManagerBase::IsCurrentUserNew() const {
|
| bool UserManagerBase::IsCurrentUserNonCryptohomeDataEphemeral() const {
|
| DCHECK(task_runner_->RunsTasksOnCurrentThread());
|
| return IsUserLoggedIn() &&
|
| - IsUserNonCryptohomeDataEphemeral(GetLoggedInUser()->email());
|
| + IsUserNonCryptohomeDataEphemeral(GetLoggedInUser()->GetUserID());
|
| }
|
|
|
| bool UserManagerBase::CanCurrentUserLock() const {
|
| @@ -674,7 +677,7 @@ bool UserManagerBase::IsLoggedInAsKioskApp() const {
|
| bool UserManagerBase::IsLoggedInAsStub() const {
|
| DCHECK(task_runner_->RunsTasksOnCurrentThread());
|
| return IsUserLoggedIn() &&
|
| - active_user_->email() == chromeos::login::kStubUser;
|
| + active_user_->GetUserID() == chromeos::login::GetStubUserID();
|
| }
|
|
|
| bool UserManagerBase::IsSessionStarted() const {
|
| @@ -683,16 +686,16 @@ bool UserManagerBase::IsSessionStarted() const {
|
| }
|
|
|
| bool UserManagerBase::IsUserNonCryptohomeDataEphemeral(
|
| - const std::string& user_id) const {
|
| + const UserID& user_id) const {
|
| // Data belonging to the guest and stub users is always ephemeral.
|
| - if (user_id == chromeos::login::kGuestUserName ||
|
| - user_id == chromeos::login::kStubUser) {
|
| + if (user_id == chromeos::login::GetGuestUserID() ||
|
| + user_id == chromeos::login::GetStubUserID()) {
|
| 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 (user_id == GetOwnerEmail() || UserExistsInList(user_id) ||
|
| + if (user_id == owner_id_ || UserExistsInList(user_id) ||
|
| IsPublicAccountMarkedForRemoval(user_id)) {
|
| return false;
|
| }
|
| @@ -702,7 +705,7 @@ bool UserManagerBase::IsUserNonCryptohomeDataEphemeral(
|
| // policy was enabled.
|
| // - or -
|
| // b) The user logged into any other account type.
|
| - if (IsUserLoggedIn() && (user_id == GetLoggedInUser()->email()) &&
|
| + if (IsUserLoggedIn() && (user_id == GetLoggedInUser()->GetUserID()) &&
|
| (is_current_user_ephemeral_regular_user_ ||
|
| !IsLoggedInAsUserWithGaiaAccount())) {
|
| return true;
|
| @@ -763,7 +766,7 @@ bool UserManagerBase::CanUserBeRemoved(const User* user) const {
|
| for (UserList::const_iterator it = logged_in_users_.begin();
|
| it != logged_in_users_.end();
|
| ++it) {
|
| - if ((*it)->email() == user->email())
|
| + if ((*it)->GetUserID() == user->GetUserID())
|
| return false;
|
| }
|
|
|
| @@ -782,19 +785,19 @@ void UserManagerBase::SetIsCurrentUserNew(bool is_new) {
|
| is_current_user_new_ = is_new;
|
| }
|
|
|
| -bool UserManagerBase::HasPendingBootstrap(const std::string& user_id) const {
|
| +bool UserManagerBase::HasPendingBootstrap(const UserID& user_id) const {
|
| return false;
|
| }
|
|
|
| -void UserManagerBase::SetOwnerEmail(std::string owner_user_id) {
|
| - owner_email_ = owner_user_id;
|
| +void UserManagerBase::SetOwnerID(const UserID& owner_user_id) {
|
| + owner_id_ = owner_user_id;
|
| }
|
|
|
| -const std::string& UserManagerBase::GetPendingUserSwitchID() const {
|
| +const user_manager::UserID& UserManagerBase::GetPendingUserSwitchID() const {
|
| return pending_user_switch_;
|
| }
|
|
|
| -void UserManagerBase::SetPendingUserSwitchID(std::string user_id) {
|
| +void UserManagerBase::SetPendingUserSwitchID(const user_manager::UserID& user_id) {
|
| pending_user_switch_ = user_id;
|
| }
|
|
|
| @@ -837,20 +840,21 @@ void UserManagerBase::EnsureUsersLoaded() {
|
| it != regular_users.end();
|
| ++it) {
|
| User* user = NULL;
|
| + const UserID user_id(UserID::FromUserEmail(*it));
|
| const std::string domain = gaia::ExtractDomainName(*it);
|
| if (domain == chromeos::login::kSupervisedUserDomain) {
|
| - user = User::CreateSupervisedUser(*it);
|
| + user = User::CreateSupervisedUser(user_id);
|
| } else {
|
| - user = User::CreateRegularUser(*it);
|
| + user = User::CreateRegularUser(user_id);
|
| int user_type;
|
| if (prefs_user_types->GetIntegerWithoutPathExpansion(*it, &user_type) &&
|
| user_type == USER_TYPE_CHILD) {
|
| ChangeUserChildStatus(user, true /* is child */);
|
| }
|
| }
|
| - user->set_oauth_token_status(LoadUserOAuthStatus(*it));
|
| - user->set_force_online_signin(LoadForceOnlineSignin(*it));
|
| - user->set_using_saml(FindUsingSAML(*it));
|
| + user->set_oauth_token_status(LoadUserOAuthStatus(user_id));
|
| + user->set_force_online_signin(LoadForceOnlineSignin(user_id));
|
| + user->set_using_saml(FindUsingSAML(user_id));
|
| users_.push_back(user);
|
|
|
| base::string16 display_name;
|
| @@ -881,29 +885,29 @@ UserList& UserManagerBase::GetUsersAndModify() {
|
| return users_;
|
| }
|
|
|
| -const User* UserManagerBase::FindUserInList(const std::string& user_id) const {
|
| +const User* UserManagerBase::FindUserInList(const UserID& user_id) const {
|
| const UserList& users = GetUsers();
|
| for (UserList::const_iterator it = users.begin(); it != users.end(); ++it) {
|
| - if ((*it)->email() == user_id)
|
| + if ((*it)->GetUserID() == user_id)
|
| return *it;
|
| }
|
| return NULL;
|
| }
|
|
|
| -bool UserManagerBase::UserExistsInList(const std::string& user_id) const {
|
| +bool UserManagerBase::UserExistsInList(const UserID& 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) && (user_id == email))
|
| + if (user_list->GetString(i, &email) && (user_id == UserID::FromUserEmail(email)))
|
| return true;
|
| }
|
| return false;
|
| }
|
|
|
| -User* UserManagerBase::FindUserInListAndModify(const std::string& user_id) {
|
| +User* UserManagerBase::FindUserInListAndModify(const UserID& user_id) {
|
| UserList& users = GetUsersAndModify();
|
| for (UserList::iterator it = users.begin(); it != users.end(); ++it) {
|
| - if ((*it)->email() == user_id)
|
| + if ((*it)->GetUserID() == user_id)
|
| return *it;
|
| }
|
| return NULL;
|
| @@ -917,11 +921,11 @@ void UserManagerBase::GuestUserLoggedIn() {
|
| void UserManagerBase::AddUserRecord(User* user) {
|
| // Add the user to the front of the user list.
|
| ListPrefUpdate prefs_users_update(GetLocalState(), kRegularUsers);
|
| - prefs_users_update->Insert(0, new base::StringValue(user->email()));
|
| + prefs_users_update->Insert(0, new base::StringValue(user->GetUserID().GetUserEmail()));
|
| users_.insert(users_.begin(), user);
|
| }
|
|
|
| -void UserManagerBase::RegularUserLoggedIn(const std::string& user_id) {
|
| +void UserManagerBase::RegularUserLoggedIn(const UserID& user_id) {
|
| // Remove the user from the user list.
|
| active_user_ = RemoveRegularOrSupervisedUserFromList(user_id);
|
|
|
| @@ -930,7 +934,7 @@ void UserManagerBase::RegularUserLoggedIn(const std::string& user_id) {
|
| if (IsCurrentUserNew()) {
|
| active_user_ = User::CreateRegularUser(user_id);
|
| active_user_->set_oauth_token_status(LoadUserOAuthStatus(user_id));
|
| - SaveUserDisplayName(active_user_->email(),
|
| + SaveUserDisplayName(active_user_->GetUserID(),
|
| base::UTF8ToUTF16(active_user_->GetAccountName(true)));
|
| }
|
|
|
| @@ -941,7 +945,7 @@ void UserManagerBase::RegularUserLoggedIn(const std::string& user_id) {
|
| }
|
|
|
| void UserManagerBase::RegularUserLoggedInAsEphemeral(
|
| - const std::string& user_id) {
|
| + const UserID& user_id) {
|
| DCHECK(task_runner_->RunsTasksOnCurrentThread());
|
| SetIsCurrentUserNew(true);
|
| is_current_user_ephemeral_regular_user_ = true;
|
| @@ -957,14 +961,14 @@ void UserManagerBase::NotifyOnLogin() {
|
| }
|
|
|
| User::OAuthTokenStatus UserManagerBase::LoadUserOAuthStatus(
|
| - const std::string& user_id) const {
|
| + const UserID& 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(user_id,
|
| + prefs_oauth_status->GetIntegerWithoutPathExpansion(user_id.GetUserEmail(),
|
| &oauth_token_status)) {
|
| User::OAuthTokenStatus status =
|
| static_cast<User::OAuthTokenStatus>(oauth_token_status);
|
| @@ -975,40 +979,40 @@ User::OAuthTokenStatus UserManagerBase::LoadUserOAuthStatus(
|
| return User::OAUTH_TOKEN_STATUS_UNKNOWN;
|
| }
|
|
|
| -bool UserManagerBase::LoadForceOnlineSignin(const std::string& user_id) const {
|
| +bool UserManagerBase::LoadForceOnlineSignin(const UserID& 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(user_id,
|
| + prefs_force_online->GetBooleanWithoutPathExpansion(user_id.GetUserEmail(),
|
| &force_online_signin);
|
| }
|
| return force_online_signin;
|
| }
|
|
|
| -void UserManagerBase::RemoveNonCryptohomeData(const std::string& user_id) {
|
| +void UserManagerBase::RemoveNonCryptohomeData(const UserID& user_id) {
|
| PrefService* prefs = GetLocalState();
|
| DictionaryPrefUpdate prefs_display_name_update(prefs, kUserDisplayName);
|
| - prefs_display_name_update->RemoveWithoutPathExpansion(user_id, NULL);
|
| + prefs_display_name_update->RemoveWithoutPathExpansion(user_id.GetUserEmail(), NULL);
|
|
|
| DictionaryPrefUpdate prefs_given_name_update(prefs, kUserGivenName);
|
| - prefs_given_name_update->RemoveWithoutPathExpansion(user_id, NULL);
|
| + prefs_given_name_update->RemoveWithoutPathExpansion(user_id.GetUserEmail(), NULL);
|
|
|
| DictionaryPrefUpdate prefs_display_email_update(prefs, kUserDisplayEmail);
|
| - prefs_display_email_update->RemoveWithoutPathExpansion(user_id, NULL);
|
| + prefs_display_email_update->RemoveWithoutPathExpansion(user_id.GetUserEmail(), NULL);
|
|
|
| DictionaryPrefUpdate prefs_oauth_update(prefs, kUserOAuthTokenStatus);
|
| - prefs_oauth_update->RemoveWithoutPathExpansion(user_id, NULL);
|
| + prefs_oauth_update->RemoveWithoutPathExpansion(user_id.GetUserEmail(), NULL);
|
|
|
| DictionaryPrefUpdate prefs_force_online_update(prefs, kUserForceOnlineSignin);
|
| - prefs_force_online_update->RemoveWithoutPathExpansion(user_id, NULL);
|
| + prefs_force_online_update->RemoveWithoutPathExpansion(user_id.GetUserEmail(), NULL);
|
|
|
| RemoveKnownUserPrefs(user_id);
|
|
|
| - std::string last_active_user = GetLocalState()->GetString(kLastActiveUser);
|
| - if (user_id == last_active_user)
|
| + const std::string last_active_user = GetLocalState()->GetString(kLastActiveUser);
|
| + if (user_id == UserID::FromUserEmail(last_active_user))
|
| GetLocalState()->SetString(kLastActiveUser, std::string());
|
| }
|
|
|
| @@ -1164,18 +1168,17 @@ std::string UserManagerBase::GetKnownUserDeviceId(const UserID& user_id) {
|
| }
|
|
|
| User* UserManagerBase::RemoveRegularOrSupervisedUserFromList(
|
| - const std::string& user_id) {
|
| + const UserID& user_id) {
|
| ListPrefUpdate prefs_users_update(GetLocalState(), kRegularUsers);
|
| prefs_users_update->Clear();
|
| User* user = NULL;
|
| for (UserList::iterator it = users_.begin(); it != users_.end();) {
|
| - const std::string user_email = (*it)->email();
|
| - if (user_email == user_id) {
|
| + if ((*it)->GetUserID() == user_id) {
|
| user = *it;
|
| it = users_.erase(it);
|
| } else {
|
| if ((*it)->HasGaiaAccount() || (*it)->IsSupervised())
|
| - prefs_users_update->Append(new base::StringValue(user_email));
|
| + prefs_users_update->Append(new base::StringValue((*it)->GetUserID().GetUserEmail()));
|
| ++it;
|
| }
|
| }
|
| @@ -1222,7 +1225,7 @@ void UserManagerBase::ChangeUserChildStatus(User* user, bool is_child) {
|
| if (user->IsSupervised() == is_child)
|
| return;
|
| user->SetIsChild(is_child);
|
| - SaveUserType(user->email(), is_child ? user_manager::USER_TYPE_CHILD
|
| + SaveUserType(user->GetUserID(), is_child ? user_manager::USER_TYPE_CHILD
|
| : user_manager::USER_TYPE_REGULAR);
|
| FOR_EACH_OBSERVER(UserManager::UserSessionStateObserver,
|
| session_state_observer_list_,
|
| @@ -1263,7 +1266,7 @@ void UserManagerBase::UpdateLoginState() {
|
| }
|
|
|
| void UserManagerBase::SetLRUUser(User* user) {
|
| - GetLocalState()->SetString(kLastActiveUser, user->email());
|
| + GetLocalState()->SetString(kLastActiveUser, user->GetUserID().GetUserEmail());
|
| GetLocalState()->CommitPendingWrite();
|
|
|
| UserList::iterator it =
|
| @@ -1273,7 +1276,7 @@ void UserManagerBase::SetLRUUser(User* user) {
|
| lru_logged_in_users_.insert(lru_logged_in_users_.begin(), user);
|
| }
|
|
|
| -void UserManagerBase::SendGaiaUserLoginMetrics(const std::string& user_id) {
|
| +void UserManagerBase::SendGaiaUserLoginMetrics(const UserID& 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(
|
| @@ -1282,7 +1285,7 @@ void UserManagerBase::SendGaiaUserLoginMetrics(const std::string& user_id) {
|
| GetLocalState()->GetString(kLastLoggedInGaiaUser);
|
| const base::TimeDelta time_to_login =
|
| base::TimeTicks::Now() - manager_creation_time_;
|
| - if (!last_email.empty() && user_id != last_email &&
|
| + if (!last_email.empty() && user_id != UserID::FromUserEmail(last_email) &&
|
| time_to_login.InSeconds() <= kLogoutToLoginDelayMaxSec) {
|
| UMA_HISTOGRAM_CUSTOM_COUNTS("UserManager.LogoutToLoginDelay",
|
| time_to_login.InSeconds(),
|
| @@ -1293,7 +1296,7 @@ void UserManagerBase::SendGaiaUserLoginMetrics(const std::string& user_id) {
|
| }
|
| }
|
|
|
| -void UserManagerBase::UpdateUserAccountLocale(const std::string& user_id,
|
| +void UserManagerBase::UpdateUserAccountLocale(const UserID& user_id,
|
| const std::string& locale) {
|
| scoped_ptr<std::string> resolved_locale(new std::string());
|
| if (!locale.empty() && locale != GetApplicationLocale()) {
|
| @@ -1315,7 +1318,7 @@ void UserManagerBase::UpdateUserAccountLocale(const std::string& user_id,
|
| }
|
|
|
| void UserManagerBase::DoUpdateAccountLocale(
|
| - const std::string& user_id,
|
| + const UserID& user_id,
|
| scoped_ptr<std::string> resolved_locale) {
|
| User* user = FindUserAndModify(user_id);
|
| if (user && resolved_locale)
|
|
|