| 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) {}
|
|
|
|
|