Chromium Code Reviews| 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 217f2ac706dc8b531a5adb038cecbf45b474aa0c..d166e69a33fc936b8fa0f472cf5060b9b7b97721 100644 |
| --- a/chrome/browser/ui/app_list/app_list_service_mac.mm |
| +++ b/chrome/browser/ui/app_list/app_list_service_mac.mm |
| @@ -37,6 +37,7 @@ |
| #include "grit/google_chrome_strings.h" |
| #import "ui/app_list/cocoa/app_list_view_controller.h" |
| #import "ui/app_list/cocoa/app_list_window_controller.h" |
| +#include "ui/app_list/search_box_model.h" |
| #include "ui/base/l10n/l10n_util.h" |
| #include "ui/base/resource/resource_bundle.h" |
| #include "ui/gfx/display.h" |
| @@ -97,6 +98,8 @@ class AppListControllerDelegateCocoa : public AppListControllerDelegate { |
| virtual void LaunchApp(Profile* profile, |
| const extensions::Extension* extension, |
| int event_flags) OVERRIDE; |
| + virtual void ShowForProfileByPath( |
| + const base::FilePath& profile_path) OVERRIDE; |
| DISALLOW_COPY_AND_ASSIGN(AppListControllerDelegateCocoa); |
| }; |
| @@ -268,6 +271,13 @@ void AppListControllerDelegateCocoa::LaunchApp( |
| profile, extension, NEW_FOREGROUND_TAB)); |
| } |
| +void AppListControllerDelegateCocoa::ShowForProfileByPath( |
| + const base::FilePath& profile_path) { |
| + AppListService* service = AppListServiceMac::GetInstance(); |
| + service->SetProfilePath(profile_path); |
| + service->Show(); |
| +} |
| + |
| enum DockLocation { |
| DockLocationOtherDisplay, |
| DockLocationBottom, |
| @@ -439,15 +449,18 @@ void AppListServiceMac::CreateForProfile(Profile* requested_profile) { |
| if (profile() == requested_profile) |
| return; |
| - // The Objective C objects might be released at some unknown point in the |
| - // future, so explicitly clear references to C++ objects. |
| - [[window_controller_ appListViewController] |
| - setDelegate:scoped_ptr<app_list::AppListViewDelegate>()]; |
| - |
| SetProfile(requested_profile); |
| + |
| + if (window_controller_) { |
| + // Clear the search box. |
| + [[window_controller_ appListViewController] searchBoxModel] |
| + ->SetText(base::string16()); |
| + } else { |
| + window_controller_.reset([[AppListWindowController alloc] init]); |
| + } |
| + |
| scoped_ptr<app_list::AppListViewDelegate> delegate( |
| new AppListViewDelegate(new AppListControllerDelegateCocoa(), profile())); |
| - window_controller_.reset([[AppListWindowController alloc] init]); |
| [[window_controller_ appListViewController] setDelegate:delegate.Pass()]; |
| } |
| @@ -457,14 +470,12 @@ void AppListServiceMac::ShowForProfile(Profile* requested_profile) { |
| InvalidatePendingProfileLoads(); |
| - if (IsAppListVisible() && (requested_profile == profile())) { |
| + if (requested_profile == profile()) { |
| ShowWindowNearDock(); |
| return; |
| } |
| SetProfilePath(requested_profile->GetPath()); |
| - |
| - DismissAppList(); |
| CreateForProfile(requested_profile); |
| ShowWindowNearDock(); |
| } |
| @@ -534,6 +545,8 @@ void AppListServiceMac::OnShimSetHidden(apps::AppShimHandler::Host* host, |
| void AppListServiceMac::OnShimQuit(apps::AppShimHandler::Host* host) {} |
| void AppListServiceMac::ShowWindowNearDock() { |
| + if (IsAppListVisible()) |
| + return; |
|
tapted
2013/09/16 20:46:44
nit: blank line after early return
calamity
2013/09/17 00:09:26
Done.
|
| NSWindow* window = GetAppListWindow(); |
| DCHECK(window); |
| NSPoint target_origin; |