summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcira@chromium.org <cira@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-18 22:25:15 +0000
committercira@chromium.org <cira@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-18 22:25:15 +0000
commite585f48a189f0e6558c6adc583738c6271980f98 (patch)
tree34e0caf11180c2aaa859e0539984b326ff84685d
parent493471842fef2fc2bee331a715058cc3c4839c95 (diff)
downloadchromium_src-e585f48a189f0e6558c6adc583738c6271980f98.zip
chromium_src-e585f48a189f0e6558c6adc583738c6271980f98.tar.gz
chromium_src-e585f48a189f0e6558c6adc583738c6271980f98.tar.bz2
Adding @@extension_id reserved message to l10n message map for extension.
It's added outside of ExtensionMessageBundle so that non-localized extensions can use it. Developer doesn't have to define default_locale in the manifest in order to get it working. With this change every extension css file will go through message replacement process (only localized extensions went through that before). This change will allow following construct in extension css: body { background-image:url('chrome-extension://__MSG_@@extension_id__/background.png'); } BUG=35208 TEST=Add an background image to your extension, and refer to it from css file using __MSG_@@extension_id__. Image should show up in the background. Review URL: http://codereview.chromium.org/628009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@39385 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/renderer_host/resource_message_filter.cc8
-rw-r--r--chrome/browser/renderer_host/resource_message_filter.h1
-rw-r--r--chrome/common/extensions/extension_message_bundle.cc1
-rw-r--r--chrome/common/extensions/extension_message_bundle.h4
-rw-r--r--chrome/common/extensions/extension_message_filter_peer.cc7
-rw-r--r--chrome/renderer/extensions/renderer_extension_bindings.cc3
6 files changed, 15 insertions, 9 deletions
diff --git a/chrome/browser/renderer_host/resource_message_filter.cc b/chrome/browser/renderer_host/resource_message_filter.cc
index 92efd4b..71830f7 100644
--- a/chrome/browser/renderer_host/resource_message_filter.cc
+++ b/chrome/browser/renderer_host/resource_message_filter.cc
@@ -1356,11 +1356,12 @@ void ResourceMessageFilter::OnGetExtensionMessageBundle(
ChromeThread::FILE, FROM_HERE,
NewRunnableMethod(
this, &ResourceMessageFilter::OnGetExtensionMessageBundleOnFileThread,
- extension_path, default_locale, reply_msg));
+ extension_path, extension_id, default_locale, reply_msg));
}
void ResourceMessageFilter::OnGetExtensionMessageBundleOnFileThread(
const FilePath& extension_path,
+ const std::string& extension_id,
const std::string& default_locale,
IPC::Message* reply_msg) {
DCHECK(ChromeThread::CurrentlyOn(ChromeThread::FILE));
@@ -1377,6 +1378,11 @@ void ResourceMessageFilter::OnGetExtensionMessageBundleOnFileThread(
dictionary_map = *bundle->dictionary();
}
+ // Add @@extension_id reserved message here, so it's available to
+ // non-localized extensions too.
+ dictionary_map.insert(
+ std::make_pair(ExtensionMessageBundle::kExtensionIdKey, extension_id));
+
ViewHostMsg_GetExtensionMessageBundle::WriteReplyParams(
reply_msg, dictionary_map);
diff --git a/chrome/browser/renderer_host/resource_message_filter.h b/chrome/browser/renderer_host/resource_message_filter.h
index 82070fb..2712d48 100644
--- a/chrome/browser/renderer_host/resource_message_filter.h
+++ b/chrome/browser/renderer_host/resource_message_filter.h
@@ -311,6 +311,7 @@ class ResourceMessageFilter : public IPC::ChannelProxy::MessageFilter,
IPC::Message* reply_msg);
void OnGetExtensionMessageBundleOnFileThread(
const FilePath& extension_path,
+ const std::string& extension_id,
const std::string& default_locale,
IPC::Message* reply_msg);
diff --git a/chrome/common/extensions/extension_message_bundle.cc b/chrome/common/extensions/extension_message_bundle.cc
index 0256914..04301f9 100644
--- a/chrome/common/extensions/extension_message_bundle.cc
+++ b/chrome/common/extensions/extension_message_bundle.cc
@@ -37,6 +37,7 @@ const char* ExtensionMessageBundle::kBidiReversedDirectionKey =
"@@bidi_reversed_dir";
const char* ExtensionMessageBundle::kBidiStartEdgeKey = "@@bidi_start_edge";
const char* ExtensionMessageBundle::kBidiEndEdgeKey = "@@bidi_end_edge";
+const char* ExtensionMessageBundle::kExtensionIdKey = "@@extension_id";
// Reserved messages values.
const char* ExtensionMessageBundle::kBidiLeftEdgeValue = "left";
diff --git a/chrome/common/extensions/extension_message_bundle.h b/chrome/common/extensions/extension_message_bundle.h
index 6e59fe3..d483ba0 100644
--- a/chrome/common/extensions/extension_message_bundle.h
+++ b/chrome/common/extensions/extension_message_bundle.h
@@ -40,6 +40,10 @@ class ExtensionMessageBundle {
static const char* kBidiReversedDirectionKey;
static const char* kBidiStartEdgeKey;
static const char* kBidiEndEdgeKey;
+ // Extension id gets added in the
+ // browser/renderer_host/resource_message_filter.cc to enable message
+ // replacement for non-localized extensions.
+ static const char* kExtensionIdKey;
// Values for some of the reserved messages.
static const char* kBidiLeftEdgeValue;
diff --git a/chrome/common/extensions/extension_message_filter_peer.cc b/chrome/common/extensions/extension_message_filter_peer.cc
index 1c0c1d0..8d58378 100644
--- a/chrome/common/extensions/extension_message_filter_peer.cc
+++ b/chrome/common/extensions/extension_message_filter_peer.cc
@@ -110,8 +110,8 @@ void ExtensionMessageFilterPeer::ReplaceMessages() {
message_sender_->Send(new ViewHostMsg_GetExtensionMessageBundle(
extension_id, &messages));
- // Save messages we got, even if they are empty, so we don't have to
- // ask again.
+ // Save messages we got, so we don't have to ask again.
+ // Messages map is never empty, it contains at least @@extension_id value.
ExtensionToL10nMessagesMap& l10n_messages_map =
*GetExtensionToL10nMessagesMap();
l10n_messages_map[extension_id] = messages;
@@ -119,9 +119,6 @@ void ExtensionMessageFilterPeer::ReplaceMessages() {
l10n_messages = GetL10nMessagesMap(extension_id);
}
- if (l10n_messages->empty())
- return;
-
std::string error;
if (ExtensionMessageBundle::ReplaceMessagesWithExternalDictionary(
*l10n_messages, &data_, &error)) {
diff --git a/chrome/renderer/extensions/renderer_extension_bindings.cc b/chrome/renderer/extensions/renderer_extension_bindings.cc
index 2f50143..5e78932b 100644
--- a/chrome/renderer/extensions/renderer_extension_bindings.cc
+++ b/chrome/renderer/extensions/renderer_extension_bindings.cc
@@ -198,9 +198,6 @@ class ExtensionImpl : public ExtensionBase {
renderview->Send(new ViewHostMsg_GetExtensionMessageBundle(
extension_id, &messages));
- if (messages.empty())
- return v8::Undefined();
-
// Save messages we got.
ExtensionToL10nMessagesMap& l10n_messages_map =
*GetExtensionToL10nMessagesMap();