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

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: Fix whitespace 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
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..5d6cc2e30b04c4f3376d592949eef3a82d150b97 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;
+ 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,40 @@ 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)
Roger Tawa OOO till Jul 10th 2013/05/14 14:38:40 # should be at start of line.
noms (inactive) 2013/05/14 15:06:48 Done.
+ new_last_profile_being_loaded = true;
+ base::FilePath path = profile_info_cache_->GetPathOfProfileAtIndex(
+ last_non_managed_profile_index);
+ CreateProfileAsync(path,
+ base::Bind(&ProfileManager::OnNewActiveProfileLoaded,
+ base::Unretained(this),
+ profile_dir),
Roger Tawa OOO till Jul 10th 2013/05/14 14:38:40 Why does FinishDeletingProfile() need to be deferr
noms (inactive) 2013/05/14 14:49:38 Above, we're deleting the only profile in the list
+ 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);
+ }
Roger Tawa OOO till Jul 10th 2013/05/14 14:38:40 Don't need { and }.
noms (inactive) 2013/05/14 15:06:48 Done.
+}
+
+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);
« chrome/browser/app_controller_mac.mm ('K') | « chrome/browser/profiles/profile_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698