| Index: chrome/browser/profiles/profiles_state.cc
|
| diff --git a/chrome/browser/profiles/profiles_state.cc b/chrome/browser/profiles/profiles_state.cc
|
| index af589b1d5ca784222fdb88f4a0fb8087789bdf46..2735fc6ba4303d110fb18c9d3945d21ae6903d8a 100644
|
| --- a/chrome/browser/profiles/profiles_state.cc
|
| +++ b/chrome/browser/profiles/profiles_state.cc
|
| @@ -16,7 +16,8 @@
|
| #include "chrome/browser/profiles/gaia_info_update_service.h"
|
| #include "chrome/browser/profiles/gaia_info_update_service_factory.h"
|
| #include "chrome/browser/profiles/profile.h"
|
| -#include "chrome/browser/profiles/profile_info_cache.h"
|
| +#include "chrome/browser/profiles/profile_attributes_entry.h"
|
| +#include "chrome/browser/profiles/profile_attributes_storage.h"
|
| #include "chrome/browser/profiles/profile_manager.h"
|
| #include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
|
| #include "chrome/browser/signin/signin_error_controller_factory.h"
|
| @@ -69,11 +70,11 @@ base::string16 GetAvatarNameForProfile(const base::FilePath& profile_path) {
|
| if (profile_path == ProfileManager::GetGuestProfilePath()) {
|
| display_name = l10n_util::GetStringUTF16(IDS_GUEST_PROFILE_NAME);
|
| } else {
|
| - const ProfileInfoCache& cache =
|
| - g_browser_process->profile_manager()->GetProfileInfoCache();
|
| - size_t index = cache.GetIndexOfProfileWithPath(profile_path);
|
| + ProfileAttributesStorage& storage =
|
| + g_browser_process->profile_manager()->GetProfileAttributesStorage();
|
|
|
| - if (index == std::string::npos)
|
| + ProfileAttributesEntry* entry;
|
| + if (!storage.GetProfileAttributesWithPath(profile_path, &entry))
|
| return l10n_util::GetStringUTF16(IDS_SINGLE_PROFILE_DISPLAY_NAME);
|
|
|
| // Using the --new-avatar-menu flag, there's a couple of rules about what
|
| @@ -82,12 +83,12 @@ base::string16 GetAvatarNameForProfile(const base::FilePath& profile_path) {
|
| // IDS_SINGLE_PROFILE_DISPLAY_NAME. If the profile is signed in but is using
|
| // a default name, use the profiles's email address. Otherwise, it
|
| // will return the actual name of the profile.
|
| - const base::string16 profile_name = cache.GetNameOfProfileAtIndex(index);
|
| - const base::string16 email = cache.GetUserNameOfProfileAtIndex(index);
|
| - bool is_default_name = cache.ProfileIsUsingDefaultNameAtIndex(index) &&
|
| - cache.IsDefaultProfileName(profile_name);
|
| + const base::string16 profile_name = entry->GetName();
|
| + const base::string16 email = entry->GetUserName();
|
| + bool is_default_name = entry->IsUsingDefaultName() &&
|
| + storage.IsDefaultProfileName(profile_name);
|
|
|
| - if (cache.GetNumberOfProfiles() == 1 && is_default_name)
|
| + if (storage.GetNumberOfProfiles() == 1u && is_default_name)
|
| display_name = l10n_util::GetStringUTF16(IDS_SINGLE_PROFILE_DISPLAY_NAME);
|
| else
|
| display_name = (is_default_name && !email.empty()) ? email : profile_name;
|
| @@ -120,13 +121,13 @@ base::string16 GetProfileSwitcherTextForItem(const AvatarMenu::Item& item) {
|
|
|
| void UpdateProfileName(Profile* profile,
|
| const base::string16& new_profile_name) {
|
| - const ProfileInfoCache& cache =
|
| - g_browser_process->profile_manager()->GetProfileInfoCache();
|
| - size_t profile_index = cache.GetIndexOfProfileWithPath(profile->GetPath());
|
| - if (profile_index == std::string::npos)
|
| + ProfileAttributesEntry* entry;
|
| + if (!g_browser_process->profile_manager()->GetProfileAttributesStorage().
|
| + GetProfileAttributesWithPath(profile->GetPath(), &entry)) {
|
| return;
|
| + }
|
|
|
| - if (new_profile_name == cache.GetNameOfProfileAtIndex(profile_index))
|
| + if (new_profile_name == entry->GetName())
|
| return;
|
|
|
| // This is only called when updating the profile name through the UI,
|
| @@ -134,8 +135,8 @@ void UpdateProfileName(Profile* profile,
|
| PrefService* pref_service = profile->GetPrefs();
|
| pref_service->SetBoolean(prefs::kProfileUsingDefaultName, false);
|
|
|
| - // Updating the profile preference will cause the cache to be updated for
|
| - // this preference.
|
| + // Updating the profile preference will cause the profile attributes storage
|
| + // to be updated for this preference.
|
| pref_service->SetString(prefs::kProfileName,
|
| base::UTF16ToUTF8(new_profile_name));
|
| }
|
| @@ -161,15 +162,14 @@ bool IsRegularOrGuestSession(Browser* browser) {
|
| return profile->IsGuestSession() || !profile->IsOffTheRecord();
|
| }
|
|
|
| -bool IsProfileLocked(const base::FilePath& path) {
|
| - const ProfileInfoCache& cache =
|
| - g_browser_process->profile_manager()->GetProfileInfoCache();
|
| - size_t profile_index = cache.GetIndexOfProfileWithPath(path);
|
| -
|
| - if (profile_index == std::string::npos)
|
| +bool IsProfileLocked(const base::FilePath& profile_path) {
|
| + ProfileAttributesEntry* entry;
|
| + if (!g_browser_process->profile_manager()->GetProfileAttributesStorage().
|
| + GetProfileAttributesWithPath(profile_path, &entry)) {
|
| return false;
|
| + }
|
|
|
| - return cache.ProfileIsSigninRequiredAtIndex(profile_index);
|
| + return entry->IsSigninRequired();
|
| }
|
|
|
| void UpdateIsProfileLockEnabledIfNeeded(Profile* profile) {
|
| @@ -211,9 +211,13 @@ bool SetActiveProfileToGuestIfLocked() {
|
| if (active_profile_path == guest_path)
|
| return true;
|
|
|
| - const ProfileInfoCache& cache = profile_manager->GetProfileInfoCache();
|
| - size_t index = cache.GetIndexOfProfileWithPath(active_profile_path);
|
| - if (!cache.ProfileIsSigninRequiredAtIndex(index))
|
| + ProfileAttributesEntry* entry;
|
| + bool has_entry =
|
| + g_browser_process->profile_manager()->GetProfileAttributesStorage().
|
| + GetProfileAttributesWithPath(active_profile_path, &entry);
|
| + DCHECK(has_entry);
|
| +
|
| + if (!entry->IsSigninRequired())
|
| return false;
|
|
|
| SetLastUsedProfile(guest_path.BaseName().MaybeAsASCII());
|
|
|