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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/ash/chrome_shell_delegate.h" 5 #include "chrome/browser/ui/ash/chrome_shell_delegate.h"
6 6
7 #include "apps/app_window.h" 7 #include "apps/app_window.h"
8 #include "apps/app_window_registry.h" 8 #include "apps/app_window_registry.h"
9 #include "ash/content_support/gpu_support_impl.h" 9 #include "ash/content_support/gpu_support_impl.h"
10 #include "ash/magnifier/magnifier_constants.h" 10 #include "ash/magnifier/magnifier_constants.h"
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 content::BrowserContext* ChromeShellDelegate::GetActiveBrowserContext() { 100 content::BrowserContext* ChromeShellDelegate::GetActiveBrowserContext() {
101 #if defined(OS_CHROMEOS) 101 #if defined(OS_CHROMEOS)
102 DCHECK(user_manager::UserManager::Get()->GetLoggedInUsers().size()); 102 DCHECK(user_manager::UserManager::Get()->GetLoggedInUsers().size());
103 #endif 103 #endif
104 return ProfileManager::GetActiveUserProfile(); 104 return ProfileManager::GetActiveUserProfile();
105 } 105 }
106 106
107 app_list::AppListViewDelegate* 107 app_list::AppListViewDelegate*
108 ChromeShellDelegate::CreateAppListViewDelegate() { 108 ChromeShellDelegate::CreateAppListViewDelegate() {
109 DCHECK(ash::Shell::HasInstance()); 109 DCHECK(ash::Shell::HasInstance());
110 // Shell will own the created delegate, and the delegate will own 110 // Shell will own the created delegate (transitively via app list).
111 // the controller. 111 // Ownership of the controller delegate remains with the AppListService.
112 return new AppListViewDelegate( 112 AppListControllerDelegate* controller_delegate =
113 Profile::FromBrowserContext(GetActiveBrowserContext()), 113 AppListService::Get(chrome::HOST_DESKTOP_TYPE_ASH)
114 AppListService::Get(chrome::HOST_DESKTOP_TYPE_ASH)-> 114 ->GetControllerDelegate();
115 GetControllerDelegate()); 115 AppListViewDelegate* view_delegate =
116 new AppListViewDelegate(controller_delegate);
117 view_delegate->SetProfile(
118 Profile::FromBrowserContext(GetActiveBrowserContext()));
119 return view_delegate;
116 } 120 }
117 121
118 ash::ShelfDelegate* ChromeShellDelegate::CreateShelfDelegate( 122 ash::ShelfDelegate* ChromeShellDelegate::CreateShelfDelegate(
119 ash::ShelfModel* model) { 123 ash::ShelfModel* model) {
120 if (!shelf_delegate_) { 124 if (!shelf_delegate_) {
121 shelf_delegate_ = ChromeLauncherController::CreateInstance(NULL, model); 125 shelf_delegate_ = ChromeLauncherController::CreateInstance(NULL, model);
122 shelf_delegate_->Init(); 126 shelf_delegate_->Init();
123 } 127 }
124 return shelf_delegate_; 128 return shelf_delegate_;
125 } 129 }
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 165
162 void ChromeShellDelegate::AddVirtualKeyboardStateObserver( 166 void ChromeShellDelegate::AddVirtualKeyboardStateObserver(
163 ash::VirtualKeyboardStateObserver* observer) { 167 ash::VirtualKeyboardStateObserver* observer) {
164 keyboard_state_observer_list_.AddObserver(observer); 168 keyboard_state_observer_list_.AddObserver(observer);
165 } 169 }
166 170
167 void ChromeShellDelegate::RemoveVirtualKeyboardStateObserver( 171 void ChromeShellDelegate::RemoveVirtualKeyboardStateObserver(
168 ash::VirtualKeyboardStateObserver* observer) { 172 ash::VirtualKeyboardStateObserver* observer) {
169 keyboard_state_observer_list_.RemoveObserver(observer); 173 keyboard_state_observer_list_.RemoveObserver(observer);
170 } 174 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698