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

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

Issue 9414013: Add a webstore API for installing bundles of extensions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 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/extension_webstore_private_api.cc
diff --git a/chrome/browser/extensions/extension_webstore_private_api.cc b/chrome/browser/extensions/extension_webstore_private_api.cc
index 5517250c79aa96c36bcb4645c10b7ad4d5472978..c51e67c54c8d49ae15b3a867594fc2651d3cd732 100644
--- a/chrome/browser/extensions/extension_webstore_private_api.cc
+++ b/chrome/browser/extensions/extension_webstore_private_api.cc
@@ -36,6 +36,7 @@
#include "ui/base/l10n/l10n_util.h"
using content::GpuDataManager;
+using extensions::BundleInstaller;
namespace {
@@ -137,6 +138,69 @@ void WebstorePrivateApi::SetTrustTestIDsForTesting(bool allow) {
trust_test_ids = allow;
}
+InstallBundleFunction::InstallBundleFunction() {}
+InstallBundleFunction::~InstallBundleFunction() {}
+
+bool InstallBundleFunction::RunImpl() {
+ ListValue* extensions = NULL;
+ EXTENSION_FUNCTION_VALIDATE(args_->GetList(0, &extensions));
+
+ BundleInstaller::ItemList items;
+ if (!ReadBundleInfo(extensions, &items))
+ return false;
+
+ bundle_ = new BundleInstaller(profile(), items);
+
+ AddRef(); // Balanced in OnBundleInstallApproved and OnBundleInstallCanceled.
Yoyo Zhou 2012/02/22 00:20:26 in OnBundleInstallCompleted
jstritar 2012/02/22 15:45:48 Thanks for catching all those... forgot to change
+
+ bundle_->PromptForApproval(this);
+ return true;
+}
+
+bool InstallBundleFunction::ReadBundleInfo(ListValue* extensions,
+ BundleInstaller::ItemList* items) {
+ for (size_t i = 0; i < extensions->GetSize(); ++i) {
+ DictionaryValue* details = NULL;
+ EXTENSION_FUNCTION_VALIDATE(extensions->GetDictionary(i, &details));
+
+ BundleInstaller::Item item;
+ EXTENSION_FUNCTION_VALIDATE(details->GetString(
+ kIdKey, &item.id));
+ EXTENSION_FUNCTION_VALIDATE(details->GetString(
+ kManifestKey, &item.manifest));
+ EXTENSION_FUNCTION_VALIDATE(details->GetString(
+ kLocalizedNameKey, &item.localized_name));
+
+ items->push_back(item);
+ }
+
+ return true;
+}
+
+void InstallBundleFunction::OnBundleInstallApproved() {
+ bundle_->CompleteInstall(
+ &(dispatcher()->delegate()->GetAssociatedWebContents()->GetController()),
+ GetCurrentBrowser(),
+ this);
+}
+
+void InstallBundleFunction::OnBundleInstallCanceled(bool user_initiated) {
+ if (user_initiated)
+ error_ = "user_canceled";
+ else
+ error_ = "unknown_error";
+
+ SendResponse(false);
+
+ Release(); // Balanced in RunImpl().
+}
+
+void InstallBundleFunction::OnBundleInstallCompleted() {
+ SendResponse(true);
+
+ Release(); // Balanced in RunImpl().
+}
+
BeginInstallWithManifestFunction::BeginInstallWithManifestFunction()
: use_app_installed_bubble_(false) {}

Powered by Google App Engine
This is Rietveld 408576698