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

Unified Diff: chrome/browser/ui/ash/chrome_shell_delegate.cc

Issue 492163002: Fix Profile* lifetime issues in Chrome's AppListViewDelegate (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: update unit test, cl format 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/ash/chrome_shell_delegate.cc
diff --git a/chrome/browser/ui/ash/chrome_shell_delegate.cc b/chrome/browser/ui/ash/chrome_shell_delegate.cc
index 97d0fdd2d5d481702ded47b026b50a544710493e..258206697e238b03c3d77e831d8850a503a6f8d1 100644
--- a/chrome/browser/ui/ash/chrome_shell_delegate.cc
+++ b/chrome/browser/ui/ash/chrome_shell_delegate.cc
@@ -107,12 +107,16 @@ content::BrowserContext* ChromeShellDelegate::GetActiveBrowserContext() {
app_list::AppListViewDelegate*
ChromeShellDelegate::CreateAppListViewDelegate() {
DCHECK(ash::Shell::HasInstance());
- // Shell will own the created delegate, and the delegate will own
- // the controller.
- return new AppListViewDelegate(
- Profile::FromBrowserContext(GetActiveBrowserContext()),
- AppListService::Get(chrome::HOST_DESKTOP_TYPE_ASH)->
- GetControllerDelegate());
+ // Shell will own the created delegate (transitively via app list).
+ // Ownership of the controller delegate remains with the AppListService.
+ AppListControllerDelegate* controller_delegate =
+ AppListService::Get(chrome::HOST_DESKTOP_TYPE_ASH)
+ ->GetControllerDelegate();
+ AppListViewDelegate* view_delegate =
+ new AppListViewDelegate(controller_delegate);
+ view_delegate->SetProfile(
+ Profile::FromBrowserContext(GetActiveBrowserContext()));
+ return view_delegate;
}
ash::ShelfDelegate* ChromeShellDelegate::CreateShelfDelegate(

Powered by Google App Engine
This is Rietveld 408576698