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

Unified Diff: chrome/browser/ui/app_list/app_list_service_mac.mm

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/app_list/app_list_service_mac.mm
diff --git a/chrome/browser/ui/app_list/app_list_service_mac.mm b/chrome/browser/ui/app_list/app_list_service_mac.mm
index 8e448e8cde0a1c4c728ce16299c30b7bcee3fd59..27f10bc8f943b31d52a37853734c35758203924a 100644
--- a/chrome/browser/ui/app_list/app_list_service_mac.mm
+++ b/chrome/browser/ui/app_list/app_list_service_mac.mm
@@ -392,9 +392,11 @@ void AppListServiceMac::CreateForProfile(Profile* requested_profile) {
if (!window_controller_)
window_controller_.reset([[AppListWindowController alloc] init]);
- scoped_ptr<app_list::AppListViewDelegate> delegate(
- new AppListViewDelegate(profile_, GetControllerDelegate()));
- [[window_controller_ appListViewController] setDelegate:delegate.Pass()];
+ scoped_ptr<AppListViewDelegate> delegate(
+ new AppListViewDelegate(GetControllerDelegate()));
+ delegate->SetProfile(profile_);
+ [[window_controller_ appListViewController]
+ setDelegate:delegate.PassAs<app_list::AppListViewDelegate>()];
Matt Giuca 2014/08/25 04:48:46 Can you explain this line? (To me: not necessarily
tapted 2014/08/25 06:17:00 Yeah - we really should rename ::AppListViewDelega
Matt Giuca 2014/08/26 01:29:45 But you reverted the use of PassAs now?
tapted 2014/08/26 02:43:57 Yep - since the constructor is calling SetProfile,
}
void AppListServiceMac::ShowForProfile(Profile* requested_profile) {
@@ -452,6 +454,17 @@ void AppListServiceMac::CreateShortcut() {
g_browser_process->profile_manager()->user_data_dir()));
}
+void AppListServiceMac::DestroyAppList() {
+ // Due to reference counting, Mac can't guarantee that the widget is deleted,
+ // but mac supports a visible app list with a NULL profile, so there's also no
+ // need to tear it down completely.
+ DismissAppList();
+ [[window_controller_ appListViewController]
+ setDelegate:scoped_ptr<app_list::AppListViewDelegate>()];
+
+ profile_ = NULL;
+}
+
NSWindow* AppListServiceMac::GetAppListWindow() {
return [window_controller_ window];
}

Powered by Google App Engine
This is Rietveld 408576698