| 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/browser/browser_plugin/browser_plugin_guest_helper.h" | 5 #include "content/browser/browser_plugin/browser_plugin_guest_helper.h" |
| 6 | 6 |
| 7 #include "content/browser/browser_plugin/browser_plugin_guest.h" | 7 #include "content/browser/browser_plugin/browser_plugin_guest.h" |
| 8 #include "content/browser/web_contents/web_contents_impl.h" | |
| 9 #include "content/common/drag_messages.h" | 8 #include "content/common/drag_messages.h" |
| 10 #include "content/common/view_messages.h" | 9 #include "content/common/view_messages.h" |
| 11 #include "content/public/browser/render_view_host.h" | 10 #include "content/public/browser/render_view_host.h" |
| 12 | 11 |
| 13 namespace content { | 12 namespace content { |
| 14 | 13 |
| 15 BrowserPluginGuestHelper::BrowserPluginGuestHelper( | 14 BrowserPluginGuestHelper::BrowserPluginGuestHelper( |
| 16 BrowserPluginGuest* guest, | 15 BrowserPluginGuest* guest, |
| 17 RenderViewHost* render_view_host) | 16 RenderViewHost* render_view_host) |
| 18 : RenderViewHostObserver(render_view_host), | 17 : RenderViewHostObserver(render_view_host), |
| 19 guest_(guest) { | 18 guest_(guest) { |
| 20 } | 19 } |
| 21 | 20 |
| 22 BrowserPluginGuestHelper::~BrowserPluginGuestHelper() { | 21 BrowserPluginGuestHelper::~BrowserPluginGuestHelper() { |
| 23 } | 22 } |
| 24 | 23 |
| 25 bool BrowserPluginGuestHelper::OnMessageReceived( | 24 bool BrowserPluginGuestHelper::OnMessageReceived( |
| 26 const IPC::Message& message) { | 25 const IPC::Message& message) { |
| 27 bool handled = true; | 26 if (ShouldForwardToBrowserPluginGuest(message)) |
| 28 IPC_BEGIN_MESSAGE_MAP(BrowserPluginGuestHelper, message) | 27 return guest_->OnMessageReceived(message); |
| 29 IPC_MESSAGE_HANDLER(DragHostMsg_UpdateDragCursor, OnUpdateDragCursor) | 28 return false; |
| 30 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateRect, OnUpdateRect) | |
| 31 IPC_MESSAGE_HANDLER(ViewHostMsg_HandleInputEvent_ACK, OnHandleInputEventAck) | |
| 32 IPC_MESSAGE_HANDLER(ViewHostMsg_TakeFocus, OnTakeFocus) | |
| 33 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowWidget, OnShowWidget) | |
| 34 IPC_MESSAGE_HANDLER(ViewHostMsg_HasTouchEventHandlers, | |
| 35 OnMsgHasTouchEventHandlers) | |
| 36 IPC_MESSAGE_HANDLER(ViewHostMsg_SetCursor, OnSetCursor) | |
| 37 #if defined(OS_MACOSX) | |
| 38 // MacOSX creates and populates platform-specific select drop-down menus | |
| 39 // whereas other platforms merely create a popup window that the guest | |
| 40 // renderer process paints inside. | |
| 41 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowPopup, OnShowPopup) | |
| 42 #endif | |
| 43 IPC_MESSAGE_UNHANDLED(handled = false) | |
| 44 IPC_END_MESSAGE_MAP() | |
| 45 return handled; | |
| 46 } | 29 } |
| 47 | 30 |
| 48 void BrowserPluginGuestHelper::OnUpdateDragCursor( | 31 // static |
| 49 WebKit::WebDragOperation current_op) { | 32 bool BrowserPluginGuestHelper::ShouldForwardToBrowserPluginGuest( |
| 50 guest_->UpdateDragCursor(current_op); | 33 const IPC::Message& message) { |
| 34 switch (message.type()) { |
| 35 case DragHostMsg_UpdateDragCursor::ID: |
| 36 case ViewHostMsg_HandleInputEvent_ACK::ID: |
| 37 case ViewHostMsg_HasTouchEventHandlers::ID: |
| 38 case ViewHostMsg_SetCursor::ID: |
| 39 #if defined(OS_MACOSX) |
| 40 case ViewHostMsg_ShowPopup::ID: |
| 41 #endif |
| 42 case ViewHostMsg_ShowWidget::ID: |
| 43 case ViewHostMsg_TakeFocus::ID: |
| 44 case ViewHostMsg_UpdateRect::ID: |
| 45 return true; |
| 46 default: |
| 47 break; |
| 48 } |
| 49 return false; |
| 51 } | 50 } |
| 52 | 51 |
| 53 void BrowserPluginGuestHelper::OnUpdateRect( | |
| 54 const ViewHostMsg_UpdateRect_Params& params) { | |
| 55 guest_->UpdateRect(render_view_host(), params); | |
| 56 } | |
| 57 | |
| 58 void BrowserPluginGuestHelper::OnHandleInputEventAck( | |
| 59 WebKit::WebInputEvent::Type event_type, | |
| 60 InputEventAckState ack_result) { | |
| 61 guest_->HandleInputEventAck(render_view_host(), | |
| 62 ack_result == INPUT_EVENT_ACK_STATE_CONSUMED); | |
| 63 } | |
| 64 | |
| 65 void BrowserPluginGuestHelper::OnTakeFocus(bool reverse) { | |
| 66 guest_->ViewTakeFocus(reverse); | |
| 67 } | |
| 68 | |
| 69 void BrowserPluginGuestHelper::OnShowWidget(int route_id, | |
| 70 const gfx::Rect& initial_pos) { | |
| 71 guest_->ShowWidget(render_view_host(), route_id, initial_pos); | |
| 72 } | |
| 73 | |
| 74 void BrowserPluginGuestHelper::OnMsgHasTouchEventHandlers(bool has_handlers) { | |
| 75 guest_->SetIsAcceptingTouchEvents(has_handlers); | |
| 76 } | |
| 77 | |
| 78 void BrowserPluginGuestHelper::OnSetCursor(const WebCursor& cursor) { | |
| 79 guest_->SetCursor(cursor); | |
| 80 } | |
| 81 | |
| 82 #if defined(OS_MACOSX) | |
| 83 void BrowserPluginGuestHelper::OnShowPopup( | |
| 84 const ViewHostMsg_ShowPopup_Params& params) { | |
| 85 guest_->ShowPopup(render_view_host(), params); | |
| 86 } | |
| 87 #endif | |
| 88 | |
| 89 } // namespace content | 52 } // namespace content |
| OLD | NEW |