app_list_controller_delegate.h revision 0f1bc08d4cfcc34181b0b5cbf065c40f687bf740
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/browser/extensions/extension_prefs.h" 11#include "ui/gfx/native_widget_types.h" 12 13class ExtensionSet; 14class Profile; 15 16namespace base { 17class FilePath; 18} 19 20namespace extensions { 21class Extension; 22class InstallTracker; 23} 24 25namespace gfx { 26class ImageSkia; 27} 28 29// Interface to allow the view delegate to call out to whatever is controlling 30// the app list. This will have different implementations for different 31// platforms. 32class AppListControllerDelegate { 33 public: 34 // Indicates the source of an app list activation, for tracking purposes. 35 enum AppListSource { 36 LAUNCH_FROM_UNKNOWN, 37 LAUNCH_FROM_APP_LIST, 38 LAUNCH_FROM_APP_LIST_SEARCH 39 }; 40 41 // Whether apps can be pinned, and whether pinned apps are editable or fixed. 42 enum Pinnable { 43 NO_PIN, 44 PIN_EDITABLE, 45 PIN_FIXED 46 }; 47 48 virtual ~AppListControllerDelegate(); 49 50 // Dismisses the view. 51 virtual void DismissView() = 0; 52 53 // Handle the view being closed. 54 virtual void ViewClosing(); 55 56 // Get app list window. 57 virtual gfx::NativeWindow GetAppListWindow() = 0; 58 59 // Get the application icon to be used, if any, for the app list. 60 virtual gfx::ImageSkia GetWindowIcon() = 0; 61 62 // Control of pinning apps. 63 virtual bool IsAppPinned(const std::string& extension_id) = 0; 64 virtual void PinApp(const std::string& extension_id) = 0; 65 virtual void UnpinApp(const std::string& extension_id) = 0; 66 virtual Pinnable GetPinnable() = 0; 67 68 // Be aware of the extension prompt (either uninstalling flow or enable flow). 69 virtual void OnShowExtensionPrompt(); 70 virtual void OnCloseExtensionPrompt(); 71 72 // Whether the controller supports a Create Shortcuts flow. 73 virtual bool CanDoCreateShortcutsFlow() = 0; 74 75 // Show the dialog to create shortcuts. Call only if 76 // CanDoCreateShortcutsFlow() returns true. 77 virtual void DoCreateShortcutsFlow(Profile* profile, 78 const std::string& extension_id) = 0; 79 80 // Handle the "create window" context menu items of Chrome App. 81 // |incognito| is true to create an incognito window. 82 virtual void CreateNewWindow(Profile* profile, bool incognito) = 0; 83 84 // Show the app's most recent window, or launch it if it is not running. 85 virtual void ActivateApp(Profile* profile, 86 const extensions::Extension* extension, 87 AppListSource source, 88 int event_flags) = 0; 89 90 // Launch the app. 91 virtual void LaunchApp(Profile* profile, 92 const extensions::Extension* extension, 93 AppListSource source, 94 int event_flags) = 0; 95 96 // Show the app list for the profile specified by |profile_path|. 97 virtual void ShowForProfileByPath(const base::FilePath& profile_path) = 0; 98 99 // Whether or not the icon indicating which user is logged in should be 100 // visible. 101 virtual bool ShouldShowUserIcon() = 0; 102 103 static std::string AppListSourceToString(AppListSource source); 104 105 // True if the user has permission to modify the given app's settings. 106 bool UserMayModifySettings(Profile* profile, const std::string& app_id); 107 108 // Uninstall the app identified by |app_id| from |profile|. 109 void UninstallApp(Profile* profile, const std::string& app_id); 110 111 // True if the app was installed from the web store. 112 bool IsAppFromWebStore(Profile* profile, 113 const std::string& app_id); 114 115 // Shows the user the webstore site for the given app. 116 void ShowAppInWebStore(Profile* profile, 117 const std::string& app_id, 118 bool is_search_result); 119 120 // True if the given extension has an options page. 121 bool HasOptionsPage(Profile* profile, const std::string& app_id); 122 123 // Shows the user the options page for the app. 124 void ShowOptionsPage(Profile* profile, const std::string& app_id); 125 126 // Gets/sets the launch type for an app. 127 // The launch type specifies whether a hosted app should launch as a separate 128 // window, fullscreened or as a tab. 129 extensions::ExtensionPrefs::LaunchType GetExtensionLaunchType( 130 Profile* profile, const std::string& app_id); 131 virtual void SetExtensionLaunchType( 132 Profile* profile, 133 const std::string& extension_id, 134 extensions::ExtensionPrefs::LaunchType launch_type); 135 136 // Returns true if the given extension is installed. 137 bool IsExtensionInstalled(Profile* profile, const std::string& app_id); 138 139 extensions::InstallTracker* GetInstallTrackerFor(Profile* profile); 140 141 // Get the list of installed apps for the given profile. 142 void GetApps(Profile* profile, ExtensionSet* out_apps); 143}; 144 145#endif // CHROME_BROWSER_UI_APP_LIST_APP_LIST_CONTROLLER_DELEGATE_H_ 146