Chromium Code Reviews| 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 5fa2dd4dd51e46cb3b0d08d170d5313465556f9a..012a97a88b64deb9c903173240d4fbc4d784668e 100644 |
| --- a/components/user_manager/user_manager_base.cc |
| +++ b/components/user_manager/user_manager_base.cc |
| @@ -58,9 +58,9 @@ const char kUserOAuthTokenStatus[] = "OAuthTokenStatus"; |
| const char kUserForceOnlineSignin[] = "UserForceOnlineSignin"; |
| // A string pref containing the ID of the last user who logged in if it was |
| -// a regular user or an empty string if it was another type of user (guest, |
| -// kiosk, public account, etc.). |
| -const char kLastLoggedInRegularUser[] = "LastLoggedInRegularUser"; |
| +// a user with gaia account (regular) or an empty string if it was another type |
| +// of user (guest, kiosk, public account, etc.). |
| +const char kLastLoggedInGaiaUser[] = "LastLoggedInRegularUser"; |
| // A string pref containing the ID of the last active user. |
| // In case of browser crash, this pref will be used to set active user after |
| @@ -93,7 +93,7 @@ void ResolveLocale(const std::string& raw_locale, |
| // static |
| void UserManagerBase::RegisterPrefs(PrefRegistrySimple* registry) { |
| registry->RegisterListPref(kRegularUsers); |
| - registry->RegisterStringPref(kLastLoggedInRegularUser, std::string()); |
| + registry->RegisterStringPref(kLastLoggedInGaiaUser, std::string()); |
| registry->RegisterDictionaryPref(kUserDisplayName); |
| registry->RegisterDictionaryPref(kUserGivenName); |
| registry->RegisterDictionaryPref(kUserDisplayEmail); |
| @@ -218,16 +218,15 @@ void UserManagerBase::UserLoggedIn(const std::string& user_id, |
| if (!primary_user_) { |
| primary_user_ = active_user_; |
| - if (primary_user_->GetType() == USER_TYPE_REGULAR) |
| - SendRegularUserLoginMetrics(user_id); |
| + if (primary_user_->HasGaiaAccount()) |
| + SendGaiaUserLoginMetrics(user_id); |
| } |
| UMA_HISTOGRAM_ENUMERATION( |
| "UserManager.LoginUserType", active_user_->GetType(), NUM_USER_TYPES); |
| GetLocalState()->SetString( |
| - kLastLoggedInRegularUser, |
| - (active_user_->GetType() == USER_TYPE_REGULAR) ? user_id : ""); |
| + kLastLoggedInGaiaUser, active_user_->HasGaiaAccount() ? user_id : ""); |
| NotifyOnLogin(); |
| PerformPostUserLoggedInActions(browser_restart); |
| @@ -247,7 +246,7 @@ void UserManagerBase::SwitchActiveUser(const std::string& user_id) { |
| NOTREACHED() << "Switching to a user that is not logged in"; |
| return; |
| } |
| - if (user->GetType() != USER_TYPE_REGULAR) { |
| + if (!user->HasGaiaAccount()) { |
| NOTREACHED() << "Switching to a non-regular user"; |
|
Nikita (slow)
2014/11/14 09:34:52
nit: update comment?
merkulova
2014/11/14 10:09:49
Done.
|
| return; |
| } |
| @@ -551,9 +550,15 @@ bool UserManagerBase::IsUserLoggedIn() const { |
| return active_user_; |
| } |
| -bool UserManagerBase::IsLoggedInAsRegularUser() const { |
| +bool UserManagerBase::IsLoggedInAsUserWithGaiaAccount() const { |
| DCHECK(task_runner_->RunsTasksOnCurrentThread()); |
| - return IsUserLoggedIn() && active_user_->GetType() == USER_TYPE_REGULAR; |
| + return IsUserLoggedIn() && active_user_->HasGaiaAccount(); |
| +} |
| + |
| +bool UserManagerBase::IsLoggedInAsRegularSupervisedUser() const { |
| + DCHECK(task_runner_->RunsTasksOnCurrentThread()); |
| + return IsUserLoggedIn() && active_user_->GetType() == |
| + USER_TYPE_REGULAR_SUPERVISED; |
| } |
| bool UserManagerBase::IsLoggedInAsDemoUser() const { |
| @@ -611,12 +616,13 @@ bool UserManagerBase::IsUserNonCryptohomeDataEphemeral( |
| } |
| // Data belonging to the currently logged-in user is ephemeral when: |
| - // a) The user logged into a regular account while the ephemeral users policy |
| - // was enabled. |
| + // a) The user logged into a regular gaia account while the ephemeral users |
| + // policy was enabled. |
| // - or - |
| // b) The user logged into any other account type. |
| if (IsUserLoggedIn() && (user_id == GetLoggedInUser()->email()) && |
| - (is_current_user_ephemeral_regular_user_ || !IsLoggedInAsRegularUser())) { |
| + (is_current_user_ephemeral_regular_user_ || |
| + !IsLoggedInAsUserWithGaiaAccount())) { |
| return true; |
| } |
| @@ -659,10 +665,8 @@ void UserManagerBase::NotifyLocalStateChanged() { |
| bool UserManagerBase::CanUserBeRemoved(const User* user) const { |
| // Only regular and supervised users are allowed to be manually removed. |
| - if (!user || (user->GetType() != USER_TYPE_REGULAR && |
| - user->GetType() != USER_TYPE_SUPERVISED)) { |
| + if (!user || !(user->HasGaiaAccount() || user->IsSupervised())) |
| return false; |
| - } |
| // Sanity check: we must not remove single user unless it's an enterprise |
| // device. This check may seem redundant at a first sight because |
| @@ -922,10 +926,8 @@ User* UserManagerBase::RemoveRegularOrSupervisedUserFromList( |
| user = *it; |
| it = users_.erase(it); |
| } else { |
| - if ((*it)->GetType() == USER_TYPE_REGULAR || |
| - (*it)->GetType() == USER_TYPE_SUPERVISED) { |
| + if ((*it)->HasGaiaAccount() || (*it)->IsSupervised()) |
| prefs_users_update->Append(new base::StringValue(user_email)); |
| - } |
| ++it; |
| } |
| } |
| @@ -1009,13 +1011,13 @@ void UserManagerBase::SetLRUUser(User* user) { |
| lru_logged_in_users_.insert(lru_logged_in_users_.begin(), user); |
| } |
| -void UserManagerBase::SendRegularUserLoginMetrics(const std::string& user_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 (!CommandLine::ForCurrentProcess()->HasSwitch( |
| chromeos::switches::kFirstExecAfterBoot)) { |
| const std::string last_email = |
| - GetLocalState()->GetString(kLastLoggedInRegularUser); |
| + GetLocalState()->GetString(kLastLoggedInGaiaUser); |
| const base::TimeDelta time_to_login = |
| base::TimeTicks::Now() - manager_creation_time_; |
| if (!last_email.empty() && user_id != last_email && |