app_list_controller_delegate.h revision 5d1f7b1de12d16ceb2c938c56701a3e8bfa558f7
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
13class Profile;
14
15namespace base {
16class FilePath;
17}
18
19namespace extensions {
20class Extension;
21class ExtensionSet;
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  // Whether to force the use of a native desktop widget when the app list
51  // window is first created.
52  virtual bool ForceNativeDesktop() const;
53
54  // Dismisses the view.
55  virtual void DismissView() = 0;
56
57  // Handle the view being closed.
58  virtual void ViewClosing();
59
60  // Get app list window.
61  virtual gfx::NativeWindow GetAppListWindow() = 0;
62
63  // Get the application icon to be used, if any, for the app list.
64  virtual gfx::ImageSkia GetWindowIcon() = 0;
65
66  // Control of pinning apps.
67  virtual bool IsAppPinned(const std::string& extension_id) = 0;
68  virtual void PinApp(const std::string& extension_id) = 0;
69  virtual void UnpinApp(const std::string& extension_id) = 0;
70  virtual Pinnable GetPinnable() = 0;
71
72  // Be aware of the extension prompt (either uninstalling flow or enable flow).
73  virtual void OnShowExtensionPrompt();
74  virtual void OnCloseExtensionPrompt();
75
76  // Whether the controller supports a Create Shortcuts flow.
77  virtual bool CanDoCreateShortcutsFlow() = 0;
78
79  // Show the dialog to create shortcuts. Call only if
80  // CanDoCreateShortcutsFlow() returns true.
81  virtual void DoCreateShortcutsFlow(Profile* profile,
82                                     const std::string& extension_id) = 0;
83
84  // Whether the controller supports a Show App Info flow.
85  virtual bool CanDoShowAppInfoFlow();
86
87  // Show the dialog with the application's information. Call only if
88  // CanDoShowAppInfoFlow() returns true.
89  virtual void DoShowAppInfoFlow(Profile* profile,
90                                 const std::string& extension_id);
91
92  // Handle the "create window" context menu items of Chrome App.
93  // |incognito| is true to create an incognito window.
94  virtual void CreateNewWindow(Profile* profile, bool incognito) = 0;
95
96  // Show the app's most recent window, or launch it if it is not running.
97  virtual void ActivateApp(Profile* profile,
98                           const extensions::Extension* extension,
99                           AppListSource source,
100                           int event_flags) = 0;
101
102  // Launch the app.
103  virtual void LaunchApp(Profile* profile,
104                         const extensions::Extension* extension,
105                         AppListSource source,
106                         int event_flags) = 0;
107
108  // Show the app list for the profile specified by |profile_path|.
109  virtual void ShowForProfileByPath(const base::FilePath& profile_path) = 0;
110
111  // Whether or not the icon indicating which user is logged in should be
112  // visible.
113  virtual bool ShouldShowUserIcon() = 0;
114
115  static std::string AppListSourceToString(AppListSource source);
116
117  // True if the user has permission to modify the given app's settings.
118  bool UserMayModifySettings(Profile* profile, const std::string& app_id);
119
120  // Uninstall the app identified by |app_id| from |profile|.
121  void UninstallApp(Profile* profile, const std::string& app_id);
122
123  // Remove the app identified by |app_id| in |profile| from its folder.
124  void RemoveAppFromFolder(Profile* profile, const std::string& app_id);
125
126  // True if the app was installed from the web store.
127  bool IsAppFromWebStore(Profile* profile,
128                         const std::string& app_id);
129
130  // Shows the user the webstore site for the given app.
131  void ShowAppInWebStore(Profile* profile,
132                         const std::string& app_id,
133                         bool is_search_result);
134
135  // True if the given extension has an options page.
136  bool HasOptionsPage(Profile* profile, const std::string& app_id);
137
138  // Shows the user the options page for the app.
139  void ShowOptionsPage(Profile* profile, const std::string& app_id);
140
141  // Gets/sets the launch type for an app.
142  // The launch type specifies whether a hosted app should launch as a separate
143  // window, fullscreened or as a tab.
144  extensions::LaunchType GetExtensionLaunchType(
145      Profile* profile, const std::string& app_id);
146  virtual void SetExtensionLaunchType(
147      Profile* profile,
148      const std::string& extension_id,
149      extensions::LaunchType launch_type);
150
151  // Returns true if the given extension is installed.
152  bool IsExtensionInstalled(Profile* profile, const std::string& app_id);
153
154  extensions::InstallTracker* GetInstallTrackerFor(Profile* profile);
155
156  // Get the list of installed apps for the given profile.
157  void GetApps(Profile* profile, extensions::ExtensionSet* out_apps);
158};
159
160#endif  // CHROME_BROWSER_UI_APP_LIST_APP_LIST_CONTROLLER_DELEGATE_H_
161