diff options
Diffstat (limited to 'chrome')
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(); |