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

Unified Diff: chrome/browser/extensions/extension_webstore_private_api.h

Issue 8430033: Adds a webstorePrivate method for silently installing extensions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 9 years, 2 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/extension_webstore_private_api.h
diff --git a/chrome/browser/extensions/extension_webstore_private_api.h b/chrome/browser/extensions/extension_webstore_private_api.h
index f1021e1955e74bb6f33b3b5b862f9fd80143f315..90625e3b6e44cb0b2ca02d98695c9fd07d87313f 100644
--- a/chrome/browser/extensions/extension_webstore_private_api.h
+++ b/chrome/browser/extensions/extension_webstore_private_api.h
@@ -27,6 +27,9 @@ class WebstorePrivateApi {
// Allows you to override the WebstoreInstaller delegate for testing.
static void SetWebstoreInstallerDelegateForTesting(
WebstoreInstaller::Delegate* delegate);
+
+ // Lets tests provide an extension ID that can be installed silently.
+ static void SetTrustedIDForTesting(const char* extension_id);
};
class BeginInstallWithManifestFunction
@@ -109,6 +112,59 @@ class CompleteInstallFunction : public SyncExtensionFunction {
DECLARE_EXTENSION_FUNCTION_NAME("webstorePrivate.completeInstall");
};
+class SilentlyInstallFunction : public AsyncExtensionFunction,
+ public WebstoreInstallHelper::Delegate,
+ public WebstoreInstaller::Delegate {
+ public:
+ SilentlyInstallFunction();
+
+ // Result codes for the return value. If you change this, make sure to
+ // update the description for the silentlyInstall callback in
+ // extension_api.json.
+ enum ResultCode {
+ ERROR_NONE = 0,
+
+ // An unspecified error occurred.
+ UNKNOWN_ERROR,
+
+ // The manifest failed to parse correctly.
+ MANIFEST_ERROR,
+
+ // The extension id was invalid.
+ INVALID_ID,
+
+ // The page does not have permission to call this function.
+ PERMISSION_DENIED,
+ };
+
+ // WebstoreInstallHelper::Delegate implementation.
+ virtual void OnWebstoreParseSuccess(
+ const std::string& id,
+ const SkBitmap& icon,
+ base::DictionaryValue* parsed_manifest) OVERRIDE;
+ virtual void OnWebstoreParseFailure(
+ const std::string& id,
+ InstallHelperResultCode result_code,
+ const std::string& error_message) OVERRIDE;
+
+ // WebstoreInstaller::Delegate implementation.
+ virtual void OnExtensionInstallSuccess(const std::string& id) OVERRIDE;
+ virtual void OnExtensionInstallFailure(const std::string& id,
+ const std::string& error) OVERRIDE;
+
+ protected:
+ virtual ~SilentlyInstallFunction();
+ virtual bool RunImpl() OVERRIDE;
+
+ // Sets the result_ as a string based on |code|.
+ void SetResult(ResultCode code);
+
+ private:
+ std::string id_;
+ std::string manifest_;
+ DECLARE_EXTENSION_FUNCTION_NAME("webstorePrivate.silentlyInstall");
+};
+
class GetBrowserLoginFunction : public SyncExtensionFunction {
virtual bool RunImpl();
DECLARE_EXTENSION_FUNCTION_NAME("webstorePrivate.getBrowserLogin");

Powered by Google App Engine
This is Rietveld 408576698