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. 4 5 #ifndef CHROME_BROWSER_UI_APP_LIST_APP_LIST_SERVICE_H_ 6 #define CHROME_BROWSER_UI_APP_LIST_APP_LIST_SERVICE_H_ 7 8 #include <string> 9 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" 14 15 class AppListControllerDelegate; 16 class PrefRegistrySimple; 17 class Profile; 18 19 namespace base { 20 class CommandLine; 21 class FilePath; 22 } 23 24 namespace gfx { 25 class ImageSkia; 26 } 27 28 class AppListService { 29 public: 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 43 }; 44 45 // Get the AppListService for the current platform and specified 46 // |desktop_type|. 47 static AppListService* Get(chrome::HostDesktopType desktop_type); 48 49 // Call Init for all AppListService instances on this platform. 50 static void InitAll(Profile* initial_profile); 51 52 static void RegisterPrefs(PrefRegistrySimple* registry); 53 54 static void RecordShowTimings(const base::CommandLine& command_line); 55 56 // Indicates that |callback| should be called next time the app list is 57 // painted. 58 virtual void SetAppListNextPaintCallback(void (*callback)()) = 0; 59 60 // Perform Chrome first run logic. This is executed before Chrome's threads 61 // have been created. 62 virtual void HandleFirstRun() = 0; 63 64 virtual base::FilePath GetProfilePath( 65 const base::FilePath& user_data_dir) = 0; 66 virtual void SetProfilePath(const base::FilePath& profile_path) = 0; 67 68 // Show the app list for the profile configured in the user data dir for the 69 // current browser process. 70 virtual void Show() = 0; 71 72 // Create the app list UI, and maintain its state, but do not show it. 73 virtual void CreateForProfile(Profile* requested_profile) = 0; 74 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; 79 80 // Show the app list due to a trigger which was not an explicit user action 81 // to show the app list. E.g. the auto-show when installing an app. This 82 // permits UMA to distinguish between a user discovering the app list shortcut 83 // themselves versus having it shown for them automatically. 84 virtual void AutoShowForProfile(Profile* requested_profile) = 0; 85 86 // Dismiss the app list. 87 virtual void DismissAppList() = 0; 88 89 // Get the profile the app list is currently showing. 90 virtual Profile* GetCurrentAppListProfile() = 0; 91 92 // Returns true if the app list is visible. 93 virtual bool IsAppListVisible() const = 0; 94 95 // Enable the app list. What this does specifically will depend on the host 96 // operating system and shell. 97 virtual void EnableAppList(Profile* initial_profile, 98 AppListEnableSource enable_source) = 0; 99 100 // Get the window the app list is in, or NULL if the app list isn't visible. 101 virtual gfx::NativeWindow GetAppListWindow() = 0; 102 103 // Returns a pointer to the platform specific AppListControllerDelegate. 104 virtual AppListControllerDelegate* GetControllerDelegate() = 0; 105 106 // Create a platform-specific shortcut for the app list. 107 virtual void CreateShortcut() = 0; 108 109 protected: 110 AppListService() {} 111 virtual ~AppListService() {} 112 113 // Do any once off initialization needed for the app list. 114 virtual void Init(Profile* initial_profile) = 0; 115 116 private: 117 DISALLOW_COPY_AND_ASSIGN(AppListService); 118 }; 119 120 #endif // CHROME_BROWSER_UI_APP_LIST_APP_LIST_SERVICE_H_ 121