diff options
author | zork@google.com <zork@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-09-15 23:43:42 +0000 |
---|---|---|
committer | zork@google.com <zork@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-09-15 23:43:42 +0000 |
commit | a9f4d90f8a1643ccc27aba95cf60c4531b3db7b9 (patch) | |
tree | 0f6069b618b1847b12cdba7d18e2ba8326073eed /chrome/renderer | |
parent | b2d85c6d595cd7b0b3807d2bb7849fee343d7394 (diff) | |
download | chromium_src-a9f4d90f8a1643ccc27aba95cf60c4531b3db7b9.zip chromium_src-a9f4d90f8a1643ccc27aba95cf60c4531b3db7b9.tar.gz chromium_src-a9f4d90f8a1643ccc27aba95cf60c4531b3db7b9.tar.bz2 |
Adding sync plugin messages, and plugin broadcasts to the renderer processes
Review URL: http://codereview.chromium.org/2411
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@2246 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer')
-rw-r--r-- | chrome/renderer/chrome_plugin_host.cc | 28 | ||||
-rw-r--r-- | chrome/renderer/render_thread.cc | 13 | ||||
-rw-r--r-- | chrome/renderer/render_thread.h | 2 |
3 files changed, 42 insertions, 1 deletions
diff --git a/chrome/renderer/chrome_plugin_host.cc b/chrome/renderer/chrome_plugin_host.cc index ea370af..b087902 100644 --- a/chrome/renderer/chrome_plugin_host.cc +++ b/chrome/renderer/chrome_plugin_host.cc @@ -495,6 +495,32 @@ CPError STDCALL CPB_SendMessage(CPID id, const void *data, uint32 data_len) { return CPERR_SUCCESS; } +CPError STDCALL CPB_SendSyncMessage(CPID id, const void *data, uint32 data_len, + void **retval, uint32 *retval_len) { + CHECK(ChromePluginLib::IsPluginThread()); + ChromePluginLib* plugin = ChromePluginLib::FromCPID(id); + CHECK(plugin); + + const uint8* data_ptr = static_cast<const uint8*>(data); + std::vector<uint8> v(data_ptr, data_ptr + data_len); + std::vector<uint8> r; + if (!RenderThread::current()->Send(new ViewHostMsg_PluginSyncMessage( + plugin->filename(), v, &r))) { + return CPERR_FAILURE; + } + + if (r.size()) { + *retval_len = static_cast<uint32>(r.size()); + *retval = CPB_Alloc(*retval_len); + memcpy(*retval, &(r.at(0)), r.size()); + } else { + *retval = NULL; + *retval_len = 0; + } + + return CPERR_SUCCESS; +} + } // namespace CPBrowserFuncs* GetCPBrowserFuncsForRenderer() { @@ -523,6 +549,7 @@ CPBrowserFuncs* GetCPBrowserFuncsForRenderer() { browser_funcs.get_command_line_arguments = CPB_GetCommandLineArguments; browser_funcs.add_ui_command = CPB_AddUICommand; browser_funcs.handle_command = CPB_HandleCommand; + browser_funcs.send_sync_message = CPB_SendSyncMessage; browser_funcs.request_funcs = &request_funcs; browser_funcs.response_funcs = &response_funcs; @@ -546,4 +573,3 @@ CPBrowserFuncs* GetCPBrowserFuncsForRenderer() { return &browser_funcs; } - diff --git a/chrome/renderer/render_thread.cc b/chrome/renderer/render_thread.cc index 97f71b5..c389860 100644 --- a/chrome/renderer/render_thread.cc +++ b/chrome/renderer/render_thread.cc @@ -10,6 +10,7 @@ #include "base/lazy_instance.h" #include "base/shared_memory.h" #include "base/thread_local.h" +#include "chrome/common/chrome_plugin_lib.h" #include "chrome/common/ipc_logging.h" #include "chrome/common/notification_service.h" #include "chrome/plugin/plugin_channel.h" @@ -161,6 +162,7 @@ void RenderThread::OnMessageReceived(const IPC::Message& msg) { IPC_MESSAGE_HANDLER(ViewMsg_SetCacheCapacities, OnSetCacheCapacities) IPC_MESSAGE_HANDLER(ViewMsg_GetCacheResourceStats, OnGetCacheResourceStats) + IPC_MESSAGE_HANDLER(ViewMsg_PluginMessage, OnPluginMessage) // send the rest to the router IPC_MESSAGE_UNHANDLED(router_.OnMessageReceived(msg)) IPC_END_MESSAGE_MAP() @@ -169,6 +171,17 @@ void RenderThread::OnMessageReceived(const IPC::Message& msg) { } } +void RenderThread::OnPluginMessage(const std::wstring& dll_path, + const std::vector<uint8>& data) { + CHECK(ChromePluginLib::IsPluginThread()); + ChromePluginLib *chrome_plugin = ChromePluginLib::Find(dll_path); + if (chrome_plugin) { + void *data_ptr = const_cast<void*>(reinterpret_cast<const void*>(&data[0])); + uint32 data_len = static_cast<uint32>(data.size()); + chrome_plugin->functions().on_message(data_ptr, data_len); + } +} + void RenderThread::OnSetNextPageID(int32 next_page_id) { // This should only be called at process initialization time, so we shouldn't // have to worry about thread-safety. diff --git a/chrome/renderer/render_thread.h b/chrome/renderer/render_thread.h index 50e022a..4dc9b99 100644 --- a/chrome/renderer/render_thread.h +++ b/chrome/renderer/render_thread.h @@ -75,6 +75,8 @@ class RenderThread : public IPC::Channel::Listener, private: void OnUpdateVisitedLinks(SharedMemoryHandle table); + void OnPluginMessage(const std::wstring& dll_path, + const std::vector<uint8>& data); void OnSetNextPageID(int32 next_page_id); void OnCreateNewView(HWND parent_hwnd, HANDLE modal_dialog_event, |