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

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

Issue 11968034: Enable profile switching for standalone App Launcher via the Settings App. (Closed) Base URL: git://nomatter.syd/chromium/src.git@master
Patch Set: respond to comments Created 7 years, 11 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_manager.cc
diff --git a/chrome/browser/profiles/profile_manager.cc b/chrome/browser/profiles/profile_manager.cc
index 714c2883aa4fb51c8e8260838dcdd9d41b9d6c9c..ccf1b75cbb67458b2d7fc123abda39f856c8e81f 100644
--- a/chrome/browser/profiles/profile_manager.cc
+++ b/chrome/browser/profiles/profile_manager.cc
@@ -310,17 +310,21 @@ Profile* ProfileManager::GetLastUsedProfile(const FilePath& user_data_dir) {
return GetDefaultProfile(user_data_dir);
#endif
+ return GetProfile(GetLastUsedProfilePath(user_data_dir));
+}
+
+FilePath ProfileManager::GetLastUsedProfilePath(const FilePath& user_data_dir) {
FilePath last_used_profile_dir(user_data_dir);
- std::string last_profile_used;
+ std::string last_used_profile;
PrefService* local_state = g_browser_process->local_state();
DCHECK(local_state);
- if (local_state->HasPrefPath(prefs::kProfileLastUsed))
- last_profile_used = local_state->GetString(prefs::kProfileLastUsed);
- last_used_profile_dir = last_profile_used.empty() ?
- last_used_profile_dir.AppendASCII(chrome::kInitialProfile) :
- last_used_profile_dir.AppendASCII(last_profile_used);
- return GetProfile(last_used_profile_dir);
+ if (local_state->HasPrefPath(prefs::kProfileLastUsed)) {
+ return last_used_profile_dir.AppendASCII(
+ local_state->GetString(prefs::kProfileLastUsed));
+ }
+
+ return last_used_profile_dir.AppendASCII(chrome::kInitialProfile);
}
std::vector<Profile*> ProfileManager::GetLastOpenedProfiles(
@@ -840,6 +844,9 @@ void ProfileManager::CreateMultiProfileAsync(
// static
void ProfileManager::RegisterPrefs(PrefServiceSimple* prefs) {
+#if defined(ENABLE_APP_LIST)
+ prefs->RegisterStringPref(prefs::kAppListProfile, "");
sail 2013/01/23 16:55:24 This should go in the app list code base. Not prof
koz (OOO until 15th September) 2013/01/25 00:32:46 Done.
+#endif
prefs->RegisterStringPref(prefs::kProfileLastUsed, "");
prefs->RegisterIntegerPref(prefs::kProfilesNumCreated, 1);
prefs->RegisterListPref(prefs::kProfilesLastActive);
@@ -992,6 +999,18 @@ void ProfileManager::ScheduleProfileForDeletion(
}
}
+#if defined(ENABLE_APP_LIST)
+ // If the profile the app list uses just got deleted, reset it to the last
+ // used profile.
+ // TODO(koz): Manage the kAppListProfile preference not in this class.
+ std::string app_list_last_profile = local_state->GetString(
sail 2013/01/23 16:55:24 same, don't put your feature code here if you need
koz (OOO until 15th September) 2013/01/25 00:32:46 Done.
+ prefs::kAppListProfile);
+ if (profile_dir.BaseName().MaybeAsASCII() == app_list_last_profile) {
+ local_state->SetString(prefs::kAppListProfile,
+ local_state->GetString(prefs::kProfileLastUsed));
+ }
+#endif
+
// TODO(sail): Due to bug 88586 we don't delete the profile instance. Once we
// start deleting the profile instance we need to close background apps too.
Profile* profile = GetProfileByPath(profile_dir);

Powered by Google App Engine
This is Rietveld 408576698