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

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

Issue 6992047: Change the web store private install API to accept a localized extension name. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased, removed test files I added in separate CL Created 9 years, 7 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 1dead6cdda7385cfd7dad83c7afecf3caee2df2b..a38d867e29cb192130a236a6d5d3e32b20ac779b 100644
--- a/chrome/browser/extensions/extension_webstore_private_api.cc
+++ b/chrome/browser/extensions/extension_webstore_private_api.cc
@@ -21,6 +21,7 @@
#include "chrome/common/chrome_switches.h"
#include "chrome/common/extensions/extension_constants.h"
#include "chrome/common/extensions/extension_error_utils.h"
+#include "chrome/common/extensions/extension_l10n_util.h"
#include "chrome/common/net/gaia/gaia_constants.h"
#include "content/browser/tab_contents/tab_contents.h"
#include "content/common/notification_details.h"
@@ -33,8 +34,13 @@
namespace {
+const char kIconDataKey[] = "iconData";
+const char kIdKey[] = "id";
+const char kLocalizedNameKey[] = "localizedName";
const char kLoginKey[] = "login";
+const char kManifestKey[] = "manifest";
const char kTokenKey[] = "token";
+
const char kImageDecodeError[] = "Image decode failed";
const char kInvalidIdError[] = "Invalid id";
const char kInvalidManifestError[] = "Invalid manifest";
@@ -283,15 +289,25 @@ bool BeginInstallWithManifestFunction::RunImpl() {
return false;
}
- EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &id_));
+ DictionaryValue* details = NULL;
+ EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(0, &details));
+ CHECK(details);
+
+ EXTENSION_FUNCTION_VALIDATE(details->GetString(kIdKey, &id_));
if (!Extension::IdIsValid(id_)) {
SetResult(INVALID_ID);
error_ = kInvalidIdError;
return false;
}
- EXTENSION_FUNCTION_VALIDATE(args_->GetString(1, &icon_data_));
- EXTENSION_FUNCTION_VALIDATE(args_->GetString(2, &manifest_));
+ EXTENSION_FUNCTION_VALIDATE(details->GetString(kManifestKey, &manifest_));
+
+ if (details->HasKey(kIconDataKey))
+ EXTENSION_FUNCTION_VALIDATE(details->GetString(kIconDataKey, &icon_data_));
+
+ if (details->HasKey(kLocalizedNameKey))
+ EXTENSION_FUNCTION_VALIDATE(details->GetString(kLocalizedNameKey,
+ &localized_name_));
scoped_refptr<SafeBeginInstallHelper> helper =
new SafeBeginInstallHelper(this, icon_data_, manifest_);
@@ -354,19 +370,29 @@ void BeginInstallWithManifestFunction::OnParseSuccess(
icon_ = icon;
parsed_manifest_.reset(parsed_manifest);
+ // If we were passed a localized name to use in the dialog, create a copy
+ // of the original manifest and replace the name in it.
+ scoped_ptr<DictionaryValue> localized_manifest;
+ if (!localized_name_.empty()) {
+ localized_manifest.reset(parsed_manifest->DeepCopy());
+ localized_manifest->SetString(extension_manifest_keys::kName,
+ localized_name_);
+ }
+
// Create a dummy extension and show the extension install confirmation
// dialog.
std::string init_errors;
dummy_extension_ = Extension::Create(
FilePath(),
Extension::INTERNAL,
- *static_cast<DictionaryValue*>(parsed_manifest_.get()),
+ localized_manifest.get() ? *localized_manifest.get() : *parsed_manifest,
Extension::NO_FLAGS,
&init_errors);
if (!dummy_extension_.get()) {
OnParseFailure(MANIFEST_ERROR, std::string(kInvalidManifestError));
return;
}
+
if (icon_.empty())
icon_ = Extension::GetDefaultIcon(dummy_extension_->is_app());
@@ -401,7 +427,10 @@ void BeginInstallWithManifestFunction::OnParseFailure(
}
void BeginInstallWithManifestFunction::InstallUIProceed() {
- CrxInstaller::SetWhitelistedManifest(id_, parsed_manifest_.release());
+ CrxInstaller::WhitelistEntry* entry = new CrxInstaller::WhitelistEntry;
+ entry->parsed_manifest.reset(parsed_manifest_.release());
+ entry->localized_name = localized_name_;
+ CrxInstaller::SetWhitelistEntry(id_, entry);
SetResult(ERROR_NONE);
SendResponse(true);
@@ -430,7 +459,7 @@ bool CompleteInstallFunction::RunImpl() {
}
if (!CrxInstaller::IsIdWhitelisted(id) &&
- !CrxInstaller::GetWhitelistedManifest(id)) {
+ !CrxInstaller::GetWhitelistEntry(id)) {
error_ = ExtensionErrorUtils::FormatErrorMessage(
kNoPreviousBeginInstallError, id);
return false;

Powered by Google App Engine
This is Rietveld 408576698