Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(23)

Unified Diff: extensions/browser/api/management/management_api.h

Issue 696543002: Move the chrome.management API to extensions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: extensions/browser/api/management/management_api.h
diff --git a/chrome/browser/extensions/api/management/management_api.h b/extensions/browser/api/management/management_api.h
similarity index 77%
rename from chrome/browser/extensions/api/management/management_api.h
rename to extensions/browser/api/management/management_api.h
index 93133f9e52a97fd82df823dc1deab16f42a8ebcf..d12903b60007bacfafd68214a9fa7ad7bc8f5817 100644
--- a/chrome/browser/extensions/api/management/management_api.h
+++ b/extensions/browser/api/management/management_api.h
@@ -2,41 +2,33 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_BROWSER_EXTENSIONS_API_MANAGEMENT_MANAGEMENT_API_H_
-#define CHROME_BROWSER_EXTENSIONS_API_MANAGEMENT_MANAGEMENT_API_H_
+#ifndef EXTENSIONS_BROWSER_API_MANAGEMENT_MANAGEMENT_API_H_
+#define EXTENSIONS_BROWSER_API_MANAGEMENT_MANAGEMENT_API_H_
#include "base/compiler_specific.h"
#include "base/scoped_observer.h"
-#include "base/task/cancelable_task_tracker.h"
-#include "chrome/browser/extensions/bookmark_app_helper.h"
-#include "chrome/browser/extensions/chrome_extension_function.h"
-#include "chrome/browser/extensions/extension_install_prompt.h"
-#include "chrome/browser/extensions/extension_uninstall_dialog.h"
-#include "chrome/common/web_application_info.h"
-#include "components/favicon_base/favicon_types.h"
#include "components/keyed_service/core/keyed_service.h"
+#include "extensions/browser/api/management/management_api_delegate.h"
#include "extensions/browser/browser_context_keyed_api_factory.h"
#include "extensions/browser/event_router.h"
+#include "extensions/browser/extension_function.h"
#include "extensions/browser/extension_registry_observer.h"
-class ExtensionService;
+class ExtensionRegistry;
class ExtensionUninstallDialog;
+struct WebApplicationInfo;
namespace extensions {
class ExtensionRegistry;
-class ManagementFunction : public ChromeSyncExtensionFunction {
+class ManagementFunction : public SyncExtensionFunction {
protected:
~ManagementFunction() override {}
-
- ExtensionService* service();
};
-class AsyncManagementFunction : public ChromeAsyncExtensionFunction {
+class AsyncManagementFunction : public AsyncExtensionFunction {
protected:
~AsyncManagementFunction() override {}
-
- ExtensionService* service();
};
class ManagementGetAllFunction : public ManagementFunction {
@@ -85,11 +77,10 @@ class ManagementGetPermissionWarningsByIdFunction : public ManagementFunction {
};
class ManagementGetPermissionWarningsByManifestFunction
- : public ChromeAsyncExtensionFunction {
+ : public AsyncExtensionFunction {
public:
- DECLARE_EXTENSION_FUNCTION(
- "management.getPermissionWarningsByManifest",
- MANAGEMENT_GETPERMISSIONWARNINGSBYMANIFEST);
+ DECLARE_EXTENSION_FUNCTION("management.getPermissionWarningsByManifest",
+ MANAGEMENT_GETPERMISSIONWARNINGSBYMANIFEST);
// Called when utility process finishes.
void OnParseSuccess(scoped_ptr<base::DictionaryValue> parsed_manifest);
@@ -113,54 +104,50 @@ class ManagementLaunchAppFunction : public ManagementFunction {
bool RunSync() override;
};
-class ManagementSetEnabledFunction : public AsyncManagementFunction,
- public ExtensionInstallPrompt::Delegate {
+class ManagementSetEnabledFunction : public AsyncManagementFunction {
public:
DECLARE_EXTENSION_FUNCTION("management.setEnabled", MANAGEMENT_SETENABLED)
ManagementSetEnabledFunction();
+ void InstallUIProceed();
+ void InstallUIAbort(bool user_initiated);
+
protected:
~ManagementSetEnabledFunction() override;
// ExtensionFunction:
bool RunAsync() override;
- // ExtensionInstallPrompt::Delegate.
- void InstallUIProceed() override;
- void InstallUIAbort(bool user_initiated) override;
-
private:
std::string extension_id_;
- // Used for prompting to re-enable items with permissions escalation updates.
- scoped_ptr<ExtensionInstallPrompt> install_prompt_;
+ scoped_ptr<InstallPromptDelegate> install_prompt_;
};
-class ManagementUninstallFunctionBase : public AsyncManagementFunction,
- public ExtensionUninstallDialog::Delegate {
+class ManagementUninstallFunctionBase : public AsyncManagementFunction {
public:
ManagementUninstallFunctionBase();
static void SetAutoConfirmForTest(bool should_proceed);
- // ExtensionUninstallDialog::Delegate implementation.
- void ExtensionUninstallAccepted() override;
- void ExtensionUninstallCanceled() override;
+ void ExtensionUninstallAccepted();
+ void ExtensionUninstallCanceled();
protected:
~ManagementUninstallFunctionBase() override;
bool Uninstall(const std::string& extension_id, bool show_confirm_dialog);
- private:
+ private:
// If should_uninstall is true, this method does the actual uninstall.
// If |show_uninstall_dialog|, then this function will be called by one of the
// Accepted/Canceled callbacks. Otherwise, it's called directly from RunAsync.
void Finish(bool should_uninstall);
std::string extension_id_;
- scoped_ptr<ExtensionUninstallDialog> extension_uninstall_dialog_;
+
+ scoped_ptr<UninstallDialogDelegate> uninstall_dialog_;
};
class ManagementUninstallFunction : public ManagementUninstallFunctionBase {
@@ -178,7 +165,7 @@ class ManagementUninstallFunction : public ManagementUninstallFunctionBase {
class ManagementUninstallSelfFunction : public ManagementUninstallFunctionBase {
public:
DECLARE_EXTENSION_FUNCTION("management.uninstallSelf",
- MANAGEMENT_UNINSTALLSELF);
+ MANAGEMENT_UNINSTALLSELF);
ManagementUninstallSelfFunction();
@@ -191,7 +178,7 @@ class ManagementUninstallSelfFunction : public ManagementUninstallFunctionBase {
class ManagementCreateAppShortcutFunction : public AsyncManagementFunction {
public:
DECLARE_EXTENSION_FUNCTION("management.createAppShortcut",
- MANAGEMENT_CREATEAPPSHORTCUT);
+ MANAGEMENT_CREATEAPPSHORTCUT);
ManagementCreateAppShortcutFunction();
@@ -208,7 +195,7 @@ class ManagementCreateAppShortcutFunction : public AsyncManagementFunction {
class ManagementSetLaunchTypeFunction : public ManagementFunction {
public:
DECLARE_EXTENSION_FUNCTION("management.setLaunchType",
- MANAGEMENT_SETLAUNCHTYPE);
+ MANAGEMENT_SETLAUNCHTYPE);
protected:
~ManagementSetLaunchTypeFunction() override {}
@@ -219,27 +206,20 @@ class ManagementSetLaunchTypeFunction : public ManagementFunction {
class ManagementGenerateAppForLinkFunction : public AsyncManagementFunction {
public:
DECLARE_EXTENSION_FUNCTION("management.generateAppForLink",
- MANAGEMENT_GENERATEAPPFORLINK);
+ MANAGEMENT_GENERATEAPPFORLINK);
ManagementGenerateAppForLinkFunction();
+ void FinishCreateBookmarkApp(const Extension* extension,
+ const WebApplicationInfo& web_app_info);
+
protected:
~ManagementGenerateAppForLinkFunction() override;
bool RunAsync() override;
private:
- void OnFaviconForApp(const favicon_base::FaviconImageResult& image_result);
- void FinishCreateBookmarkApp(const Extension* extension,
- const WebApplicationInfo& web_app_info);
-
- std::string title_;
- GURL launch_url_;
-
- scoped_ptr<BookmarkAppHelper> bookmark_app_helper_;
-
- // Used for favicon loading tasks.
- base::CancelableTaskTracker cancelable_task_tracker_;
+ scoped_ptr<AppForLinkDelegate> app_for_link_delegate_;
};
class ManagementEventRouter : public ExtensionRegistryObserver {
@@ -287,23 +267,26 @@ class ManagementAPI : public BrowserContextKeyedAPI,
// EventRouter::Observer implementation.
void OnListenerAdded(const EventListenerInfo& details) override;
+ // Returns the ManagementAPI delegate.
+ const ManagementAPIDelegate* GetDelegate() const { return delegate_.get(); }
+
private:
friend class BrowserContextKeyedAPIFactory<ManagementAPI>;
content::BrowserContext* browser_context_;
// BrowserContextKeyedAPI implementation.
- static const char* service_name() {
- return "ManagementAPI";
- }
+ static const char* service_name() { return "ManagementAPI"; }
static const bool kServiceIsNULLWhileTesting = true;
// Created lazily upon OnListenerAdded.
scoped_ptr<ManagementEventRouter> management_event_router_;
+ scoped_ptr<ManagementAPIDelegate> delegate_;
+
DISALLOW_COPY_AND_ASSIGN(ManagementAPI);
};
} // namespace extensions
-#endif // CHROME_BROWSER_EXTENSIONS_API_MANAGEMENT_MANAGEMENT_API_H_
+#endif // EXTENSIONS_BROWSER_API_MANAGEMENT_MANAGEMENT_API_H_
« no previous file with comments | « extensions/browser/api/extensions_api_client.cc ('k') | extensions/browser/api/management/management_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698