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.
5 #ifndef CHROME_BROWSER_UI_APP_LIST_APP_LIST_CONTROLLER_DELEGATE_H_
6 #define CHROME_BROWSER_UI_APP_LIST_APP_LIST_CONTROLLER_DELEGATE_H_
10 #include "chrome/common/extensions/extension_constants.h"
11 #include "ui/gfx/native_widget_types.h"
19 namespace extensions
{
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
33 class AppListControllerDelegate
{
35 // Indicates the source of an app list activation, for tracking purposes.
39 LAUNCH_FROM_APP_LIST_SEARCH
42 // Whether apps can be pinned, and whether pinned apps are editable or fixed.
49 virtual ~AppListControllerDelegate();
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;
55 // Dismisses the view.
56 virtual void DismissView() = 0;
58 // Handle the view being closed.
59 virtual void ViewClosing();
61 // Get app list window.
62 virtual gfx::NativeWindow
GetAppListWindow() = 0;
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();
69 // Get the application icon to be used, if any, for the app list.
70 virtual gfx::ImageSkia
GetWindowIcon() = 0;
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;
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();
83 // Whether the controller supports a Create Shortcuts flow.
84 virtual bool CanDoCreateShortcutsFlow() = 0;
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;
91 // Whether the controller supports a Show App Info flow.
92 virtual bool CanDoShowAppInfoFlow();
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
);
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;
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;
110 virtual void LaunchApp(Profile
* profile
,
111 const extensions::Extension
* extension
,
112 AppListSource source
,
113 int event_flags
) = 0;
115 // Show the app list for the profile specified by |profile_path|.
116 virtual void ShowForProfileByPath(const base::FilePath
& profile_path
) = 0;
118 // Whether or not the icon indicating which user is logged in should be
120 virtual bool ShouldShowUserIcon() = 0;
122 static std::string
AppListSourceToString(AppListSource source
);
124 // True if the user has permission to modify the given app's settings.
125 bool UserMayModifySettings(Profile
* profile
, const std::string
& app_id
);
127 // Uninstall the app identified by |app_id| from |profile|.
128 void UninstallApp(Profile
* profile
, const std::string
& app_id
);
130 // True if the app was installed from the web store.
131 bool IsAppFromWebStore(Profile
* profile
,
132 const std::string
& app_id
);
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
);
139 // True if the given extension has an options page.
140 bool HasOptionsPage(Profile
* profile
, const std::string
& app_id
);
142 // Shows the user the options page for the app.
143 void ShowOptionsPage(Profile
* profile
, const std::string
& app_id
);
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(
152 const std::string
& extension_id
,
153 extensions::LaunchType launch_type
);
155 // Returns true if the given extension is installed.
156 bool IsExtensionInstalled(Profile
* profile
, const std::string
& app_id
);
158 extensions::InstallTracker
* GetInstallTrackerFor(Profile
* profile
);
160 // Get the list of installed apps for the given profile.
161 void GetApps(Profile
* profile
, extensions::ExtensionSet
* out_apps
);
163 // Called when a search is started using the app list search box.
164 void OnSearchStarted();
167 #endif // CHROME_BROWSER_UI_APP_LIST_APP_LIST_CONTROLLER_DELEGATE_H_