- add sources.
[platform/framework/web/crosswalk.git] / src / chrome / browser / ui / app_list / app_list_controller_delegate.h
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
13 class ExtensionSet;
14 class Profile;
15
16 namespace base {
17 class FilePath;
18 }
19
20 namespace extensions {
21 class Extension;
22 class InstallTracker;
23 }
24
25 namespace gfx {
26 class 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.
32 class 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   // Handle the "create window" context menu items of Chrome App.
85   // |incognito| is true to create an incognito window.
86   virtual void CreateNewWindow(Profile* profile, bool incognito) = 0;
87
88   // Show the app's most recent window, or launch it if it is not running.
89   virtual void ActivateApp(Profile* profile,
90                            const extensions::Extension* extension,
91                            AppListSource source,
92                            int event_flags) = 0;
93
94   // Launch the app.
95   virtual void LaunchApp(Profile* profile,
96                          const extensions::Extension* extension,
97                          AppListSource source,
98                          int event_flags) = 0;
99
100   // Show the app list for the profile specified by |profile_path|.
101   virtual void ShowForProfileByPath(const base::FilePath& profile_path) = 0;
102
103   // Whether or not the icon indicating which user is logged in should be
104   // visible.
105   virtual bool ShouldShowUserIcon() = 0;
106
107   static std::string AppListSourceToString(AppListSource source);
108
109   // True if the user has permission to modify the given app's settings.
110   bool UserMayModifySettings(Profile* profile, const std::string& app_id);
111
112   // Uninstall the app identified by |app_id| from |profile|.
113   void UninstallApp(Profile* profile, const std::string& app_id);
114
115   // True if the app was installed from the web store.
116   bool IsAppFromWebStore(Profile* profile,
117                          const std::string& app_id);
118
119   // Shows the user the webstore site for the given app.
120   void ShowAppInWebStore(Profile* profile,
121                          const std::string& app_id,
122                          bool is_search_result);
123
124   // True if the given extension has an options page.
125   bool HasOptionsPage(Profile* profile, const std::string& app_id);
126
127   // Shows the user the options page for the app.
128   void ShowOptionsPage(Profile* profile, const std::string& app_id);
129
130   // Gets/sets the launch type for an app.
131   // The launch type specifies whether a hosted app should launch as a separate
132   // window, fullscreened or as a tab.
133   extensions::ExtensionPrefs::LaunchType GetExtensionLaunchType(
134       Profile* profile, const std::string& app_id);
135   virtual void SetExtensionLaunchType(
136       Profile* profile,
137       const std::string& extension_id,
138       extensions::ExtensionPrefs::LaunchType launch_type);
139
140   // Returns true if the given extension is installed.
141   bool IsExtensionInstalled(Profile* profile, const std::string& app_id);
142
143   extensions::InstallTracker* GetInstallTrackerFor(Profile* profile);
144
145   // Get the list of installed apps for the given profile.
146   void GetApps(Profile* profile, ExtensionSet* out_apps);
147 };
148
149 #endif  // CHROME_BROWSER_UI_APP_LIST_APP_LIST_CONTROLLER_DELEGATE_H_