Chromium Code Reviews| Index: content/browser/browser_plugin/browser_plugin_guest.cc |
| diff --git a/content/browser/browser_plugin/browser_plugin_guest.cc b/content/browser/browser_plugin/browser_plugin_guest.cc |
| index 0741cd5e8971e9906b359d73ee50c7aeaf1dae7f..23e4ad2be17d07729e2a7db5c6e55b5cf54a104f 100644 |
| --- a/content/browser/browser_plugin/browser_plugin_guest.cc |
| +++ b/content/browser/browser_plugin/browser_plugin_guest.cc |
| @@ -24,6 +24,7 @@ |
| #include "content/common/browser_plugin/browser_plugin_messages.h" |
| #include "content/common/content_constants_internal.h" |
| #include "content/common/drag_messages.h" |
| +#include "content/common/frame_messages.h" |
| #include "content/common/input_messages.h" |
| #include "content/common/view_messages.h" |
| #include "content/public/browser/browser_context.h" |
| @@ -87,6 +88,7 @@ BrowserPluginGuest::BrowserPluginGuest(bool has_render_view, |
| last_input_mode_(ui::TEXT_INPUT_MODE_DEFAULT), |
| last_can_compose_inline_(true), |
| delegate_(delegate), |
| + render_frame_message_source_(NULL), |
| weak_ptr_factory_(this) { |
| DCHECK(web_contents); |
| DCHECK(delegate); |
| @@ -445,12 +447,6 @@ bool BrowserPluginGuest::OnMessageReceived(const IPC::Message& message) { |
| OnHasTouchEventHandlers) |
| IPC_MESSAGE_HANDLER(ViewHostMsg_LockMouse, OnLockMouse) |
| IPC_MESSAGE_HANDLER(ViewHostMsg_SetCursor, OnSetCursor) |
| - #if defined(OS_MACOSX) |
| - // MacOSX creates and populates platform-specific select drop-down menus |
| - // whereas other platforms merely create a popup window that the guest |
| - // renderer process paints inside. |
| - IPC_MESSAGE_HANDLER(ViewHostMsg_ShowPopup, OnShowPopup) |
| - #endif |
| IPC_MESSAGE_HANDLER(ViewHostMsg_ShowWidget, OnShowWidget) |
| IPC_MESSAGE_HANDLER(ViewHostMsg_TakeFocus, OnTakeFocus) |
| IPC_MESSAGE_HANDLER(ViewHostMsg_TextInputStateChanged, |
| @@ -462,6 +458,35 @@ bool BrowserPluginGuest::OnMessageReceived(const IPC::Message& message) { |
| return handled; |
| } |
| +bool BrowserPluginGuest::OnMessageReceived(const IPC::Message& message, |
| + RenderFrameHost* render_frame_host) { |
| + // This will eventually be the home for more IPC handlers that depend on |
| + // RenderFrameHost. Until more are moved here, though, the IPC_* macros won't |
| + // compile if there are no handlers for a platform. So we have both #if guards |
| + // around the whole thing (unfortunate but temporary), and #if guards where |
| + // they belong, only around the one IPC handler. TODO(avi): Move more of the |
| + // frame-based handlers to this function and remove the outer #if layer. |
| +#if defined(OS_MACOSX) |
| + render_frame_message_source_ = render_frame_host; |
|
Fady Samuel
2014/08/23 10:56:17
nit: There's no way to pass this along via the mac
Avi (use Gerrit)
2014/08/23 18:36:44
No. If you take a look at WebContentsImpl::OnMessa
Avi (use Gerrit)
2014/08/24 23:00:06
Actually, IPC_BEGIN_MESSAGE_MAP_WITH_PARAM works.
|
| + |
| + bool handled = true; |
| + IPC_BEGIN_MESSAGE_MAP(BrowserPluginGuest, message) |
| +#if defined(OS_MACOSX) |
| + // MacOS X creates and populates platform-specific select drop-down menus |
| + // whereas other platforms merely create a popup window that the guest |
| + // renderer process paints inside. |
| + IPC_MESSAGE_HANDLER(FrameHostMsg_ShowPopup, OnShowPopup) |
| +#endif |
| + IPC_MESSAGE_UNHANDLED(handled = false) |
| + IPC_END_MESSAGE_MAP() |
| + render_frame_message_source_ = NULL; |
| + |
| + return handled; |
| +#else |
| + return false; |
| +#endif |
| +} |
| + |
| void BrowserPluginGuest::Attach( |
| int browser_plugin_instance_id, |
| WebContentsImpl* embedder_web_contents, |
| @@ -783,12 +808,12 @@ void BrowserPluginGuest::OnSetCursor(const WebCursor& cursor) { |
| #if defined(OS_MACOSX) |
| void BrowserPluginGuest::OnShowPopup( |
| - const ViewHostMsg_ShowPopup_Params& params) { |
| + const FrameHostMsg_ShowPopup_Params& params) { |
| gfx::Rect translated_bounds(params.bounds); |
| translated_bounds.Offset(guest_window_rect_.OffsetFromOrigin()); |
| BrowserPluginPopupMenuHelper popup_menu_helper( |
| embedder_web_contents_->GetRenderViewHost(), |
| - GetWebContents()->GetRenderViewHost()); |
| + render_frame_message_source_); |
| popup_menu_helper.ShowPopupMenu(translated_bounds, |
| params.item_height, |
| params.item_font_size, |