Chromium Code Reviews| Index: chrome/browser/profiles/profile_window.cc |
| diff --git a/chrome/browser/profiles/profile_window.cc b/chrome/browser/profiles/profile_window.cc |
| index 90b4a353a72c3cdac755418a72c60639a111cf9d..812d6f13e3bb731761dbaadbce7f60cc0b1058a8 100644 |
| --- a/chrome/browser/profiles/profile_window.cc |
| +++ b/chrome/browser/profiles/profile_window.cc |
| @@ -14,6 +14,8 @@ |
| #include "chrome/browser/lifetime/application_lifetime.h" |
| #include "chrome/browser/pref_service_flags_storage.h" |
| #include "chrome/browser/profiles/profile.h" |
| +#include "chrome/browser/profiles/profile_attributes_entry.h" |
| +#include "chrome/browser/profiles/profile_attributes_storage.h" |
| #include "chrome/browser/profiles/profile_avatar_icon_util.h" |
| #include "chrome/browser/profiles/profile_manager.h" |
| #include "chrome/browser/signin/account_reconcilor_factory.h" |
| @@ -131,11 +133,16 @@ void OpenBrowserWindowForProfile( |
| // The signin bit will still be set if the profile is being unlocked and the |
| // browser window for it is opening. As part of this unlock process, unblock |
| // all the extensions. |
| - const ProfileInfoCache& cache = |
| - g_browser_process->profile_manager()->GetProfileInfoCache(); |
| - int index = cache.GetIndexOfProfileWithPath(profile->GetPath()); |
| + ProfileAttributesStorage& storage = |
| + g_browser_process->profile_manager()->GetProfileAttributesStorage(); |
| + ProfileAttributesEntry* entry = nullptr; |
| if (!profile->IsGuestSession() && |
| - cache.ProfileIsSigninRequiredAtIndex(index)) { |
| + !storage.GetProfileAttributesWithPath(profile->GetPath(), &entry)) { |
| + NOTREACHED(); |
| + return; |
| + } |
| + |
| + if (!profile->IsGuestSession() && entry->IsSigninRequired()) { |
|
Mike Lerman
2015/08/06 16:06:20
you don't need to verify IsGuestSession() twice (h
|
| UnblockExtensions(profile); |
| } |
| #endif // defined(ENABLE_EXTENSIONS) |
| @@ -197,12 +204,23 @@ void OnUserManagerSystemProfileCreated( |
| if (tutorial_mode == profiles::USER_MANAGER_TUTORIAL_OVERVIEW) { |
| page += profiles::kUserManagerDisplayTutorial; |
| } else if (!profile_path_to_focus.empty()) { |
| - const ProfileInfoCache& cache = |
| - g_browser_process->profile_manager()->GetProfileInfoCache(); |
| - size_t index = cache.GetIndexOfProfileWithPath(profile_path_to_focus); |
| - if (index != std::string::npos) { |
| + |
| + ProfileAttributesStorage& storage = |
| + g_browser_process->profile_manager()->GetProfileAttributesStorage(); |
| + std::vector<ProfileAttributesEntry*> entries = |
| + storage.GetAllProfilesAttributes(); |
| + ProfileAttributesEntry* entry_to_focus; |
| + if (storage.GetProfileAttributesWithPath(profile_path_to_focus, |
| + &entry_to_focus)) { |
| + // The index of an entry in an hypothetically sorted collection is equal |
| + // to the count of items that compare as smaller than said entry, since |
| + // it's impossible for entries to compare as equal. |
| + auto index_to_focus = std::count_if(entries.begin(), entries.end(), |
| + [&entry_to_focus] (ProfileAttributesEntry* other) { |
| + return other->LessThan(*entry_to_focus); |
| + }); |
| page += "#"; |
| - page += base::IntToString(index); |
| + page += base::IntToString(index_to_focus); |
|
Mike Lerman
2015/08/06 16:06:20
well... this is annoying. We probably shouldn't us
|
| } |
| } else if (profile_open_action == |
| profiles::USER_MANAGER_SELECT_PROFILE_TASK_MANAGER) { |
| @@ -319,12 +337,12 @@ bool HasProfileSwitchTargets(Profile* profile) { |
| void CreateAndSwitchToNewProfile(chrome::HostDesktopType desktop_type, |
| ProfileManager::CreateCallback callback, |
| ProfileMetrics::ProfileAdd metric) { |
| - ProfileInfoCache& cache = |
| - g_browser_process->profile_manager()->GetProfileInfoCache(); |
| + ProfileAttributesStorage& storage = |
| + g_browser_process->profile_manager()->GetProfileAttributesStorage(); |
| int placeholder_avatar_index = profiles::GetPlaceholderAvatarIndex(); |
| ProfileManager::CreateMultiProfileAsync( |
| - cache.ChooseNameForNewProfile(placeholder_avatar_index), |
| + storage.ChooseNameForNewProfile(placeholder_avatar_index), |
| base::UTF8ToUTF16(profiles::GetDefaultAvatarIconUrl( |
| placeholder_avatar_index)), |
| base::Bind(&OpenBrowserWindowForProfile, |
| @@ -355,10 +373,13 @@ void CloseGuestProfileWindows() { |
| void LockBrowserCloseSuccess(const base::FilePath& profile_path) { |
| ProfileManager* profile_manager = g_browser_process->profile_manager(); |
| - ProfileInfoCache* cache = &profile_manager->GetProfileInfoCache(); |
| - cache->SetProfileSigninRequiredAtIndex( |
| - cache->GetIndexOfProfileWithPath(profile_path), true); |
| + ProfileAttributesStorage& storage = |
| + profile_manager->GetProfileAttributesStorage(); |
| + ProfileAttributesEntry* entry; |
| + if (storage.GetProfileAttributesWithPath(profile_path, &entry)) { |
| + entry->SetIsSigninRequired(true); |
| + } |
| #if defined(ENABLE_EXTENSIONS) |
| // Profile guaranteed to exist for it to have been locked. |
| @@ -405,10 +426,12 @@ bool IsLockAvailable(Profile* profile) { |
| return false; |
| } |
| - const ProfileInfoCache& cache = |
| - g_browser_process->profile_manager()->GetProfileInfoCache(); |
| - for (size_t i = 0; i < cache.GetNumberOfProfiles(); ++i) { |
| - if (cache.ProfileIsSupervisedAtIndex(i)) |
| + ProfileAttributesStorage& storage = |
| + g_browser_process->profile_manager()->GetProfileAttributesStorage(); |
| + std::vector<ProfileAttributesEntry*> entries = |
| + storage.GetAllProfilesAttributes(); |
| + for (ProfileAttributesEntry* entry: entries) { |
|
Mike Lerman
2015/08/06 16:06:20
entry<space>:
|
| + if (entry->IsSupervised()) |
| return true; |
| } |
| return false; |