Add more checks to investigate SupervisedUserPrefStore crash at startup.
[chromium-blink-merge.git] / extensions / browser / api / management / management_api_delegate.h
blob6311b3d92195f4dcf7ff8637907df8ba04c0e570
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"
13 #include "url/gurl.h"
15 namespace content {
16 class BrowserContext;
17 } // namespace content
19 namespace extensions {
21 class Extension;
22 class ExtensionPrefs;
23 class ManagementCreateAppShortcutFunction;
24 class ManagementGenerateAppForLinkFunction;
25 class ManagementGetPermissionWarningsByManifestFunction;
26 class ManagementSetEnabledFunction;
27 class ManagementUninstallFunctionBase;
29 // Manages the lifetime of the install prompt.
30 class InstallPromptDelegate {
31 public:
32 virtual ~InstallPromptDelegate() {}
35 // Manages the lifetime of the uninstall prompt.
36 class UninstallDialogDelegate {
37 public:
38 virtual ~UninstallDialogDelegate() {}
41 // Manages the lifetime of the bookmark app creation.
42 class AppForLinkDelegate {
43 public:
44 virtual ~AppForLinkDelegate() {}
47 class ManagementAPIDelegate {
48 public:
49 virtual ~ManagementAPIDelegate() {}
51 // Launches the app |extension|. Returns true on success.
52 virtual bool LaunchAppFunctionDelegate(
53 const Extension* extension,
54 content::BrowserContext* context) const = 0;
56 // Forwards the call to extensions::util::IsNewBookmarkAppsEnabled in
57 // chrome.
58 virtual bool IsNewBookmarkAppsEnabled() const = 0;
60 // Forwards the call to AppLaunchInfo::GetFullLaunchURL in chrome.
61 virtual GURL GetFullLaunchURL(const Extension* extension) const = 0;
63 // Forwards the call to launch_util::GetLaunchType in chrome.
64 virtual LaunchType GetLaunchType(const ExtensionPrefs* prefs,
65 const Extension* extension) const = 0;
67 // Parses the manifest and calls back the
68 // ManagementGetPermissionWarningsByManifestFunction.
69 virtual void GetPermissionWarningsByManifestFunctionDelegate(
70 ManagementGetPermissionWarningsByManifestFunction* function,
71 const std::string& manifest_str) const = 0;
73 // Used to show a dialog prompt in chrome when management.setEnabled extension
74 // function is called.
75 virtual scoped_ptr<InstallPromptDelegate> SetEnabledFunctionDelegate(
76 ManagementSetEnabledFunction* function,
77 const Extension* extension) const = 0;
79 // Enables the extension identified by |extension_id|.
80 virtual void EnableExtension(content::BrowserContext* context,
81 const std::string& extension_id) const = 0;
83 // Disables the extension identified by |extension_id|.
84 virtual void DisableExtension(
85 content::BrowserContext* context,
86 const std::string& extension_id,
87 Extension::DisableReason disable_reason) const = 0;
89 // Used to show a confirmation dialog when uninstalling |target_extension_id|.
90 virtual scoped_ptr<UninstallDialogDelegate> UninstallFunctionDelegate(
91 ManagementUninstallFunctionBase* function,
92 const std::string& target_extension_id) const = 0;
94 // Uninstalls the extension.
95 virtual bool UninstallExtension(content::BrowserContext* context,
96 const std::string& transient_extension_id,
97 UninstallReason reason,
98 const base::Closure& deletion_done_callback,
99 base::string16* error) const = 0;
101 // Creates an app shortcut.
102 virtual bool CreateAppShortcutFunctionDelegate(
103 ManagementCreateAppShortcutFunction* function,
104 const Extension* extension) const = 0;
106 // Forwards the call to launch_util::SetLaunchType in chrome.
107 virtual void SetLaunchType(content::BrowserContext* context,
108 const std::string& extension_id,
109 LaunchType launch_type) const = 0;
111 // Creates a bookmark app for |launch_url|.
112 virtual scoped_ptr<AppForLinkDelegate> GenerateAppForLinkFunctionDelegate(
113 ManagementGenerateAppForLinkFunction* function,
114 content::BrowserContext* context,
115 const std::string& title,
116 const GURL& launch_url) const = 0;
118 // Forwards the call to ExtensionIconSource::GetIconURL in chrome.
119 virtual GURL GetIconURL(const Extension* extension,
120 int icon_size,
121 ExtensionIconSet::MatchType match,
122 bool grayscale,
123 bool* exists) const = 0;
126 } // namespace extensions
128 #endif // EXTENSIONS_BROWSER_API_MANAGEMENT_MANAGEMENT_API_DELEGATER_H_