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

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

Issue 14923004: [Mac] AppController needs to update its "last profile" pointer when the active profile is deleted (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Drive-by fixes Created 7 years, 7 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.h ('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 a1ed001fe17b19e9026519dde70ace801855abf0..9eed51881d166956e12a5057e56493e903df49ec 100644
--- a/chrome/browser/profiles/profile_manager.cc
+++ b/chrome/browser/profiles/profile_manager.cc
@@ -1068,6 +1068,9 @@ void ProfileManager::ScheduleProfileForDeletion(
chrome::HostDesktopType desktop_type) {
DCHECK(IsMultipleProfilesEnabled());
+ bool new_last_profile_being_loaded = false;
Alexei Svitkine (slow) 2013/05/14 15:34:12 Instead of keeping track of this here, just do an
noms (inactive) 2013/06/05 18:16:38 Done.
+ size_t last_non_managed_profile_index;
+
PrefService* local_state = g_browser_process->local_state();
ProfileInfoCache& cache = GetProfileInfoCache();
if (profile_dir.BaseName().MaybeAsASCII() ==
@@ -1079,6 +1082,7 @@ void ProfileManager::ScheduleProfileForDeletion(
base::FilePath cur_path = cache.GetPathOfProfileAtIndex(i);
if (cur_path != profile_dir && !cache.ProfileIsManagedAtIndex(i)) {
last_non_managed_profile = cur_path.BaseName().MaybeAsASCII();
+ last_non_managed_profile_index = i;
break;
}
}
@@ -1102,9 +1106,39 @@ void ProfileManager::ScheduleProfileForDeletion(
false);
} else {
local_state->SetString(prefs::kProfileLastUsed, last_non_managed_profile);
+
+ // On the Mac, the browser process is not killed when all browser windows
+ // are closed, so just in case we are deleting the active profile, and no
+ // other profile has been loaded, we must pre-load a next one.
+#if defined(OS_MACOSX)
+ new_last_profile_being_loaded = true;
+ base::FilePath path = profile_info_cache_->GetPathOfProfileAtIndex(
+ last_non_managed_profile_index);
Alexei Svitkine (slow) 2013/05/14 15:34:12 If you're just going to query the path of that pro
noms (inactive) 2013/06/05 18:16:38 Done.
+ CreateProfileAsync(path,
+ base::Bind(&ProfileManager::OnNewActiveProfileLoaded,
Alexei Svitkine (slow) 2013/05/14 15:34:12 Hmm, this may be tricky. I think you should loop i
noms (inactive) 2013/06/05 18:16:38 Done most of the comments. Working on the tests.
+ base::Unretained(this),
+ profile_dir),
+ string16(),
+ string16(),
+ false);
+#endif
}
}
+ if (!new_last_profile_being_loaded)
+ FinishDeletingProfile(profile_dir);
+}
+
+void ProfileManager::OnNewActiveProfileLoaded(const base::FilePath& profile_dir,
+ Profile* profile,
+ Profile::CreateStatus status) {
+ // Ensure we only call the callback once per profile creation.
+ if (status == Profile::CREATE_STATUS_INITIALIZED)
+ FinishDeletingProfile(profile_dir);
+}
+
+void ProfileManager::FinishDeletingProfile(const base::FilePath& profile_dir) {
+ ProfileInfoCache& cache = GetProfileInfoCache();
// 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);
« no previous file with comments | « chrome/browser/profiles/profile_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698