1 // Copyright 2014 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 EXTENSIONS_BROWSER_API_MANAGEMENT_MANAGEMENT_API_DELEGATER_H_
6 #define EXTENSIONS_BROWSER_API_MANAGEMENT_MANAGEMENT_API_DELEGATER_H_
8 #include "base/callback.h"
9 #include "extensions/browser/uninstall_reason.h"
10 #include "extensions/common/constants.h"
11 #include "extensions/common/extension.h"
12 #include "extensions/common/extension_icon_set.h"
17 } // namespace content
19 namespace extensions
{
23 class ManagementCreateAppShortcutFunction
;
24 class ManagementGenerateAppForLinkFunction
;
25 class ManagementGetPermissionWarningsByManifestFunction
;
26 class ManagementSetEnabledFunction
;
27 class ManagementUninstallFunctionBase
;
28 class RequirementsChecker
;
30 // Manages the lifetime of the install prompt.
31 class InstallPromptDelegate
{
33 virtual ~InstallPromptDelegate() {}
36 // Manages the lifetime of the uninstall prompt.
37 class UninstallDialogDelegate
{
39 virtual ~UninstallDialogDelegate() {}
42 // Manages the lifetime of the bookmark app creation.
43 class AppForLinkDelegate
{
45 virtual ~AppForLinkDelegate() {}
48 class ManagementAPIDelegate
{
50 virtual ~ManagementAPIDelegate() {}
52 // Launches the app |extension|. Returns true on success.
53 virtual bool LaunchAppFunctionDelegate(
54 const Extension
* extension
,
55 content::BrowserContext
* context
) const = 0;
57 // Forwards the call to extensions::util::IsNewBookmarkAppsEnabled in
59 virtual bool IsNewBookmarkAppsEnabled() const = 0;
61 // Forwards the call to AppLaunchInfo::GetFullLaunchURL in chrome.
62 virtual GURL
GetFullLaunchURL(const Extension
* extension
) const = 0;
64 // Forwards the call to launch_util::GetLaunchType in chrome.
65 virtual LaunchType
GetLaunchType(const ExtensionPrefs
* prefs
,
66 const Extension
* extension
) const = 0;
68 // Parses the manifest and calls back the
69 // ManagementGetPermissionWarningsByManifestFunction.
70 virtual void GetPermissionWarningsByManifestFunctionDelegate(
71 ManagementGetPermissionWarningsByManifestFunction
* function
,
72 const std::string
& manifest_str
) const = 0;
74 // Used to show a dialog prompt in chrome when management.setEnabled extension
75 // function is called.
76 virtual scoped_ptr
<InstallPromptDelegate
> SetEnabledFunctionDelegate(
77 ManagementSetEnabledFunction
* function
,
78 const Extension
* extension
) const = 0;
80 // Returns a new RequirementsChecker.
81 virtual scoped_ptr
<RequirementsChecker
> CreateRequirementsChecker() const = 0;
83 // Enables the extension identified by |extension_id|.
84 virtual void EnableExtension(content::BrowserContext
* context
,
85 const std::string
& extension_id
) const = 0;
87 // Disables the extension identified by |extension_id|.
88 virtual void DisableExtension(
89 content::BrowserContext
* context
,
90 const std::string
& extension_id
,
91 Extension::DisableReason disable_reason
) const = 0;
93 // Used to show a confirmation dialog when uninstalling |target_extension|.
94 virtual scoped_ptr
<UninstallDialogDelegate
> UninstallFunctionDelegate(
95 ManagementUninstallFunctionBase
* function
,
96 const Extension
* target_extension
,
97 bool show_programmatic_uninstall_ui
) const = 0;
99 // Uninstalls the extension.
100 virtual bool UninstallExtension(content::BrowserContext
* context
,
101 const std::string
& transient_extension_id
,
102 UninstallReason reason
,
103 const base::Closure
& deletion_done_callback
,
104 base::string16
* error
) const = 0;
106 // Creates an app shortcut.
107 virtual bool CreateAppShortcutFunctionDelegate(
108 ManagementCreateAppShortcutFunction
* function
,
109 const Extension
* extension
) const = 0;
111 // Forwards the call to launch_util::SetLaunchType in chrome.
112 virtual void SetLaunchType(content::BrowserContext
* context
,
113 const std::string
& extension_id
,
114 LaunchType launch_type
) const = 0;
116 // Creates a bookmark app for |launch_url|.
117 virtual scoped_ptr
<AppForLinkDelegate
> GenerateAppForLinkFunctionDelegate(
118 ManagementGenerateAppForLinkFunction
* function
,
119 content::BrowserContext
* context
,
120 const std::string
& title
,
121 const GURL
& launch_url
) const = 0;
123 // Forwards the call to ExtensionIconSource::GetIconURL in chrome.
124 virtual GURL
GetIconURL(const Extension
* extension
,
126 ExtensionIconSet::MatchType match
,
128 bool* exists
) const = 0;
131 } // namespace extensions
133 #endif // EXTENSIONS_BROWSER_API_MANAGEMENT_MANAGEMENT_API_DELEGATER_H_