summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkalman@chromium.org <kalman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-17 05:13:45 +0000
committerkalman@chromium.org <kalman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-17 05:13:45 +0000
commit715ffe498a150b6ad85d19337e34eb4bbbf842cd (patch)
tree62a61b44a0e9c391f8ea741f3e746e6d699b60e8
parente0a760eddc624ca66b1836f39508845fe9ec8a86 (diff)
downloadchromium_src-715ffe498a150b6ad85d19337e34eb4bbbf842cd.zip
chromium_src-715ffe498a150b6ad85d19337e34eb4bbbf842cd.tar.gz
chromium_src-715ffe498a150b6ad85d19337e34eb4bbbf842cd.tar.bz2
Use the non-localized "canonical name" of an extension to write to its sync
data, rather than the localized name. BUG=123214 TEST=none Review URL: http://codereview.chromium.org/10086019 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@132543 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/extensions/extension_sync_data.cc2
-rw-r--r--chrome/common/extensions/extension.cc1
-rw-r--r--chrome/common/extensions/extension.h5
-rw-r--r--chrome/common/extensions/extension_manifests_unittest.cc5
4 files changed, 12 insertions, 1 deletions
diff --git a/chrome/browser/extensions/extension_sync_data.cc b/chrome/browser/extensions/extension_sync_data.cc
index 52d54a1..8d33e5c 100644
--- a/chrome/browser/extensions/extension_sync_data.cc
+++ b/chrome/browser/extensions/extension_sync_data.cc
@@ -43,7 +43,7 @@ ExtensionSyncData::ExtensionSyncData(const Extension& extension,
incognito_enabled_(incognito_enabled),
version_(*extension.version()),
update_url_(extension.update_url()),
- name_(extension.name()) {
+ name_(extension.non_localized_name()) {
}
ExtensionSyncData::~ExtensionSyncData() {}
diff --git a/chrome/common/extensions/extension.cc b/chrome/common/extensions/extension.cc
index 0e860fe..7f30fea 100644
--- a/chrome/common/extensions/extension.cc
+++ b/chrome/common/extensions/extension.cc
@@ -1135,6 +1135,7 @@ bool Extension::LoadName(string16* error) {
*error = ASCIIToUTF16(errors::kInvalidName);
return false;
}
+ non_localized_name_ = UTF16ToUTF8(localized_name);
base::i18n::AdjustStringForLocaleDirection(&localized_name);
name_ = UTF16ToUTF8(localized_name);
return true;
diff --git a/chrome/common/extensions/extension.h b/chrome/common/extensions/extension.h
index 9a5d575..23c0293 100644
--- a/chrome/common/extensions/extension.h
+++ b/chrome/common/extensions/extension.h
@@ -560,6 +560,7 @@ class Extension : public base::RefCountedThreadSafe<Extension> {
const Version* version() const { return version_.get(); }
const std::string VersionString() const;
const std::string& name() const { return name_; }
+ const std::string& non_localized_name() const { return non_localized_name_; }
const std::string public_key() const { return public_key_; }
const std::string& description() const { return description_; }
int manifest_version() const { return manifest_version_; }
@@ -869,6 +870,10 @@ class Extension : public base::RefCountedThreadSafe<Extension> {
// NOTE: Name is UTF-8 and may contain non-ascii characters.
std::string name_;
+ // A non-localized version of the extension's name. This is useful for
+ // debug output.
+ std::string non_localized_name_;
+
// The version of this extension's manifest. We increase the manifest
// version when making breaking changes to the extension system.
// Version 1 was the first manifest version (implied by a lack of a
diff --git a/chrome/common/extensions/extension_manifests_unittest.cc b/chrome/common/extensions/extension_manifests_unittest.cc
index 45ab26a..a08615b 100644
--- a/chrome/common/extensions/extension_manifests_unittest.cc
+++ b/chrome/common/extensions/extension_manifests_unittest.cc
@@ -254,6 +254,7 @@ TEST_F(ExtensionManifestTest, InitFromValueValid) {
EXPECT_TRUE(Extension::IdIsValid(extension->id()));
EXPECT_EQ("1.0.0.0", extension->VersionString());
EXPECT_EQ("my extension", extension->name());
+ EXPECT_EQ("my extension", extension->non_localized_name());
EXPECT_EQ(extension->id(), extension->url().host());
EXPECT_EQ(extension->path(), path);
EXPECT_EQ(path, extension->path());
@@ -384,6 +385,8 @@ TEST_F(ExtensionManifestTest, InitFromValueValidNameInRTL) {
"init_valid_name_no_rtl.json"));
string16 localized_name(ASCIIToUTF16("Dictionary (by Google)"));
+ EXPECT_EQ(localized_name, UTF8ToUTF16(extension->non_localized_name()));
+
base::i18n::AdjustStringForLocaleDirection(&localized_name);
EXPECT_EQ(localized_name, UTF8ToUTF16(extension->name()));
@@ -391,6 +394,8 @@ TEST_F(ExtensionManifestTest, InitFromValueValidNameInRTL) {
extension = LoadAndExpectSuccess("init_valid_name_strong_rtl.json");
localized_name = WideToUTF16(L"Dictionary (\x05D1\x05D2"L" Google)");
+ EXPECT_EQ(localized_name, UTF8ToUTF16(extension->non_localized_name()));
+
base::i18n::AdjustStringForLocaleDirection(&localized_name);
EXPECT_EQ(localized_name, UTF8ToUTF16(extension->name()));