| // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| // 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_WEBSTORE_PRIVATE_WEBSTORE_PRIVATE_API_H_ |
| #define CHROME_BROWSER_EXTENSIONS_API_WEBSTORE_PRIVATE_WEBSTORE_PRIVATE_API_H_ |
| |
| #include <memory> |
| #include <string> |
| |
| #include "chrome/browser/bitmap_fetcher/bitmap_fetcher_delegate.h" |
| #include "chrome/browser/extensions/active_install_data.h" |
| #include "chrome/browser/extensions/chrome_extension_function_details.h" |
| #include "chrome/browser/extensions/extension_install_prompt.h" |
| #include "chrome/browser/extensions/webstore_install_helper.h" |
| #include "chrome/browser/extensions/webstore_installer.h" |
| #include "chrome/common/extensions/api/webstore_private.h" |
| #include "chrome/common/extensions/webstore_install_result.h" |
| #include "extensions/browser/extension_function.h" |
| #include "third_party/skia/include/core/SkBitmap.h" |
| |
| namespace content { |
| class GpuFeatureChecker; |
| } |
| |
| namespace extensions { |
| |
| class Extension; |
| |
| class WebstorePrivateApi { |
| public: |
| // Allows you to override the WebstoreInstaller delegate for testing. |
| static void SetWebstoreInstallerDelegateForTesting( |
| WebstoreInstaller::Delegate* delegate); |
| |
| // Gets the pending approval for the |extension_id| in |profile|. Pending |
| // approvals are held between the calls to beginInstallWithManifest and |
| // completeInstall. This should only be used for testing. |
| static std::unique_ptr<WebstoreInstaller::Approval> PopApprovalForTesting( |
| Profile* profile, |
| const std::string& extension_id); |
| }; |
| |
| class WebstorePrivateBeginInstallWithManifest3Function |
| : public UIThreadExtensionFunction, |
| public WebstoreInstallHelper::Delegate { |
| public: |
| DECLARE_EXTENSION_FUNCTION("webstorePrivate.beginInstallWithManifest3", |
| WEBSTOREPRIVATE_BEGININSTALLWITHMANIFEST3) |
| |
| WebstorePrivateBeginInstallWithManifest3Function(); |
| |
| private: |
| using Params = api::webstore_private::BeginInstallWithManifest3::Params; |
| |
| ~WebstorePrivateBeginInstallWithManifest3Function() override; |
| |
| // ExtensionFunction: |
| ExtensionFunction::ResponseAction Run() override; |
| |
| // WebstoreInstallHelper::Delegate: |
| void OnWebstoreParseSuccess( |
| const std::string& id, |
| const SkBitmap& icon, |
| std::unique_ptr<base::DictionaryValue> parsed_manifest) override; |
| void OnWebstoreParseFailure(const std::string& id, |
| InstallHelperResultCode result, |
| const std::string& error_message) override; |
| |
| void OnInstallPromptDone(ExtensionInstallPrompt::Result result); |
| |
| void HandleInstallProceed(); |
| void HandleInstallAbort(bool user_initiated); |
| |
| ExtensionFunction::ResponseValue BuildResponse( |
| api::webstore_private::Result result, |
| const std::string& error); |
| std::unique_ptr<base::ListValue> CreateResults( |
| api::webstore_private::Result result) const; |
| |
| const Params::Details& details() const { return params_->details; } |
| |
| ChromeExtensionFunctionDetails chrome_details_; |
| |
| std::unique_ptr<Params> params_; |
| |
| std::unique_ptr<ScopedActiveInstall> scoped_active_install_; |
| |
| std::unique_ptr<base::DictionaryValue> parsed_manifest_; |
| SkBitmap icon_; |
| |
| // A dummy Extension object we create for the purposes of using |
| // ExtensionInstallPrompt to prompt for confirmation of the install. |
| scoped_refptr<Extension> dummy_extension_; |
| |
| std::unique_ptr<ExtensionInstallPrompt> install_prompt_; |
| }; |
| |
| class WebstorePrivateCompleteInstallFunction |
| : public UIThreadExtensionFunction, |
| public WebstoreInstaller::Delegate { |
| public: |
| DECLARE_EXTENSION_FUNCTION("webstorePrivate.completeInstall", |
| WEBSTOREPRIVATE_COMPLETEINSTALL) |
| |
| WebstorePrivateCompleteInstallFunction(); |
| |
| private: |
| ~WebstorePrivateCompleteInstallFunction() override; |
| |
| // ExtensionFunction: |
| ExtensionFunction::ResponseAction Run() override; |
| |
| // WebstoreInstaller::Delegate: |
| void OnExtensionInstallSuccess(const std::string& id) override; |
| void OnExtensionInstallFailure( |
| const std::string& id, |
| const std::string& error, |
| WebstoreInstaller::FailureReason reason) override; |
| |
| void OnInstallSuccess(const std::string& id); |
| |
| ChromeExtensionFunctionDetails chrome_details_; |
| |
| std::unique_ptr<WebstoreInstaller::Approval> approval_; |
| std::unique_ptr<ScopedActiveInstall> scoped_active_install_; |
| }; |
| |
| class WebstorePrivateEnableAppLauncherFunction |
| : public UIThreadExtensionFunction { |
| public: |
| DECLARE_EXTENSION_FUNCTION("webstorePrivate.enableAppLauncher", |
| WEBSTOREPRIVATE_ENABLEAPPLAUNCHER) |
| |
| WebstorePrivateEnableAppLauncherFunction(); |
| |
| private: |
| ~WebstorePrivateEnableAppLauncherFunction() override; |
| |
| // ExtensionFunction: |
| ExtensionFunction::ResponseAction Run() override; |
| |
| ChromeExtensionFunctionDetails chrome_details_; |
| }; |
| |
| class WebstorePrivateGetBrowserLoginFunction |
| : public UIThreadExtensionFunction { |
| public: |
| DECLARE_EXTENSION_FUNCTION("webstorePrivate.getBrowserLogin", |
| WEBSTOREPRIVATE_GETBROWSERLOGIN) |
| |
| WebstorePrivateGetBrowserLoginFunction(); |
| |
| private: |
| ~WebstorePrivateGetBrowserLoginFunction() override; |
| |
| // ExtensionFunction: |
| ExtensionFunction::ResponseAction Run() override; |
| |
| ChromeExtensionFunctionDetails chrome_details_; |
| }; |
| |
| class WebstorePrivateGetStoreLoginFunction |
| : public UIThreadExtensionFunction { |
| public: |
| DECLARE_EXTENSION_FUNCTION("webstorePrivate.getStoreLogin", |
| WEBSTOREPRIVATE_GETSTORELOGIN) |
| |
| WebstorePrivateGetStoreLoginFunction(); |
| |
| private: |
| ~WebstorePrivateGetStoreLoginFunction() override; |
| |
| // ExtensionFunction: |
| ExtensionFunction::ResponseAction Run() override; |
| |
| ChromeExtensionFunctionDetails chrome_details_; |
| }; |
| |
| class WebstorePrivateSetStoreLoginFunction |
| : public UIThreadExtensionFunction { |
| public: |
| DECLARE_EXTENSION_FUNCTION("webstorePrivate.setStoreLogin", |
| WEBSTOREPRIVATE_SETSTORELOGIN) |
| |
| WebstorePrivateSetStoreLoginFunction(); |
| |
| private: |
| ~WebstorePrivateSetStoreLoginFunction() override; |
| |
| // ExtensionFunction: |
| ExtensionFunction::ResponseAction Run() override; |
| |
| ChromeExtensionFunctionDetails chrome_details_; |
| }; |
| |
| class WebstorePrivateGetWebGLStatusFunction |
| : public UIThreadExtensionFunction { |
| public: |
| DECLARE_EXTENSION_FUNCTION("webstorePrivate.getWebGLStatus", |
| WEBSTOREPRIVATE_GETWEBGLSTATUS) |
| |
| WebstorePrivateGetWebGLStatusFunction(); |
| |
| private: |
| ~WebstorePrivateGetWebGLStatusFunction() override; |
| |
| // ExtensionFunction: |
| ExtensionFunction::ResponseAction Run() override; |
| |
| void OnFeatureCheck(bool feature_allowed); |
| |
| scoped_refptr<content::GpuFeatureChecker> feature_checker_; |
| }; |
| |
| class WebstorePrivateGetIsLauncherEnabledFunction |
| : public UIThreadExtensionFunction { |
| public: |
| DECLARE_EXTENSION_FUNCTION("webstorePrivate.getIsLauncherEnabled", |
| WEBSTOREPRIVATE_GETISLAUNCHERENABLED) |
| |
| WebstorePrivateGetIsLauncherEnabledFunction(); |
| |
| private: |
| ~WebstorePrivateGetIsLauncherEnabledFunction() override; |
| |
| // ExtensionFunction: |
| ExtensionFunction::ResponseAction Run() override; |
| |
| void OnIsLauncherCheckCompleted(bool is_enabled); |
| }; |
| |
| class WebstorePrivateIsInIncognitoModeFunction |
| : public UIThreadExtensionFunction { |
| public: |
| DECLARE_EXTENSION_FUNCTION("webstorePrivate.isInIncognitoMode", |
| WEBSTOREPRIVATE_ISININCOGNITOMODEFUNCTION) |
| |
| WebstorePrivateIsInIncognitoModeFunction(); |
| |
| private: |
| ~WebstorePrivateIsInIncognitoModeFunction() override; |
| |
| // ExtensionFunction: |
| ExtensionFunction::ResponseAction Run() override; |
| |
| ChromeExtensionFunctionDetails chrome_details_; |
| }; |
| |
| class WebstorePrivateLaunchEphemeralAppFunction |
| : public UIThreadExtensionFunction { |
| public: |
| DECLARE_EXTENSION_FUNCTION("webstorePrivate.launchEphemeralApp", |
| WEBSTOREPRIVATE_LAUNCHEPHEMERALAPP) |
| |
| WebstorePrivateLaunchEphemeralAppFunction(); |
| |
| private: |
| ~WebstorePrivateLaunchEphemeralAppFunction() override; |
| |
| // ExtensionFunction: |
| ExtensionFunction::ResponseAction Run() override; |
| |
| void OnLaunchComplete(webstore_install::Result result, |
| const std::string& error); |
| |
| ExtensionFunction::ResponseValue BuildResponse( |
| api::webstore_private::Result result, |
| const std::string& error); |
| |
| ChromeExtensionFunctionDetails chrome_details_; |
| }; |
| |
| class WebstorePrivateGetEphemeralAppsEnabledFunction |
| : public UIThreadExtensionFunction { |
| public: |
| DECLARE_EXTENSION_FUNCTION("webstorePrivate.getEphemeralAppsEnabled", |
| WEBSTOREPRIVATE_GETEPHEMERALAPPSENABLED) |
| |
| WebstorePrivateGetEphemeralAppsEnabledFunction(); |
| |
| private: |
| ~WebstorePrivateGetEphemeralAppsEnabledFunction() override; |
| |
| // ExtensionFunction: |
| ExtensionFunction::ResponseAction Run() override; |
| }; |
| |
| class WebstorePrivateIsPendingCustodianApprovalFunction |
| : public UIThreadExtensionFunction { |
| public: |
| DECLARE_EXTENSION_FUNCTION("webstorePrivate.isPendingCustodianApproval", |
| WEBSTOREPRIVATE_ISPENDINGCUSTODIANAPPROVAL) |
| |
| WebstorePrivateIsPendingCustodianApprovalFunction(); |
| |
| private: |
| ~WebstorePrivateIsPendingCustodianApprovalFunction() override; |
| |
| // ExtensionFunction: |
| ExtensionFunction::ResponseAction Run() override; |
| |
| ExtensionFunction::ResponseValue BuildResponse(bool result); |
| |
| ChromeExtensionFunctionDetails chrome_details_; |
| }; |
| |
| class WebstorePrivateGetReferrerChainFunction |
| : public UIThreadExtensionFunction { |
| public: |
| DECLARE_EXTENSION_FUNCTION("webstorePrivate.getReferrerChain", |
| WEBSTOREPRIVATE_GETREFERRERCHAIN) |
| |
| WebstorePrivateGetReferrerChainFunction(); |
| |
| private: |
| ~WebstorePrivateGetReferrerChainFunction() override; |
| |
| // ExtensionFunction: |
| ExtensionFunction::ResponseAction Run() override; |
| |
| ChromeExtensionFunctionDetails chrome_details_; |
| |
| DISALLOW_COPY_AND_ASSIGN(WebstorePrivateGetReferrerChainFunction); |
| }; |
| |
| } // namespace extensions |
| |
| #endif // CHROME_BROWSER_EXTENSIONS_API_WEBSTORE_PRIVATE_WEBSTORE_PRIVATE_API_H_ |