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

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 c85b35dca22f86497d16092e7ba5d7c3b59ed951..485bb4b9ced496f514255e357e372507a9f34e72 100644
--- a/chrome/browser/extensions/extension_webstore_private_api.cc
+++ b/chrome/browser/extensions/extension_webstore_private_api.cc
@@ -34,6 +34,10 @@
#include "grit/generated_resources.h"
#include "ui/base/l10n/l10n_util.h"
+using webstore::BundleInstaller;
+using webstore::Item;
+using webstore::ItemList;
+
namespace {
const char kAppInstallBubbleKey[] = "appInstallBubble";
@@ -134,6 +138,68 @@ 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));
+
+ ItemList items;
+ if (!ReadBundleInfo(extensions, &items))
+ return false;
+
+ bundle_ = new BundleInstaller(profile(), items);
+
+ AddRef(); // Balanced in OnBundleInstallApproved and OnBundleInstallCanceled.
+
+ bundle_->PromptForApproval(this);
+ return true;
+}
+
+bool InstallBundleFunction::ReadBundleInfo(ListValue* extensions,
+ ItemList* items) {
+ for (size_t i = 0; i < extensions->GetSize(); ++i) {
+ DictionaryValue* details = NULL;
+ EXTENSION_FUNCTION_VALIDATE(extensions->GetDictionary(i, &details));
+
+ 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()),
+ 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