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

Unified Diff: chrome/browser/ui/toolbar/wrench_menu_model.cc

Issue 7155015: Store profile avatar to preferences (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: '' Created 9 years, 5 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
« no previous file with comments | « chrome/browser/profiles/profile_manager.cc ('k') | chrome/browser/ui/views/frame/browser_view.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/toolbar/wrench_menu_model.cc
===================================================================
--- chrome/browser/ui/toolbar/wrench_menu_model.cc (revision 91576)
+++ chrome/browser/ui/toolbar/wrench_menu_model.cc (working copy)
@@ -18,6 +18,7 @@
#include "chrome/browser/defaults.h"
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/profiles/profile_info_cache.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/sync/profile_sync_service.h"
#include "chrome/browser/sync/sync_ui_util.h"
@@ -227,11 +228,12 @@
}
void ProfilesSubMenuModel::Build() {
- ProfileManager* profile_manager = g_browser_process->profile_manager();
- size_t count = profile_manager->GetNumberOfProfiles();
+ ProfileInfoCache& cache =
+ g_browser_process->profile_manager()->GetProfileInfoCache();
+ size_t count = cache.GetNumberOfProfiles();
for (size_t i = 0; i < count; ++i) {
AddCheckItem(COMMAND_SWITCH_TO_PROFILE + i,
- profile_manager->GetNameOfProfileAtIndex(i));
+ cache.GetNameOfProfileAtIndex(i));
}
AddSeparator();
@@ -257,39 +259,38 @@
};
void ProfilesSubMenuModel::ExecuteCommand(int command_id) {
- ProfileManager* profile_manager = g_browser_process->profile_manager();
+ ProfileInfoCache& cache =
+ g_browser_process->profile_manager()->GetProfileInfoCache();
size_t index = command_id;
- if (index < profile_manager->GetNumberOfProfiles()) {
- FilePath userDataFolder;
- PathService::Get(chrome::DIR_USER_DATA, &userDataFolder);
- FilePath profile_path =
- profile_manager->GetFilePathOfProfileAtIndex(index, userDataFolder);
-
+ if (index < cache.GetNumberOfProfiles()) {
+ FilePath profile_path = cache.GetPathOfProfileAtIndex(index);
ProfileSwitchObserver* observer = new ProfileSwitchObserver;
// The observer is deleted by the manager when profile creation is finished.
- profile_manager->CreateProfileAsync(profile_path, observer);
+ g_browser_process->profile_manager()->CreateProfileAsync(
+ profile_path, observer);
} else {
delegate_->ExecuteCommand(command_id);
}
}
bool ProfilesSubMenuModel::IsCommandIdChecked(int command_id) const {
- ProfileManager* profile_manager = g_browser_process->profile_manager();
+ ProfileInfoCache& cache =
+ g_browser_process->profile_manager()->GetProfileInfoCache();
size_t index = command_id;
- if (index < profile_manager->GetNumberOfProfiles()) {
+ if (index < cache.GetNumberOfProfiles()) {
FilePath userDataFolder;
PathService::Get(chrome::DIR_USER_DATA, &userDataFolder);
- FilePath profile_path =
- profile_manager->GetFilePathOfProfileAtIndex(index, userDataFolder);
+ FilePath profile_path = cache.GetPathOfProfileAtIndex(index);
return browser_->GetProfile()->GetPath() == profile_path;
}
return delegate_->IsCommandIdChecked(command_id);
}
bool ProfilesSubMenuModel::IsCommandIdEnabled(int command_id) const {
- ProfileManager* profile_manager = g_browser_process->profile_manager();
+ ProfileInfoCache& cache =
+ g_browser_process->profile_manager()->GetProfileInfoCache();
size_t index = command_id;
- if (index < profile_manager->GetNumberOfProfiles())
+ if (index < cache.GetNumberOfProfiles())
return true;
return delegate_->IsCommandIdEnabled(command_id);
}
@@ -297,9 +298,10 @@
bool ProfilesSubMenuModel::GetAcceleratorForCommandId(
int command_id,
ui::Accelerator* accelerator) {
- ProfileManager* profile_manager = g_browser_process->profile_manager();
+ ProfileInfoCache& cache =
+ g_browser_process->profile_manager()->GetProfileInfoCache();
size_t index = command_id;
- if (index < profile_manager->GetNumberOfProfiles())
+ if (index < cache.GetNumberOfProfiles())
return false;
return delegate_->GetAcceleratorForCommandId(command_id, accelerator);
}
@@ -571,7 +573,9 @@
l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME);
const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess();
if (browser_command_line.HasSwitch(switches::kMultiProfiles)) {
- if (g_browser_process->profile_manager()->GetNumberOfProfiles() > 1) {
+ ProfileInfoCache& cache =
+ g_browser_process->profile_manager()->GetProfileInfoCache();
+ if (cache.GetNumberOfProfiles() > 1) {
profiles_sub_menu_model_.reset(new ProfilesSubMenuModel(this, browser_));
AddSubMenu(IDC_PROFILE_MENU, l10n_util::GetStringFUTF16(
IDS_PROFILES_MENU, short_product_name),
« no previous file with comments | « chrome/browser/profiles/profile_manager.cc ('k') | chrome/browser/ui/views/frame/browser_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698