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
;
17 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.
32 enum AppListEnableSource
{
33 ENABLE_NOT_RECORDED
, // Indicates app launcher not recently enabled.
34 ENABLE_FOR_APP_INSTALL
, // Triggered by a webstore packaged app install.
35 ENABLE_VIA_WEBSTORE_LINK
, // Triggered by webstore explicitly via API.
36 ENABLE_VIA_COMMAND_LINE
, // Triggered by --enable-app-list.
37 ENABLE_ON_REINSTALL
, // Triggered by Chrome reinstall finding pref.
38 ENABLE_SHOWN_UNDISCOVERED
, // This overrides a prior ENABLE_FOR_APP_INSTALL
39 // when the launcher is auto-shown without
40 // being "discovered" beforehand.
41 ENABLE_NUM_ENABLE_SOURCES
44 // Get the AppListService for the current platform and specified
46 static AppListService
* Get(chrome::HostDesktopType desktop_type
);
48 // Call Init for all AppListService instances on this platform.
49 static void InitAll(Profile
* initial_profile
);
51 static void RegisterPrefs(PrefRegistrySimple
* registry
);
53 static void RecordShowTimings(const CommandLine
& command_line
);
55 // Indicates that |callback| should be called next time the app list is
57 virtual void SetAppListNextPaintCallback(void (*callback
)()) = 0;
59 // Perform Chrome first run logic. This is executed before Chrome's threads
61 virtual void HandleFirstRun() = 0;
63 virtual base::FilePath
GetProfilePath(
64 const base::FilePath
& user_data_dir
) = 0;
65 virtual void SetProfilePath(const base::FilePath
& profile_path
) = 0;
67 // Show the app list for the profile configured in the user data dir for the
68 // current browser process.
69 virtual void Show() = 0;
71 // Create the app list UI, and maintain its state, but do not show it.
72 virtual void CreateForProfile(Profile
* requested_profile
) = 0;
74 // Show the app list for the given profile. If it differs from the profile the
75 // app list is currently showing, repopulate the app list and save the new
76 // profile to local prefs as the default app list profile.
77 virtual void ShowForProfile(Profile
* requested_profile
) = 0;
79 // Show the app list due to a trigger which was not an explicit user action
80 // to show the app list. E.g. the auto-show when installing an app. This
81 // permits UMA to distinguish between a user discovering the app list shortcut
82 // themselves versus having it shown for them automatically.
83 virtual void AutoShowForProfile(Profile
* requested_profile
) = 0;
85 // Dismiss the app list.
86 virtual void DismissAppList() = 0;
88 // Get the profile the app list is currently showing.
89 virtual Profile
* GetCurrentAppListProfile() = 0;
91 // Returns true if the app list is visible.
92 virtual bool IsAppListVisible() const = 0;
94 // Enable the app list. What this does specifically will depend on the host
95 // operating system and shell.
96 virtual void EnableAppList(Profile
* initial_profile
,
97 AppListEnableSource enable_source
) = 0;
99 // Get the window the app list is in, or NULL if the app list isn't visible.
100 virtual gfx::NativeWindow
GetAppListWindow() = 0;
102 // Returns a pointer to the platform specific AppListControllerDelegate.
103 virtual AppListControllerDelegate
* GetControllerDelegate() = 0;
107 virtual ~AppListService() {}
109 // Do any once off initialization needed for the app list.
110 virtual void Init(Profile
* initial_profile
) = 0;
113 DISALLOW_COPY_AND_ASSIGN(AppListService
);
116 #endif // CHROME_BROWSER_UI_APP_LIST_APP_LIST_SERVICE_H_