diff options
author | cira@chromium.org <cira@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-17 18:30:53 +0000 |
---|---|---|
committer | cira@chromium.org <cira@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-17 18:30:53 +0000 |
commit | 696044b0f89347690ac2323670a7edf2ad4d2b2a (patch) | |
tree | 663da3b9c0bb0cfc7e37950941837c78937ed2e3 /chrome/renderer | |
parent | b79d7abdc9e7de5d17beca1ddcbfcd8c20e1cdd4 (diff) | |
download | chromium_src-696044b0f89347690ac2323670a7edf2ad4d2b2a.zip chromium_src-696044b0f89347690ac2323670a7edf2ad4d2b2a.tar.gz chromium_src-696044b0f89347690ac2323670a7edf2ad4d2b2a.tar.bz2 |
Load message catalogs on demand when chrome.i18n.getMessage needs them.
1. Added default locale to the url context
2. Removed old code that was uploading catalogs on load (to renderer)
3. Removed message bundle object from Extension class.
BUG=27361
TEST=Open Chrome with --lang=sr and load src\chrome\common\extensions\docs\examples\api\i18n\getMessage extension from chrome://extensions page. Click on icon and text in popup should be localized.
Review URL: http://codereview.chromium.org/463011
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@34846 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer')
-rw-r--r-- | chrome/renderer/extensions/extension_process_bindings.cc | 22 | ||||
-rw-r--r-- | chrome/renderer/render_thread.cc | 8 | ||||
-rw-r--r-- | chrome/renderer/render_thread.h | 3 |
3 files changed, 20 insertions, 13 deletions
diff --git a/chrome/renderer/extensions/extension_process_bindings.cc b/chrome/renderer/extensions/extension_process_bindings.cc index e7aef4b..540469f 100644 --- a/chrome/renderer/extensions/extension_process_bindings.cc +++ b/chrome/renderer/extensions/extension_process_bindings.cc @@ -423,8 +423,26 @@ class ExtensionImpl : public ExtensionBase { return v8::Undefined(); L10nMessagesMap* l10n_messages = GetL10nMessagesMap(extension_id); - if (!l10n_messages) - return v8::Undefined(); + if (!l10n_messages) { + // Get the current RenderView so that we can send a routed IPC message + // from the correct source. + RenderView* renderview = bindings_utils::GetRenderViewForCurrentContext(); + if (!renderview) + return v8::Undefined(); + + L10nMessagesMap messages; + // A sync call to load message catalogs for current extension. + renderview->Send(new ViewHostMsg_GetExtensionMessageBundle( + extension_id, &messages)); + + if (messages.empty()) + return v8::Undefined(); + + ExtensionProcessBindings::SetL10nMessages(extension_id, messages); + l10n_messages = GetL10nMessagesMap(extension_id); + if (!l10n_messages) + return v8::Undefined(); + } std::string message_name = *v8::String::AsciiValue(args[0]); std::string message = diff --git a/chrome/renderer/render_thread.cc b/chrome/renderer/render_thread.cc index df6dc42..d1ce79d 100644 --- a/chrome/renderer/render_thread.cc +++ b/chrome/renderer/render_thread.cc @@ -329,12 +329,6 @@ void RenderThread::OnDOMStorageEvent( params.storage_type_ == DOM_STORAGE_LOCAL); } -void RenderThread::OnExtensionSetL10nMessages( - const std::string& extension_id, - const std::map<std::string, std::string>& l10n_messages) { - ExtensionProcessBindings::SetL10nMessages(extension_id, l10n_messages); -} - void RenderThread::OnControlMessageReceived(const IPC::Message& msg) { // App cache messages are handled by a delegate. if (appcache_dispatcher_->OnMessageReceived(msg)) @@ -380,8 +374,6 @@ void RenderThread::OnControlMessageReceived(const IPC::Message& msg) { OnExtensionSetHostPermissions) IPC_MESSAGE_HANDLER(ViewMsg_DOMStorageEvent, OnDOMStorageEvent) - IPC_MESSAGE_HANDLER(ViewMsg_Extension_SetL10nMessages, - OnExtensionSetL10nMessages) #if defined(IPC_MESSAGE_LOG_ENABLED) IPC_MESSAGE_HANDLER(ViewMsg_SetIPCLoggingEnabled, OnSetIPCLoggingEnabled) diff --git a/chrome/renderer/render_thread.h b/chrome/renderer/render_thread.h index 2b5693a..6769b06 100644 --- a/chrome/renderer/render_thread.h +++ b/chrome/renderer/render_thread.h @@ -169,9 +169,6 @@ class RenderThread : public RenderThreadBase, void OnExtensionSetHostPermissions( const GURL& extension_url, const std::vector<URLPattern>& permissions); - void OnExtensionSetL10nMessages( - const std::string& extension_id, - const std::map<std::string, std::string>& l10n_messages); void OnSetNextPageID(int32 next_page_id); void OnSetCSSColors(const std::vector<CSSColors::CSSColorMapping>& colors); void OnCreateNewView(gfx::NativeViewId parent_hwnd, |