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