Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(308)

Unified Diff: chrome/browser/profiles/profile_window.cc

Issue 1794353003: Refactor ProfileInfoCache in c/b/profiles (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/profiles/profile_window.cc
diff --git a/chrome/browser/profiles/profile_window.cc b/chrome/browser/profiles/profile_window.cc
index 54925e9fd72f43c09823fcfa20b2572954b728bd..a8c5df6b211aacb1db4a1b1b4349aeae58e0fe61 100644
--- a/chrome/browser/profiles/profile_window.cc
+++ b/chrome/browser/profiles/profile_window.cc
@@ -5,6 +5,7 @@
#include "chrome/browser/profiles/profile_window.h"
#include <stddef.h>
+
#include <string>
#include <vector>
@@ -18,6 +19,8 @@
#include "chrome/browser/browser_process.h"
#include "chrome/browser/lifetime/application_lifetime.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"
@@ -142,12 +145,13 @@ 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());
- if (!profile->IsGuestSession() &&
- cache.ProfileIsSigninRequiredAtIndex(index)) {
- UnblockExtensions(profile);
+ if (!profile->IsGuestSession()) {
+ ProfileAttributesEntry* entry;
+ if (g_browser_process->profile_manager()->GetProfileAttributesStorage().
+ GetProfileAttributesWithPath(profile->GetPath(), &entry) &&
+ entry->IsSigninRequired()) {
+ UnblockExtensions(profile);
+ }
}
#endif // defined(ENABLE_EXTENSIONS)
@@ -205,12 +209,18 @@ 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) {
- page += "#";
- page += base::SizeTToString(index);
+ // TODO(anthonyvd) : Send |profile_path_to_focus| to the user manager
+ // instead of the profile index.
+ std::vector<ProfileAttributesEntry*> entries =
+ g_browser_process->profile_manager()->GetProfileAttributesStorage().
+ GetAllProfilesAttributesSortedByName();
Mike Lerman 2016/03/18 17:10:44 This is now very fragile, as we're assuming that w
lwchkg 2016/03/19 18:48:46 Agree. Anyway I've modified that SendUserList to
Mike Lerman 2016/03/30 01:18:10 Let's wait for your other related CL to land first
lwchkg 2016/03/31 19:32:26 Sure. Will rebase later today.
+ size_t count = entries.size();
+ for (size_t i = 0; i < count; ++i) {
+ if (profile_path_to_focus == entries[i]->GetPath()) {
+ page += "#";
+ page += base::SizeTToString(i);
+ break;
+ }
}
} else if (profile_open_action ==
profiles::USER_MANAGER_SELECT_PROFILE_TASK_MANAGER) {
@@ -256,7 +266,7 @@ base::FilePath GetPathOfProfileWithEmail(ProfileManager* profile_manager,
const std::string& email) {
base::string16 profile_email = base::UTF8ToUTF16(email);
std::vector<ProfileAttributesEntry*> entries =
- profile_manager->GetProfileInfoCache().GetAllProfilesAttributes();
+ profile_manager->GetProfileAttributesStorage().GetAllProfilesAttributes();
for (ProfileAttributesEntry* entry : entries) {
if (entry->GetUserName() == profile_email)
return entry->GetPath();
@@ -320,12 +330,12 @@ bool HasProfileSwitchTargets(Profile* profile) {
void CreateAndSwitchToNewProfile(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),
profiles::GetDefaultAvatarIconUrl(placeholder_avatar_index),
base::Bind(&OpenBrowserWindowForProfile, callback, true, true),
std::string());
@@ -351,10 +361,11 @@ 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);
+ ProfileAttributesEntry* entry;
+ bool has_entry = profile_manager->GetProfileAttributesStorage().
+ GetProfileAttributesWithPath(profile_path, &entry);
+ DCHECK(has_entry);
+ entry->SetIsSigninRequired(true);
#if defined(ENABLE_EXTENSIONS)
// Profile guaranteed to exist for it to have been locked.
@@ -401,10 +412,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))
+ // Lock only when there is at least one supervised user on the machine.
+ std::vector<ProfileAttributesEntry*> entries =
+ g_browser_process->profile_manager()->GetProfileAttributesStorage().
+ GetAllProfilesAttributes();
+ for (ProfileAttributesEntry* entry : entries) {
+ if (entry->IsSupervised())
return true;
}
return false;

Powered by Google App Engine
This is Rietveld 408576698