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

Unified Diff: chrome/browser/ui/app_list/app_list_service_impl.cc

Issue 492163002: Fix Profile* lifetime issues in Chrome's AppListViewDelegate (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add constructor comment Created 6 years, 4 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/ui/app_list/app_list_service_impl.cc
diff --git a/chrome/browser/ui/app_list/app_list_service_impl.cc b/chrome/browser/ui/app_list/app_list_service_impl.cc
index cd59dea6d955f87ba5d7014de5b362295f21d234..8020d5d60fb8d5456b2e531d2b09f46aaefc129e 100644
--- a/chrome/browser/ui/app_list/app_list_service_impl.cc
+++ b/chrome/browser/ui/app_list/app_list_service_impl.cc
@@ -284,17 +284,31 @@ void AppListServiceImpl::SetProfilePath(const base::FilePath& profile_path) {
void AppListServiceImpl::CreateShortcut() {}
-// We need to watch for profile removal to keep kAppListProfile updated.
void AppListServiceImpl::OnProfileWillBeRemoved(
const base::FilePath& profile_path) {
- // If the profile the app list uses just got deleted, reset it to the last
- // used profile.
+ // We need to watch for profile removal to keep kAppListProfile updated, for
+ // the case that the deleted profile is being used by the app list.
std::string app_list_last_profile = local_state_->GetString(
prefs::kAppListProfile);
- if (profile_path.BaseName().MaybeAsASCII() == app_list_last_profile) {
- local_state_->SetString(prefs::kAppListProfile,
- local_state_->GetString(prefs::kProfileLastUsed));
- }
+ if (profile_path.BaseName().MaybeAsASCII() != app_list_last_profile)
+ return;
+
+ // Switch the app list over to a valid profile.
+ // Before ProfileInfoCache::DeleteProfileFromCache() calls this function,
+ // ProfileManager::ScheduleProfileForDeletion() will have checked to see if
+ // the deleted profile was also "last used", and updated that setting with
+ // something valid.
+ local_state_->SetString(prefs::kAppListProfile,
+ local_state_->GetString(prefs::kProfileLastUsed));
+
+ // The Chrome AppListViewDelegate now needs to be torn down, because:
+ // 1. it has many references to the profile and can't be profile-keyed, and
+ // 2. the last used profile might not be loaded yet.
+ // - this loading is sometimes done by the ProfileManager asynchronously,
+ // so the app list can't just switch to that.
+ // Currently, the AppListViewDelegate is owned by the platform-specific
+ // AppListView, so just force-close the window.
+ DestroyAppList();
}
void AppListServiceImpl::Show() {
« no previous file with comments | « chrome/browser/ui/app_list/app_list_service_impl.h ('k') | chrome/browser/ui/app_list/app_list_service_interactive_uitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698