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 "chrome/browser/ui/host_desktop.h"
13 #include "ui/gfx/native_widget_types.h"
15 class AppListControllerDelegate
;
16 class PrefRegistrySimple
;
28 class AppListService
{
30 // Source that triggers the app launcher being enabled. This is used for UMA
31 // to track discoverability of the app lancher shortcut after install. Also
32 // used to provide custom install behavior (e.g. "always" enable).
33 enum AppListEnableSource
{
34 ENABLE_NOT_RECORDED
, // Indicates app launcher not recently enabled.
35 ENABLE_FOR_APP_INSTALL
, // Triggered by a webstore packaged app install.
36 ENABLE_VIA_WEBSTORE_LINK
, // Triggered by webstore explicitly via API.
37 ENABLE_VIA_COMMAND_LINE
, // Triggered by --enable-app-list.
38 ENABLE_ON_REINSTALL
, // Triggered by Chrome reinstall finding pref.
39 ENABLE_SHOWN_UNDISCOVERED
, // This overrides a prior ENABLE_FOR_APP_INSTALL
40 // when the launcher is auto-shown without
41 // being "discovered" beforehand.
42 ENABLE_NUM_ENABLE_SOURCES
45 // Get the AppListService for the current platform and specified
47 static AppListService
* Get(chrome::HostDesktopType desktop_type
);
49 // Call Init for all AppListService instances on this platform.
50 static void InitAll(Profile
* initial_profile
);
52 static void RegisterPrefs(PrefRegistrySimple
* registry
);
54 // Initializes the AppListService, and returns true if |command_line| is for
55 // showing the app list.
56 static bool HandleLaunchCommandLine(const base::CommandLine
& command_line
,
57 Profile
* launch_profile
);
59 // Indicates that |callback| should be called next time the app list is
61 virtual void SetAppListNextPaintCallback(void (*callback
)()) = 0;
63 // Perform Chrome first run logic. This is executed before Chrome's threads
65 virtual void HandleFirstRun() = 0;
67 virtual base::FilePath
GetProfilePath(
68 const base::FilePath
& user_data_dir
) = 0;
69 virtual void SetProfilePath(const base::FilePath
& profile_path
) = 0;
71 // Show the app list for the profile configured in the user data dir for the
72 // current browser process.
73 virtual void Show() = 0;
75 // Show the app list for the given profile. If it differs from the profile the
76 // app list is currently showing, repopulate the app list and save the new
77 // profile to local prefs as the default app list profile.
78 virtual void ShowForProfile(Profile
* requested_profile
) = 0;
80 // Shows the app list, and jump to voice search. Used by always-on hotwording.
81 virtual void ShowForVoiceSearch(Profile
* profile
) = 0;
83 // Shows the app list, and reveals the page that contains |extension_id|. This
84 // should only be called for things that show in the app list, and only when
85 // they begin or complete installing. If |start_discovery_tracking| is set,
86 // the app launcher will not actually be shown, but will start tracking UMA
87 // for app launcher discovery.
88 virtual void ShowForAppInstall(Profile
* profile
,
89 const std::string
& extension_id
,
90 bool start_discovery_tracking
) = 0;
92 // Dismiss the app list.
93 virtual void DismissAppList() = 0;
95 // Get the profile the app list is currently showing.
96 virtual Profile
* GetCurrentAppListProfile() = 0;
98 // Returns true if the app list is visible.
99 virtual bool IsAppListVisible() const = 0;
101 // Enable the app list. What this does specifically will depend on the host
102 // operating system and shell.
103 virtual void EnableAppList(Profile
* initial_profile
,
104 AppListEnableSource enable_source
) = 0;
106 // Get the window the app list is in, or NULL if the app list isn't visible.
107 virtual gfx::NativeWindow
GetAppListWindow() = 0;
109 // Returns a pointer to the platform specific AppListControllerDelegate.
110 virtual AppListControllerDelegate
* GetControllerDelegate() = 0;
112 // Create a platform-specific shortcut for the app list.
113 virtual void CreateShortcut() = 0;
117 virtual ~AppListService() {}
119 // Do any once off initialization needed for the app list.
120 virtual void Init(Profile
* initial_profile
) = 0;
123 DISALLOW_COPY_AND_ASSIGN(AppListService
);
126 #endif // CHROME_BROWSER_UI_APP_LIST_APP_LIST_SERVICE_H_