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

Unified Diff: chrome/browser/extensions/api/webstore_private/webstore_private_api.h

Issue 850283003: Add a new webstorePrivate API to show a permission prompt for delegated installs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@testext_permission_prompt
Patch Set: common base class Created 5 years, 10 months 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: chrome/browser/extensions/api/webstore_private/webstore_private_api.h
diff --git a/chrome/browser/extensions/api/webstore_private/webstore_private_api.h b/chrome/browser/extensions/api/webstore_private/webstore_private_api.h
index 06436443a5092b233d0f766999e23e55e9ab4a6d..be189d08e3c4f064159b19621da7932e77680f94 100644
--- a/chrome/browser/extensions/api/webstore_private/webstore_private_api.h
+++ b/chrome/browser/extensions/api/webstore_private/webstore_private_api.h
@@ -34,19 +34,43 @@ class WebstorePrivateApi {
Profile* profile, const std::string& extension_id);
};
-class WebstorePrivateBeginInstallWithManifest3Function
+// Base class for webstorePrivate functions that show a permission prompt.
+template<typename Params>
+class WebstorePrivateFunctionWithPermissionPrompt
: public UIThreadExtensionFunction,
public ExtensionInstallPrompt::Delegate,
public WebstoreInstallHelper::Delegate {
public:
- DECLARE_EXTENSION_FUNCTION("webstorePrivate.beginInstallWithManifest3",
- WEBSTOREPRIVATE_BEGININSTALLWITHMANIFEST3)
+ WebstorePrivateFunctionWithPermissionPrompt();
- WebstorePrivateBeginInstallWithManifest3Function();
+ protected:
+ ~WebstorePrivateFunctionWithPermissionPrompt() override;
- private:
- ~WebstorePrivateBeginInstallWithManifest3Function() override;
+ // May be implemented by subclasses to add their own code to the
+ // ExtensionFunction::Run implementation. Return true and fill |result| and
+ // |error| to trigger an immediate response.
+ virtual bool RunImpl(api::webstore_private::Result* result,
+ std::string* error);
+
+ // Must be implemented by subclasses to call one of the Confirm* methods on
+ // |install_prompt|.
+ virtual void ShowPrompt(ExtensionInstallPrompt* install_prompt) = 0;
+
+ virtual void OnInstallUIProceed() {}
+ virtual void OnInstallUIAbort(bool user_initiated) {}
+
+ virtual ExtensionFunction::ResponseValue BuildResponse(
+ api::webstore_private::Result result, const std::string& error) = 0;
+
+ const Params& params() const { return *params_; }
+ const SkBitmap& icon() const { return icon_; }
+ const scoped_refptr<Extension>& dummy_extension() const {
+ return dummy_extension_;
+ }
+ scoped_ptr<base::DictionaryValue> PassParsedManifest();
+
+ private:
// ExtensionFunction:
ExtensionFunction::ResponseAction Run() override;
@@ -62,17 +86,10 @@ class WebstorePrivateBeginInstallWithManifest3Function
void InstallUIProceed() override;
void InstallUIAbort(bool user_initiated) override;
- // Response helpers.
- ExtensionFunction::ResponseValue BuildResponseForSuccess();
- ExtensionFunction::ResponseValue BuildResponseForError(
- api::webstore_private::Result result, const std::string& error);
-
- ChromeExtensionFunctionDetails chrome_details_;
-
// This stores the input parameters to the function.
- scoped_ptr<api::webstore_private::BeginInstallWithManifest3::Params> params_;
+ scoped_ptr<Params> params_;
- // The results of parsing manifest_ and icon_data_ go into these two.
+ // The results of parsing manifest_ and icon_data_.
scoped_ptr<base::DictionaryValue> parsed_manifest_;
SkBitmap icon_;
@@ -82,12 +99,31 @@ class WebstorePrivateBeginInstallWithManifest3Function
// The class that displays the install prompt.
scoped_ptr<ExtensionInstallPrompt> install_prompt_;
+};
- scoped_ptr<ScopedActiveInstall> scoped_active_install_;
+class WebstorePrivateBeginInstallWithManifest3Function
+ : public WebstorePrivateFunctionWithPermissionPrompt
+ <api::webstore_private::BeginInstallWithManifest3::Params> {
+ public:
+ DECLARE_EXTENSION_FUNCTION("webstorePrivate.beginInstallWithManifest3",
+ WEBSTOREPRIVATE_BEGININSTALLWITHMANIFEST3)
+
+ WebstorePrivateBeginInstallWithManifest3Function();
+
+ private:
+ ~WebstorePrivateBeginInstallWithManifest3Function() override;
+
+ bool RunImpl(api::webstore_private::Result* result,
+ std::string* error) override;
+ void ShowPrompt(ExtensionInstallPrompt* install_prompt) override;
+ void OnInstallUIProceed() override;
+ void OnInstallUIAbort(bool user_initiated) override;
+ ExtensionFunction::ResponseValue BuildResponse(
+ api::webstore_private::Result result, const std::string& error) override;
+
+ ChromeExtensionFunctionDetails chrome_details_;
- // The authuser query parameter value which should be used with CRX download
- // requests. This is empty if authuser should not be set on download requests.
- std::string authuser_;
+ scoped_ptr<ScopedActiveInstall> scoped_active_install_;
};
class WebstorePrivateCompleteInstallFunction
@@ -120,6 +156,26 @@ class WebstorePrivateCompleteInstallFunction
scoped_ptr<ScopedActiveInstall> scoped_active_install_;
};
+class WebstorePrivateShowPermissionPromptForDelegatedInstallFunction
+ : public WebstorePrivateFunctionWithPermissionPrompt
+ <api::webstore_private::ShowPermissionPromptForDelegatedInstall::
+ Params> {
+ public:
+ DECLARE_EXTENSION_FUNCTION(
+ "webstorePrivate.showPermissionPromptForDelegatedInstall",
+ WEBSTOREPRIVATE_SHOWPERMISSIONPROMPTFORDELEGATEDINSTALL)
+
+ WebstorePrivateShowPermissionPromptForDelegatedInstallFunction();
+
+ private:
+ ~WebstorePrivateShowPermissionPromptForDelegatedInstallFunction() override;
+
+ void ShowPrompt(ExtensionInstallPrompt* install_prompt) override;
+ ExtensionFunction::ResponseValue BuildResponse(
+ api::webstore_private::Result result,
+ const std::string& error) override;
+};
+
class WebstorePrivateEnableAppLauncherFunction
: public UIThreadExtensionFunction {
public:

Powered by Google App Engine
This is Rietveld 408576698