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

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

Issue 508813002: Move ownership of the AppListViewDelegate into the AppListService (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix comments Created 6 years, 3 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 458850b294c2437e7fc8ffdaf5a6b624fa305f3d..9bf20e067f71292a057bff819a0d1a27a738aa52 100644
--- a/chrome/browser/ui/app_list/app_list_service_impl.cc
+++ b/chrome/browser/ui/app_list/app_list_service_impl.cc
@@ -15,6 +15,7 @@
#include "chrome/browser/browser_process.h"
#include "chrome/browser/browser_shutdown.h"
#include "chrome/browser/profiles/profile_manager.h"
+#include "chrome/browser/ui/app_list/app_list_view_delegate.h"
#include "chrome/browser/ui/app_list/profile_loader.h"
#include "chrome/browser/ui/app_list/profile_store.h"
#include "chrome/common/chrome_constants.h"
@@ -249,6 +250,13 @@ AppListServiceImpl::AppListServiceImpl(const CommandLine& command_line,
AppListServiceImpl::~AppListServiceImpl() {}
+AppListViewDelegate* AppListServiceImpl::GetViewDelegate(Profile* profile) {
+ if (!view_delegate_)
+ view_delegate_.reset(new AppListViewDelegate(GetControllerDelegate()));
+ view_delegate_->SetProfile(profile);
+ return view_delegate_.get();
+}
+
void AppListServiceImpl::SetAppListNextPaintCallback(void (*callback)()) {}
void AppListServiceImpl::HandleFirstRun() {}
@@ -300,14 +308,19 @@ void AppListServiceImpl::OnProfileWillBeRemoved(
local_state_->SetString(prefs::kAppListProfile,
local_state_->GetString(prefs::kProfileLastUsed));
- // The Chrome AppListViewDelegate now needs to be torn down, because:
+ // If the app list was never shown, there won't be a |view_delegate_| yet.
+ if (!view_delegate_)
+ return;
+
+ // The Chrome AppListViewDelegate now needs its profile cleared, 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.
+ // Only Mac supports showing the app list with a NULL profile, so tear down
+ // the view.
DestroyAppList();
+ view_delegate_->SetProfile(NULL);
}
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_impl_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698