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

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

Issue 8592006: Update last used profile when deleting profile (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: nit Created 9 years, 1 month 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/app_controller_mac.mm ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/profiles/profile_manager.cc
diff --git a/chrome/browser/profiles/profile_manager.cc b/chrome/browser/profiles/profile_manager.cc
index ae4fb090d41a8c7d3c84cd8cd02d73cb44953392..024efee73ac9a4a3ad02353fba3234f61e0c6d63 100644
--- a/chrome/browser/profiles/profile_manager.cc
+++ b/chrome/browser/profiles/profile_manager.cc
@@ -643,11 +643,27 @@ void ProfileManager::ScheduleProfileForDeletion(const FilePath& profile_dir) {
CreateProfileAsync(new_path, launcher);
}
+ // Update the last used profile pref before closing browser windows. This way
+ // the correct last used profile is set for any notification observers.
+ PrefService* local_state = g_browser_process->local_state();
+ std::string last_profile = local_state->GetString(prefs::kProfileLastUsed);
+ if (profile_dir.BaseName().MaybeAsASCII() == last_profile) {
+ for (size_t i = 0; i < cache.GetNumberOfProfiles(); ++i) {
+ FilePath cur_path = cache.GetPathOfProfileAtIndex(i);
+ if (cur_path != profile_dir) {
+ local_state->SetString(
+ prefs::kProfileLastUsed, cur_path.BaseName().MaybeAsASCII());
+ break;
+ }
+ }
+ }
+
// 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);
if (profile)
BrowserList::CloseAllBrowsersWithProfile(profile);
+
QueueProfileDirectoryForDeletion(profile_dir);
cache.DeleteProfileFromCache(profile_dir);
}
« no previous file with comments | « chrome/browser/app_controller_mac.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698