| Index: chrome/browser/ui/cocoa/app_list/app_list_controller_cocoa.mm
|
| diff --git a/chrome/browser/ui/cocoa/app_list/app_list_controller_cocoa.mm b/chrome/browser/ui/cocoa/app_list/app_list_controller_cocoa.mm
|
| index 85c362d2163440a42ece6277be03ec15a5018bbd..5b0635fdbe508316b1b2b8fe7abd8ef6bbba44c3 100644
|
| --- a/chrome/browser/ui/cocoa/app_list/app_list_controller_cocoa.mm
|
| +++ b/chrome/browser/ui/cocoa/app_list/app_list_controller_cocoa.mm
|
| @@ -5,9 +5,11 @@
|
| #include "base/bind.h"
|
| #include "base/lazy_instance.h"
|
| #include "base/memory/scoped_nsobject.h"
|
| +#include "base/memory/singleton.h"
|
| #include "base/message_loop.h"
|
| +#include "chrome/browser/ui/app_list/app_list_service.h"
|
| +#include "chrome/browser/ui/app_list/app_list_service_mac.h"
|
| #include "chrome/browser/ui/app_list/app_list_controller_delegate.h"
|
| -#include "chrome/browser/ui/app_list/app_list_util.h"
|
| #include "chrome/browser/ui/app_list/app_list_view_delegate.h"
|
| #include "chrome/browser/ui/extensions/application_launch.h"
|
| #import "ui/app_list/cocoa/apps_grid_controller.h"
|
| @@ -21,22 +23,32 @@ namespace {
|
|
|
| // The AppListController class manages global resources needed for the app
|
| // list to operate, and controls when the app list is opened and closed.
|
| -class AppListController {
|
| +class AppListControllerCocoa : public AppListService {
|
| public:
|
| - AppListController() {}
|
| - ~AppListController() {}
|
| + virtual ~AppListControllerCocoa() {}
|
| +
|
| + static AppListControllerCocoa* GetInstance() {
|
| + return Singleton<AppListControllerCocoa,
|
| + LeakySingletonTraits<AppListControllerCocoa> >::get();
|
| + }
|
|
|
| void CreateAppList(Profile* profile);
|
| - void ShowAppList(Profile* profile);
|
| - void DismissAppList();
|
| - bool IsAppListVisible() const;
|
| +
|
| + // AppListService overrides:
|
| + virtual void ShowAppList(Profile* profile) OVERRIDE;
|
| + virtual void DismissAppList() OVERRIDE;
|
| + virtual bool IsAppListVisible() const;
|
|
|
| NSWindow* GetNativeWindow();
|
|
|
| private:
|
| + friend struct DefaultSingletonTraits<AppListControllerCocoa>;
|
| +
|
| + AppListControllerCocoa() {}
|
| +
|
| scoped_nsobject<AppListWindowController> window_controller_;
|
|
|
| - DISALLOW_COPY_AND_ASSIGN(AppListController);
|
| + DISALLOW_COPY_AND_ASSIGN(AppListControllerCocoa);
|
| };
|
|
|
| class AppListControllerDelegateCocoa : public AppListControllerDelegate {
|
| @@ -60,19 +72,16 @@ class AppListControllerDelegateCocoa : public AppListControllerDelegate {
|
| DISALLOW_COPY_AND_ASSIGN(AppListControllerDelegateCocoa);
|
| };
|
|
|
| -base::LazyInstance<AppListController>::Leaky g_app_list_controller =
|
| - LAZY_INSTANCE_INITIALIZER;
|
| -
|
| AppListControllerDelegateCocoa::AppListControllerDelegateCocoa() {}
|
|
|
| AppListControllerDelegateCocoa::~AppListControllerDelegateCocoa() {}
|
|
|
| void AppListControllerDelegateCocoa::DismissView() {
|
| - g_app_list_controller.Get().DismissAppList();
|
| + AppListControllerCocoa::GetInstance()->DismissAppList();
|
| }
|
|
|
| gfx::NativeWindow AppListControllerDelegateCocoa::GetAppListWindow() {
|
| - return g_app_list_controller.Get().GetNativeWindow();
|
| + return AppListControllerCocoa::GetInstance()->GetNativeWindow();
|
| }
|
|
|
| bool AppListControllerDelegateCocoa::CanPin() {
|
| @@ -95,7 +104,7 @@ void AppListControllerDelegateCocoa::LaunchApp(
|
| profile, extension, NEW_FOREGROUND_TAB));
|
| }
|
|
|
| -void AppListController::CreateAppList(Profile* profile) {
|
| +void AppListControllerCocoa::CreateAppList(Profile* profile) {
|
| scoped_ptr<app_list::AppListViewDelegate> delegate(
|
| new AppListViewDelegate(new AppListControllerDelegateCocoa(), profile));
|
| scoped_nsobject<AppsGridController> content(
|
| @@ -104,65 +113,34 @@ void AppListController::CreateAppList(Profile* profile) {
|
| [[AppListWindowController alloc] initWithGridController:content]);
|
| }
|
|
|
| -void AppListController::ShowAppList(Profile* profile) {
|
| +void AppListControllerCocoa::ShowAppList(Profile* profile) {
|
| if (!window_controller_)
|
| CreateAppList(profile);
|
|
|
| [[window_controller_ window] makeKeyAndOrderFront:nil];
|
| }
|
|
|
| -void AppListController::DismissAppList() {
|
| +void AppListControllerCocoa::DismissAppList() {
|
| if (!window_controller_)
|
| return;
|
|
|
| [[window_controller_ window] close];
|
| }
|
|
|
| -bool AppListController::IsAppListVisible() const {
|
| +bool AppListControllerCocoa::IsAppListVisible() const {
|
| return [[window_controller_ window] isVisible];
|
| }
|
|
|
| -NSWindow* AppListController::GetNativeWindow() {
|
| +NSWindow* AppListControllerCocoa::GetNativeWindow() {
|
| return [window_controller_ window];
|
| }
|
|
|
| } // namespace
|
|
|
| -
|
| namespace chrome {
|
|
|
| -void InitAppList(Profile* profile) {
|
| - // TODO(tapted): AppList warmup code coes here.
|
| -}
|
| -
|
| -void ShowAppList(Profile* profile) {
|
| - g_app_list_controller.Get().ShowAppList(profile);
|
| -}
|
| -
|
| -void NotifyAppListOfBeginExtensionInstall(
|
| - Profile* profile,
|
| - const std::string& extension_id,
|
| - const std::string& extension_name,
|
| - const gfx::ImageSkia& installing_icon) {
|
| -}
|
| -
|
| -void NotifyAppListOfDownloadProgress(
|
| - Profile* profile,
|
| - const std::string& extension_id,
|
| - int percent_downloaded) {
|
| -}
|
| -
|
| -void NotifyAppListOfExtensionInstallFailure(
|
| - Profile* profile,
|
| - const std::string& extension_id) {
|
| -}
|
| -
|
| -void DismissAppList() {
|
| - g_app_list_controller.Get().DismissAppList();
|
| -}
|
| -
|
| -bool IsAppListVisible() {
|
| - return g_app_list_controller.Get().IsAppListVisible();
|
| +AppListService* GetAppListServiceMac() {
|
| + return AppListControllerCocoa::GetInstance();
|
| }
|
|
|
| } // namespace chrome
|
|
|