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 #ifndef CHROME_BROWSER_UI_APP_LIST_APP_LIST_SERVICE_H_
6 #define CHROME_BROWSER_UI_APP_LIST_APP_LIST_SERVICE_H_
10 #include "base/basictypes.h"
11 #include "base/compiler_specific.h"
12 #include "base/memory/ref_counted.h"
13 #include "chrome/browser/ui/host_desktop.h"
14 #include "ui/gfx/native_widget_types.h"
16 class AppListControllerDelegate
;
17 class PrefRegistrySimple
;
26 struct SpeechRecognitionSessionPreamble
;
33 class AppListService
{
35 // Source that triggers the app launcher being enabled. This is used for UMA
36 // to track discoverability of the app lancher shortcut after install. Also
37 // used to provide custom install behavior (e.g. "always" enable).
38 enum AppListEnableSource
{
39 ENABLE_NOT_RECORDED
, // Indicates app launcher not recently enabled.
40 ENABLE_FOR_APP_INSTALL
, // Triggered by a webstore packaged app install.
41 ENABLE_VIA_WEBSTORE_LINK
, // Triggered by webstore explicitly via API.
42 ENABLE_VIA_COMMAND_LINE
, // Triggered by --enable-app-list.
43 ENABLE_ON_REINSTALL_UNUSED
, // Triggered by Chrome reinstall finding pref.
44 // Unused since detecting a reinstall and
45 // detecting a pref are mutually exclusive.
46 ENABLE_SHOWN_UNDISCOVERED
, // This overrides a prior ENABLE_FOR_APP_INSTALL
47 // when the launcher is auto-shown without
48 // being "discovered" beforehand.
49 ENABLE_NUM_ENABLE_SOURCES
52 // Get the AppListService for the current platform and specified
54 static AppListService
* Get(chrome::HostDesktopType desktop_type
);
56 // Call Init for all AppListService instances on this platform.
57 static void InitAll(Profile
* initial_profile
,
58 const base::FilePath
& profile_path
);
60 static void RegisterPrefs(PrefRegistrySimple
* registry
);
62 // Initializes the AppListService, and returns true if |command_line| is for
63 // showing the app list.
64 static bool HandleLaunchCommandLine(const base::CommandLine
& command_line
,
65 Profile
* launch_profile
);
67 // Indicates that |callback| should be called next time the app list is
69 virtual void SetAppListNextPaintCallback(void (*callback
)()) = 0;
71 virtual base::FilePath
GetProfilePath(
72 const base::FilePath
& user_data_dir
) = 0;
73 virtual void SetProfilePath(const base::FilePath
& profile_path
) = 0;
75 // Show the app list for the profile configured in the user data dir for the
76 // current browser process.
77 virtual void Show() = 0;
79 // Show the app list for the given profile. If it differs from the profile the
80 // app list is currently showing, repopulate the app list and save the new
81 // profile to local prefs as the default app list profile.
82 virtual void ShowForProfile(Profile
* requested_profile
) = 0;
84 // Shows the app list, and switches to voice search. Used by always-on
86 virtual void ShowForVoiceSearch(
88 const scoped_refptr
<content::SpeechRecognitionSessionPreamble
>& preamble
)
91 // Shows the app list, and reveals the page that contains |extension_id|. This
92 // should only be called for things that show in the app list, and only when
93 // they begin or complete installing. If |start_discovery_tracking| is set,
94 // the app launcher will not actually be shown, but will start tracking UMA
95 // for app launcher discovery.
96 virtual void ShowForAppInstall(Profile
* profile
,
97 const std::string
& extension_id
,
98 bool start_discovery_tracking
) = 0;
100 // Shows the app list, and switches to the custom launcher page.
101 virtual void ShowForCustomLauncherPage(Profile
* profile
) = 0;
103 // Hides the custom launcher page if it is currently being shown. Does nothing
105 virtual void HideCustomLauncherPage() = 0;
107 // Dismiss the app list.
108 virtual void DismissAppList() = 0;
110 // Get the profile the app list is currently showing.
111 virtual Profile
* GetCurrentAppListProfile() = 0;
113 // Returns true if the app list is visible.
114 virtual bool IsAppListVisible() const = 0;
116 // Enable the app list. What this does specifically will depend on the host
117 // operating system and shell.
118 virtual void EnableAppList(Profile
* initial_profile
,
119 AppListEnableSource enable_source
) = 0;
121 // Get the window the app list is in, or NULL if the app list isn't visible.
122 virtual gfx::NativeWindow
GetAppListWindow() = 0;
124 // Returns a pointer to the platform specific AppListControllerDelegate.
125 virtual AppListControllerDelegate
* GetControllerDelegate() = 0;
127 // Create a platform-specific shortcut for the app list.
128 virtual void CreateShortcut() = 0;
132 virtual ~AppListService() {}
134 // Do any once off initialization needed for the app list.
135 virtual void Init(Profile
* initial_profile
) = 0;
138 DISALLOW_COPY_AND_ASSIGN(AppListService
);
141 #endif // CHROME_BROWSER_UI_APP_LIST_APP_LIST_SERVICE_H_