| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/renderer/browser_plugin/browser_plugin_manager_impl.h" | 5 #include "content/renderer/browser_plugin/browser_plugin_manager_impl.h" |
| 6 | 6 |
| 7 #include "content/common/browser_plugin_messages.h" | 7 #include "content/common/browser_plugin_messages.h" |
| 8 #include "content/renderer/browser_plugin/browser_plugin.h" | 8 #include "content/renderer/browser_plugin/browser_plugin.h" |
| 9 #include "content/renderer/render_thread_impl.h" | 9 #include "content/renderer/render_thread_impl.h" |
| 10 #include "ui/gfx/point.h" | 10 #include "ui/gfx/point.h" |
| 11 #include "webkit/glue/webcursor.h" | 11 #include "webkit/glue/webcursor.h" |
| 12 | 12 |
| 13 namespace content { | 13 namespace content { |
| 14 | 14 |
| 15 BrowserPluginManagerImpl::BrowserPluginManagerImpl() { | 15 BrowserPluginManagerImpl::BrowserPluginManagerImpl( |
| 16 RenderViewImpl* render_view) |
| 17 : BrowserPluginManager(render_view) { |
| 16 } | 18 } |
| 17 | 19 |
| 18 BrowserPluginManagerImpl::~BrowserPluginManagerImpl() { | 20 BrowserPluginManagerImpl::~BrowserPluginManagerImpl() { |
| 19 } | 21 } |
| 20 | 22 |
| 21 BrowserPlugin* BrowserPluginManagerImpl::CreateBrowserPlugin( | 23 BrowserPlugin* BrowserPluginManagerImpl::CreateBrowserPlugin( |
| 22 RenderViewImpl* render_view, | 24 RenderViewImpl* render_view, |
| 23 WebKit::WebFrame* frame, | 25 WebKit::WebFrame* frame, |
| 24 const WebKit::WebPluginParams& params) { | 26 const WebKit::WebPluginParams& params) { |
| 25 return new BrowserPlugin(browser_plugin_counter_++, | 27 return new BrowserPlugin(browser_plugin_counter_++, |
| 26 render_view, | 28 render_view, |
| 27 frame, | 29 frame, |
| 28 params); | 30 params); |
| 29 } | 31 } |
| 30 | 32 |
| 31 bool BrowserPluginManagerImpl::Send(IPC::Message* msg) { | 33 bool BrowserPluginManagerImpl::Send(IPC::Message* msg) { |
| 32 return RenderThread::Get()->Send(msg); | 34 return RenderThread::Get()->Send(msg); |
| 33 } | 35 } |
| 34 | 36 |
| 35 bool BrowserPluginManagerImpl::OnControlMessageReceived( | 37 bool BrowserPluginManagerImpl::OnMessageReceived( |
| 36 const IPC::Message& message) { | 38 const IPC::Message& message) { |
| 37 DCHECK(CalledOnValidThread()); | |
| 38 bool handled = true; | 39 bool handled = true; |
| 39 IPC_BEGIN_MESSAGE_MAP(BrowserPluginManagerImpl, message) | 40 IPC_BEGIN_MESSAGE_MAP(BrowserPluginManagerImpl, message) |
| 40 IPC_MESSAGE_HANDLER(BrowserPluginMsg_UpdateRect, OnUpdateRect) | 41 IPC_MESSAGE_HANDLER(BrowserPluginMsg_UpdateRect, OnUpdateRect) |
| 41 IPC_MESSAGE_HANDLER(BrowserPluginMsg_GuestGone, OnGuestGone) | 42 IPC_MESSAGE_HANDLER(BrowserPluginMsg_GuestGone, OnGuestGone) |
| 42 IPC_MESSAGE_HANDLER(BrowserPluginMsg_AdvanceFocus, OnAdvanceFocus) | 43 IPC_MESSAGE_HANDLER(BrowserPluginMsg_AdvanceFocus, OnAdvanceFocus) |
| 43 IPC_MESSAGE_HANDLER(BrowserPluginMsg_GuestContentWindowReady, | 44 IPC_MESSAGE_HANDLER(BrowserPluginMsg_GuestContentWindowReady, |
| 44 OnGuestContentWindowReady) | 45 OnGuestContentWindowReady) |
| 45 IPC_MESSAGE_HANDLER(BrowserPluginMsg_ShouldAcceptTouchEvents, | 46 IPC_MESSAGE_HANDLER(BrowserPluginMsg_ShouldAcceptTouchEvents, |
| 46 OnShouldAcceptTouchEvents) | 47 OnShouldAcceptTouchEvents) |
| 47 IPC_MESSAGE_HANDLER(BrowserPluginMsg_LoadStart, OnLoadStart) | 48 IPC_MESSAGE_HANDLER(BrowserPluginMsg_LoadStart, OnLoadStart) |
| 48 IPC_MESSAGE_HANDLER(BrowserPluginMsg_LoadAbort, OnLoadAbort) | 49 IPC_MESSAGE_HANDLER(BrowserPluginMsg_LoadAbort, OnLoadAbort) |
| 49 IPC_MESSAGE_HANDLER(BrowserPluginMsg_LoadRedirect, OnLoadRedirect) | 50 IPC_MESSAGE_HANDLER(BrowserPluginMsg_LoadRedirect, OnLoadRedirect) |
| 50 IPC_MESSAGE_HANDLER(BrowserPluginMsg_LoadCommit, OnLoadCommit) | 51 IPC_MESSAGE_HANDLER(BrowserPluginMsg_LoadCommit, OnLoadCommit) |
| 51 IPC_MESSAGE_HANDLER(BrowserPluginMsg_LoadStop, OnLoadStop) | 52 IPC_MESSAGE_HANDLER(BrowserPluginMsg_LoadStop, OnLoadStop) |
| 52 IPC_MESSAGE_HANDLER(BrowserPluginMsg_SetCursor, OnSetCursor) | 53 IPC_MESSAGE_HANDLER(BrowserPluginMsg_SetCursor, OnSetCursor) |
| 53 IPC_MESSAGE_HANDLER(BrowserPluginMsg_PluginAtPositionRequest, | 54 IPC_MESSAGE_HANDLER(BrowserPluginMsg_PluginAtPositionRequest, |
| 54 OnPluginAtPositionRequest); | 55 OnPluginAtPositionRequest); |
| 55 IPC_MESSAGE_UNHANDLED(handled = false) | 56 IPC_MESSAGE_UNHANDLED(handled = false) |
| 56 IPC_END_MESSAGE_MAP() | 57 IPC_END_MESSAGE_MAP() |
| 57 return handled; | 58 return handled; |
| 58 } | 59 } |
| 59 | 60 |
| 60 void BrowserPluginManagerImpl::OnPluginAtPositionRequest( | 61 void BrowserPluginManagerImpl::OnPluginAtPositionRequest( |
| 61 int source_routing_id, int request_id, const gfx::Point& position) { | 62 int request_id, const gfx::Point& position) { |
| 62 int instance_id = -1; | 63 int instance_id = -1; |
| 63 IDMap<BrowserPlugin>::iterator it(&instances_); | 64 IDMap<BrowserPlugin>::iterator it(&instances_); |
| 64 gfx::Point local_position = position; | 65 gfx::Point local_position = position; |
| 66 int source_routing_id = -1; |
| 65 while (!it.IsAtEnd()) { | 67 while (!it.IsAtEnd()) { |
| 66 const BrowserPlugin* plugin = it.GetCurrentValue(); | 68 const BrowserPlugin* plugin = it.GetCurrentValue(); |
| 67 // We need to check the plugin's routing id too since BrowserPluginManager | 69 // We need to check the plugin's routing id too since BrowserPluginManager |
| 68 // can manage plugins from other embedder (in the same process). | 70 // can manage plugins from other embedder (in the same process). |
| 69 if (plugin->render_view_routing_id() == source_routing_id && | 71 if (plugin->InBounds(position)) { |
| 70 plugin->InBounds(position)) { | 72 source_routing_id = plugin->render_view_routing_id(); |
| 71 instance_id = plugin->instance_id(); | 73 instance_id = plugin->instance_id(); |
| 72 local_position = plugin->ToLocalCoordinates(position); | 74 local_position = plugin->ToLocalCoordinates(position); |
| 73 break; | 75 break; |
| 74 } | 76 } |
| 75 it.Advance(); | 77 it.Advance(); |
| 76 } | 78 } |
| 77 | 79 |
| 78 Send(new BrowserPluginHostMsg_PluginAtPositionResponse( | 80 Send(new BrowserPluginHostMsg_PluginAtPositionResponse( |
| 79 source_routing_id, | 81 source_routing_id, |
| 80 instance_id, | 82 instance_id, |
| 81 request_id, | 83 request_id, |
| 82 local_position)); | 84 local_position)); |
| 83 } | 85 } |
| 84 | 86 |
| 85 void BrowserPluginManagerImpl::OnUpdateRect( | 87 void BrowserPluginManagerImpl::OnUpdateRect( |
| 86 int instance_id, | 88 int instance_id, |
| 87 int message_id, | 89 int message_id, |
| 88 const BrowserPluginMsg_UpdateRect_Params& params) { | 90 const BrowserPluginMsg_UpdateRect_Params& params) { |
| 89 BrowserPlugin* plugin = GetBrowserPlugin(instance_id); | 91 BrowserPlugin* plugin = GetBrowserPlugin(instance_id); |
| 90 if (plugin) | 92 if (plugin) |
| 91 plugin->UpdateRect(message_id, params); | 93 plugin->UpdateRect(message_id, params); |
| 92 } | 94 } |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 } | 162 } |
| 161 | 163 |
| 162 void BrowserPluginManagerImpl::OnSetCursor(int instance_id, | 164 void BrowserPluginManagerImpl::OnSetCursor(int instance_id, |
| 163 const WebCursor& cursor) { | 165 const WebCursor& cursor) { |
| 164 BrowserPlugin* plugin = GetBrowserPlugin(instance_id); | 166 BrowserPlugin* plugin = GetBrowserPlugin(instance_id); |
| 165 if (plugin) | 167 if (plugin) |
| 166 plugin->SetCursor(cursor); | 168 plugin->SetCursor(cursor); |
| 167 } | 169 } |
| 168 | 170 |
| 169 } // namespace content | 171 } // namespace content |
| OLD | NEW |