summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormpcomplete@chromium.org <mpcomplete@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-17 23:15:05 +0000
committermpcomplete@chromium.org <mpcomplete@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-17 23:15:05 +0000
commit08ee98d4104c901b57550cf1773fd294bd72585f (patch)
treee111c78c3b53d1dd357129db2bf0d8949220225b
parent5ddaa0ac4c4d01677f469e65a02ff584d3035de2 (diff)
downloadchromium_src-08ee98d4104c901b57550cf1773fd294bd72585f.zip
chromium_src-08ee98d4104c901b57550cf1773fd294bd72585f.tar.gz
chromium_src-08ee98d4104c901b57550cf1773fd294bd72585f.tar.bz2
Allow localization of omnibox.keyword.
Also change omnibox_keyword -> omnibox.keyword. BUG=63448,63449 TEST=unit tests Review URL: http://codereview.chromium.org/5172002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@66538 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/common/extensions/docs/examples/api/omnibox/extension-docs/manifest.json2
-rw-r--r--chrome/common/extensions/docs/examples/api/omnibox/simple-example/manifest.json2
-rw-r--r--chrome/common/extensions/docs/examples/extensions/chrome_search/manifest.json14
-rw-r--r--chrome/common/extensions/extension.cc2
-rw-r--r--chrome/common/extensions/extension_constants.cc5
-rw-r--r--chrome/common/extensions/extension_constants.h1
-rw-r--r--chrome/common/extensions/extension_l10n_util.cc4
-rw-r--r--chrome/common/extensions/extension_l10n_util_unittest.cc33
-rw-r--r--chrome/test/data/extensions/api_test/omnibox/manifest.json2
9 files changed, 50 insertions, 15 deletions
diff --git a/chrome/common/extensions/docs/examples/api/omnibox/extension-docs/manifest.json b/chrome/common/extensions/docs/examples/api/omnibox/extension-docs/manifest.json
index 8e6b3b9..8ed1c36 100644
--- a/chrome/common/extensions/docs/examples/api/omnibox/extension-docs/manifest.json
+++ b/chrome/common/extensions/docs/examples/api/omnibox/extension-docs/manifest.json
@@ -11,6 +11,6 @@
"16" : "icon-16.png",
"128" : "icon-128.png"
},
- "omnibox_keyword" : "crdoc",
+ "omnibox": { "keyword" : "crdoc" },
"background_page" : "background.html"
}
diff --git a/chrome/common/extensions/docs/examples/api/omnibox/simple-example/manifest.json b/chrome/common/extensions/docs/examples/api/omnibox/simple-example/manifest.json
index c48a345..41fdcb5 100644
--- a/chrome/common/extensions/docs/examples/api/omnibox/simple-example/manifest.json
+++ b/chrome/common/extensions/docs/examples/api/omnibox/simple-example/manifest.json
@@ -4,5 +4,5 @@
"version": "1.0",
"permissions": [ "experimental" ],
"background_page": "background.html",
- "omnibox_keyword": "omnix"
+ "omnibox": { "keyword" : "omnix" }
}
diff --git a/chrome/common/extensions/docs/examples/extensions/chrome_search/manifest.json b/chrome/common/extensions/docs/examples/extensions/chrome_search/manifest.json
index 3eee569af..61112cb 100644
--- a/chrome/common/extensions/docs/examples/extensions/chrome_search/manifest.json
+++ b/chrome/common/extensions/docs/examples/extensions/chrome_search/manifest.json
@@ -1,9 +1,9 @@
{
- "background_page": "background.html",
- "description": "Add support to the omnibox to search the Chromium source code.",
- "key": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDRx0y4f/CuomPPeGxcVMo7yfYZ1apxD+9e3ItNtPRBi8WMmzG0xhjnqvm03LTfTljbzA1L93s31HkjS5Bd12qM8SSZxOOizsZveK1tdpX0QelikSUaz1wwIyjatoC/jJy7vuuk0j5kPeLkNAhYGJTqN3H/Pqt0lFF1VFX4+fCEvQIDAQAB",
- "name": "Chromium Search",
- "omnibox_keyword": "src",
- "permissions": [ "experimental", "tabs", "http://www.google.com/" ],
- "version": "4"
+ "background_page": "background.html",
+ "description": "Add support to the omnibox to search the Chromium source code.",
+ "key": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDRx0y4f/CuomPPeGxcVMo7yfYZ1apxD+9e3ItNtPRBi8WMmzG0xhjnqvm03LTfTljbzA1L93s31HkjS5Bd12qM8SSZxOOizsZveK1tdpX0QelikSUaz1wwIyjatoC/jJy7vuuk0j5kPeLkNAhYGJTqN3H/Pqt0lFF1VFX4+fCEvQIDAQAB",
+ "name": "Chromium Search",
+ "omnibox": { "keyword" : "src" },
+ "permissions": [ "experimental", "tabs", "http://www.google.com/" ],
+ "version": "4"
}
diff --git a/chrome/common/extensions/extension.cc b/chrome/common/extensions/extension.cc
index e46001b..a7e827a 100644
--- a/chrome/common/extensions/extension.cc
+++ b/chrome/common/extensions/extension.cc
@@ -1774,7 +1774,7 @@ bool Extension::InitFromValue(const DictionaryValue& source, bool require_key,
}
}
- if (source.HasKey(keys::kOmniboxKeyword)) {
+ if (source.HasKey(keys::kOmnibox)) {
if (!source.GetString(keys::kOmniboxKeyword,
&omnibox_keyword_) ||
omnibox_keyword_.empty()) {
diff --git a/chrome/common/extensions/extension_constants.cc b/chrome/common/extensions/extension_constants.cc
index 9516f39..4bfc456 100644
--- a/chrome/common/extensions/extension_constants.cc
+++ b/chrome/common/extensions/extension_constants.cc
@@ -33,7 +33,8 @@ const char* kLaunchWidth = "app.launch.width";
const char* kMatches = "matches";
const char* kMinimumChromeVersion = "minimum_chrome_version";
const char* kName = "name";
-const char* kOmniboxKeyword = "omnibox_keyword";
+const char* kOmnibox = "omnibox";
+const char* kOmniboxKeyword = "omnibox.keyword";
const char* kOptionsPage = "options_page";
const char* kPageAction = "page_action";
const char* kPageActionDefaultIcon = "default_icon";
@@ -167,7 +168,7 @@ const char* kInvalidMinimumChromeVersion =
const char* kInvalidName =
"Required value 'name' is missing or invalid.";
const char* kInvalidOmniboxKeyword =
- "Invalid value for 'omnibox_keyword'.";
+ "Invalid value for 'omnibox.keyword'.";
const char* kInvalidOptionsPage =
"Invalid value for 'options_page'.";
const char* kInvalidOptionsPageExpectUrlInPackage =
diff --git a/chrome/common/extensions/extension_constants.h b/chrome/common/extensions/extension_constants.h
index a32231e..4df8223 100644
--- a/chrome/common/extensions/extension_constants.h
+++ b/chrome/common/extensions/extension_constants.h
@@ -38,6 +38,7 @@ namespace extension_manifest_keys {
extern const char* kMatches;
extern const char* kMinimumChromeVersion;
extern const char* kName;
+ extern const char* kOmnibox;
extern const char* kOmniboxKeyword;
extern const char* kOptionsPage;
extern const char* kPageAction;
diff --git a/chrome/common/extensions/extension_l10n_util.cc b/chrome/common/extensions/extension_l10n_util.cc
index 8c7826c..34762fd 100644
--- a/chrome/common/extensions/extension_l10n_util.cc
+++ b/chrome/common/extensions/extension_l10n_util.cc
@@ -107,6 +107,10 @@ bool LocalizeManifest(const ExtensionMessageBundle& messages,
if (!LocalizeManifestValue(key, messages, manifest, error))
return false;
+ // Initialize omnibox.keyword.
+ if (!LocalizeManifestValue(keys::kOmniboxKeyword, messages, manifest, error))
+ return false;
+
// Add current locale key to the manifest, so we can overwrite prefs
// with new manifest when chrome locale changes.
manifest->SetString(keys::kCurrentLocale, CurrentLocaleOrDefault());
diff --git a/chrome/common/extensions/extension_l10n_util_unittest.cc b/chrome/common/extensions/extension_l10n_util_unittest.cc
index 2aafebb..1487452 100644
--- a/chrome/common/extensions/extension_l10n_util_unittest.cc
+++ b/chrome/common/extensions/extension_l10n_util_unittest.cc
@@ -241,13 +241,17 @@ ExtensionMessageBundle* CreateManifestBundle() {
action_title_tree->SetString("message", "action title");
catalog->Set("title", action_title_tree);
+ DictionaryValue* omnibox_keyword_tree = new DictionaryValue();
+ omnibox_keyword_tree->SetString("message", "omnibox keyword");
+ catalog->Set("omnibox_keyword", omnibox_keyword_tree);
+
std::vector<linked_ptr<DictionaryValue> > catalogs;
catalogs.push_back(catalog);
std::string error;
ExtensionMessageBundle* bundle =
- ExtensionMessageBundle::Create(catalogs, &error);
- EXPECT_TRUE(NULL != bundle);
+ ExtensionMessageBundle::Create(catalogs, &error);
+ EXPECT_TRUE(bundle);
EXPECT_TRUE(error.empty());
return bundle;
@@ -347,6 +351,31 @@ TEST(ExtensionL10nUtil, LocalizeManifestWithNameDescriptionDefaultTitleMsgs) {
EXPECT_TRUE(error.empty());
}
+TEST(ExtensionL10nUtil, LocalizeManifestWithNameDescriptionOmniboxMsgs) {
+ DictionaryValue manifest;
+ manifest.SetString(keys::kName, "__MSG_name__");
+ manifest.SetString(keys::kDescription, "__MSG_description__");
+ manifest.SetString(keys::kOmniboxKeyword, "__MSG_omnibox_keyword__");
+
+ std::string error;
+ scoped_ptr<ExtensionMessageBundle> messages(CreateManifestBundle());
+
+ EXPECT_TRUE(
+ extension_l10n_util::LocalizeManifest(*messages, &manifest, &error));
+
+ std::string result;
+ ASSERT_TRUE(manifest.GetString(keys::kName, &result));
+ EXPECT_EQ("name", result);
+
+ ASSERT_TRUE(manifest.GetString(keys::kDescription, &result));
+ EXPECT_EQ("description", result);
+
+ ASSERT_TRUE(manifest.GetString(keys::kOmniboxKeyword, &result));
+ EXPECT_EQ("omnibox keyword", result);
+
+ EXPECT_TRUE(error.empty());
+}
+
// Try with NULL manifest.
TEST(ExtensionL10nUtil, ShouldRelocalizeManifestWithNullManifest) {
ExtensionInfo info(NULL, "", FilePath(), Extension::LOAD);
diff --git a/chrome/test/data/extensions/api_test/omnibox/manifest.json b/chrome/test/data/extensions/api_test/omnibox/manifest.json
index 8d3a577..6313d5c 100644
--- a/chrome/test/data/extensions/api_test/omnibox/manifest.json
+++ b/chrome/test/data/extensions/api_test/omnibox/manifest.json
@@ -3,6 +3,6 @@
"version": "0.1",
"description": "end-to-end browser test for chrome.omnibox API",
"background_page": "test.html",
- "omnibox_keyword": "keyword",
+ "omnibox": { "keyword": "keyword" },
"permissions": ["experimental"]
}