1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome/browser/ui/app_list/app_list_service_ash.h"
8 #include "base/files/file_path.h"
9 #include "base/memory/singleton.h"
10 #include "chrome/browser/profiles/profile.h"
11 #include "chrome/browser/ui/app_list/app_list_service_impl.h"
12 #include "chrome/browser/ui/ash/app_list/app_list_controller_ash.h"
13 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h"
17 class AppListServiceAsh : public AppListServiceImpl {
19 static AppListServiceAsh* GetInstance() {
20 return Singleton<AppListServiceAsh,
21 LeakySingletonTraits<AppListServiceAsh> >::get();
25 friend struct DefaultSingletonTraits<AppListServiceAsh>;
27 AppListServiceAsh() {}
29 // AppListService overrides:
30 virtual base::FilePath GetProfilePath(
31 const base::FilePath& user_data_dir) OVERRIDE;
32 virtual void CreateForProfile(Profile* default_profile) OVERRIDE;
33 virtual void ShowForProfile(Profile* default_profile) OVERRIDE;
34 virtual bool IsAppListVisible() const OVERRIDE;
35 virtual void DismissAppList() OVERRIDE;
36 virtual void EnableAppList(Profile* initial_profile) OVERRIDE;
37 virtual gfx::NativeWindow GetAppListWindow() OVERRIDE;
38 virtual Profile* GetCurrentAppListProfile() OVERRIDE;
39 virtual AppListControllerDelegate* CreateControllerDelegate() OVERRIDE;
41 DISALLOW_COPY_AND_ASSIGN(AppListServiceAsh);
44 base::FilePath AppListServiceAsh::GetProfilePath(
45 const base::FilePath& user_data_dir) {
46 return ChromeLauncherController::instance()->profile()->GetPath();
49 void AppListServiceAsh::CreateForProfile(Profile* default_profile) {}
51 void AppListServiceAsh::ShowForProfile(Profile* default_profile) {
52 // This may not work correctly if the profile passed in is different from the
53 // one the ash Shell is currently using.
54 // TODO(ananta): Handle profile changes correctly when !defined(OS_CHROMEOS).
55 if (!ash::Shell::GetInstance()->GetAppListTargetVisibility())
56 ash::Shell::GetInstance()->ToggleAppList(NULL);
59 bool AppListServiceAsh::IsAppListVisible() const {
60 return ash::Shell::GetInstance()->GetAppListTargetVisibility();
63 void AppListServiceAsh::DismissAppList() {
64 if (IsAppListVisible())
65 ash::Shell::GetInstance()->ToggleAppList(NULL);
68 void AppListServiceAsh::EnableAppList(Profile* initial_profile) {}
70 gfx::NativeWindow AppListServiceAsh::GetAppListWindow() {
71 if (ash::Shell::HasInstance())
72 return ash::Shell::GetInstance()->GetAppListWindow();
76 Profile* AppListServiceAsh::GetCurrentAppListProfile() {
77 return ChromeLauncherController::instance()->profile();
80 AppListControllerDelegate* AppListServiceAsh::CreateControllerDelegate() {
81 return new AppListControllerDelegateAsh();
88 AppListService* GetAppListServiceAsh() {
89 return AppListServiceAsh::GetInstance();
94 // Windows Ash additionally supports a native UI. See app_list_service_win.cc.
98 AppListService* AppListService::Get(chrome::HostDesktopType desktop_type) {
99 return chrome::GetAppListServiceAsh();
103 void AppListService::InitAll(Profile* initial_profile) {
104 AppListServiceAsh::GetInstance()->Init(initial_profile);
107 #endif // !defined(OS_WIN)