1 // Copyright 2012 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_CONTROLLER_DELEGATE_H_ 6 #define CHROME_BROWSER_UI_APP_LIST_APP_LIST_CONTROLLER_DELEGATE_H_ 7 8 #include <string> 9 10 #include "chrome/common/extensions/extension_constants.h" 11 #include "ui/gfx/native_widget_types.h" 12 13 class Profile; 14 15 namespace base { 16 class FilePath; 17 } 18 19 namespace extensions { 20 class Extension; 21 class ExtensionSet; 22 class InstallTracker; 23 } 24 25 namespace gfx { 26 class ImageSkia; 27 class Rect; 28 } 29 30 // Interface to allow the view delegate to call out to whatever is controlling 31 // the app list. This will have different implementations for different 32 // platforms. 33 class AppListControllerDelegate { 34 public: 35 // Indicates the source of an app list activation, for tracking purposes. 36 enum AppListSource { 37 LAUNCH_FROM_UNKNOWN, 38 LAUNCH_FROM_APP_LIST, 39 LAUNCH_FROM_APP_LIST_SEARCH 40 }; 41 42 // Whether apps can be pinned, and whether pinned apps are editable or fixed. 43 enum Pinnable { 44 NO_PIN, 45 PIN_EDITABLE, 46 PIN_FIXED 47 }; 48 49 virtual ~AppListControllerDelegate(); 50 51 // Whether to force the use of a native desktop widget when the app list 52 // window is first created. 53 virtual bool ForceNativeDesktop() const; 54 55 // Dismisses the view. 56 virtual void DismissView() = 0; 57 58 // Handle the view being closed. 59 virtual void ViewClosing(); 60 61 // Get app list window. 62 virtual gfx::NativeWindow GetAppListWindow() = 0; 63 64 // Get the content bounds of the app list in the screen. On platforms that 65 // use views, this returns the bounds of the AppListView. Without views, this 66 // returns a 0x0 rectangle. 67 virtual gfx::Rect GetAppListBounds(); 68 69 // Get the application icon to be used, if any, for the app list. 70 virtual gfx::ImageSkia GetWindowIcon() = 0; 71 72 // Control of pinning apps. 73 virtual bool IsAppPinned(const std::string& extension_id) = 0; 74 virtual void PinApp(const std::string& extension_id) = 0; 75 virtual void UnpinApp(const std::string& extension_id) = 0; 76 virtual Pinnable GetPinnable() = 0; 77 78 // Called before and after a dialog opens in the app list. For example, 79 // displays an overlay that disables the app list while the dialog is open. 80 virtual void OnShowChildDialog(); 81 virtual void OnCloseChildDialog(); 82 83 // Whether the controller supports a Create Shortcuts flow. 84 virtual bool CanDoCreateShortcutsFlow() = 0; 85 86 // Show the dialog to create shortcuts. Call only if 87 // CanDoCreateShortcutsFlow() returns true. 88 virtual void DoCreateShortcutsFlow(Profile* profile, 89 const std::string& extension_id) = 0; 90 91 // Whether the controller supports a Show App Info flow. 92 virtual bool CanDoShowAppInfoFlow(); 93 94 // Show the dialog with the application's information. Call only if 95 // CanDoShowAppInfoFlow() returns true. 96 virtual void DoShowAppInfoFlow(Profile* profile, 97 const std::string& extension_id); 98 99 // Handle the "create window" context menu items of Chrome App. 100 // |incognito| is true to create an incognito window. 101 virtual void CreateNewWindow(Profile* profile, bool incognito) = 0; 102 103 // Show the app's most recent window, or launch it if it is not running. 104 virtual void ActivateApp(Profile* profile, 105 const extensions::Extension* extension, 106 AppListSource source, 107 int event_flags) = 0; 108 109 // Launch the app. 110 virtual void LaunchApp(Profile* profile, 111 const extensions::Extension* extension, 112 AppListSource source, 113 int event_flags) = 0; 114 115 // Show the app list for the profile specified by |profile_path|. 116 virtual void ShowForProfileByPath(const base::FilePath& profile_path) = 0; 117 118 // Whether or not the icon indicating which user is logged in should be 119 // visible. 120 virtual bool ShouldShowUserIcon() = 0; 121 122 static std::string AppListSourceToString(AppListSource source); 123 124 // True if the user has permission to modify the given app's settings. 125 bool UserMayModifySettings(Profile* profile, const std::string& app_id); 126 127 // Uninstall the app identified by |app_id| from |profile|. 128 void UninstallApp(Profile* profile, const std::string& app_id); 129 130 // True if the app was installed from the web store. 131 bool IsAppFromWebStore(Profile* profile, 132 const std::string& app_id); 133 134 // Shows the user the webstore site for the given app. 135 void ShowAppInWebStore(Profile* profile, 136 const std::string& app_id, 137 bool is_search_result); 138 139 // True if the given extension has an options page. 140 bool HasOptionsPage(Profile* profile, const std::string& app_id); 141 142 // Shows the user the options page for the app. 143 void ShowOptionsPage(Profile* profile, const std::string& app_id); 144 145 // Gets/sets the launch type for an app. 146 // The launch type specifies whether a hosted app should launch as a separate 147 // window, fullscreened or as a tab. 148 extensions::LaunchType GetExtensionLaunchType( 149 Profile* profile, const std::string& app_id); 150 virtual void SetExtensionLaunchType( 151 Profile* profile, 152 const std::string& extension_id, 153 extensions::LaunchType launch_type); 154 155 // Returns true if the given extension is installed. 156 bool IsExtensionInstalled(Profile* profile, const std::string& app_id); 157 158 extensions::InstallTracker* GetInstallTrackerFor(Profile* profile); 159 160 // Get the list of installed apps for the given profile. 161 void GetApps(Profile* profile, extensions::ExtensionSet* out_apps); 162 163 // Called when a search is started using the app list search box. 164 void OnSearchStarted(); 165 }; 166 167 #endif // CHROME_BROWSER_UI_APP_LIST_APP_LIST_CONTROLLER_DELEGATE_H_ 168