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.h" | 5 #include "content/browser/browser_plugin/browser_plugin_guest.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/pickle.h" | 10 #include "base/pickle.h" |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 WebContentsImpl* BrowserPluginGuest::CreateNewGuestWindow( | 121 WebContentsImpl* BrowserPluginGuest::CreateNewGuestWindow( |
122 const WebContents::CreateParams& params) { | 122 const WebContents::CreateParams& params) { |
123 WebContentsImpl* new_contents = | 123 WebContentsImpl* new_contents = |
124 static_cast<WebContentsImpl*>(delegate_->CreateNewGuestWindow(params)); | 124 static_cast<WebContentsImpl*>(delegate_->CreateNewGuestWindow(params)); |
125 DCHECK(new_contents); | 125 DCHECK(new_contents); |
126 return new_contents; | 126 return new_contents; |
127 } | 127 } |
128 | 128 |
129 bool BrowserPluginGuest::OnMessageReceivedFromEmbedder( | 129 bool BrowserPluginGuest::OnMessageReceivedFromEmbedder( |
130 const IPC::Message& message) { | 130 const IPC::Message& message) { |
| 131 RenderWidgetHostViewGuest* rwhv = static_cast<RenderWidgetHostViewGuest*>( |
| 132 web_contents()->GetRenderWidgetHostView()); |
| 133 if (rwhv && |
| 134 rwhv->OnMessageReceivedFromEmbedder( |
| 135 message, |
| 136 static_cast<RenderViewHostImpl*>( |
| 137 embedder_web_contents()->GetRenderViewHost()))) { |
| 138 return true; |
| 139 } |
| 140 |
131 bool handled = true; | 141 bool handled = true; |
132 IPC_BEGIN_MESSAGE_MAP(BrowserPluginGuest, message) | 142 IPC_BEGIN_MESSAGE_MAP(BrowserPluginGuest, message) |
133 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_CompositorFrameSwappedACK, | 143 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_CompositorFrameSwappedACK, |
134 OnCompositorFrameSwappedACK) | 144 OnCompositorFrameSwappedACK) |
135 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_CopyFromCompositingSurfaceAck, | 145 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_CopyFromCompositingSurfaceAck, |
136 OnCopyFromCompositingSurfaceAck) | 146 OnCopyFromCompositingSurfaceAck) |
137 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_DragStatusUpdate, | 147 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_DragStatusUpdate, |
138 OnDragStatusUpdate) | 148 OnDragStatusUpdate) |
139 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_ExecuteEditCommand, | 149 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_ExecuteEditCommand, |
140 OnExecuteEditCommand) | 150 OnExecuteEditCommand) |
141 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_ExtendSelectionAndDelete, | 151 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_ExtendSelectionAndDelete, |
142 OnExtendSelectionAndDelete) | 152 OnExtendSelectionAndDelete) |
143 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_HandleInputEvent, | |
144 OnHandleInputEvent) | |
145 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_ImeConfirmComposition, | 153 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_ImeConfirmComposition, |
146 OnImeConfirmComposition) | 154 OnImeConfirmComposition) |
147 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_ImeSetComposition, | 155 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_ImeSetComposition, |
148 OnImeSetComposition) | 156 OnImeSetComposition) |
149 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_LockMouse_ACK, OnLockMouseAck) | 157 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_LockMouse_ACK, OnLockMouseAck) |
150 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_PluginDestroyed, OnPluginDestroyed) | 158 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_PluginDestroyed, OnPluginDestroyed) |
151 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_ReclaimCompositorResources, | 159 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_ReclaimCompositorResources, |
152 OnReclaimCompositorResources) | 160 OnReclaimCompositorResources) |
153 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_ResizeGuest, OnResizeGuest) | 161 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_ResizeGuest, OnResizeGuest) |
154 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_SetEditCommandsForNextKeyEvent, | 162 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_SetEditCommandsForNextKeyEvent, |
(...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
624 | 632 |
625 void BrowserPluginGuest::OnReclaimCompositorResources( | 633 void BrowserPluginGuest::OnReclaimCompositorResources( |
626 int browser_plugin_instance_id, | 634 int browser_plugin_instance_id, |
627 const FrameHostMsg_ReclaimCompositorResources_Params& params) { | 635 const FrameHostMsg_ReclaimCompositorResources_Params& params) { |
628 RenderWidgetHostImpl::SendReclaimCompositorResources(params.route_id, | 636 RenderWidgetHostImpl::SendReclaimCompositorResources(params.route_id, |
629 params.output_surface_id, | 637 params.output_surface_id, |
630 params.renderer_host_id, | 638 params.renderer_host_id, |
631 params.ack); | 639 params.ack); |
632 } | 640 } |
633 | 641 |
634 void BrowserPluginGuest::OnHandleInputEvent( | |
635 int browser_plugin_instance_id, | |
636 const gfx::Rect& guest_window_rect, | |
637 const blink::WebInputEvent* event) { | |
638 RenderViewHostImpl* guest_rvh = static_cast<RenderViewHostImpl*>( | |
639 GetWebContents()->GetRenderViewHost()); | |
640 | |
641 if (blink::WebInputEvent::isMouseEventType(event->type)) { | |
642 guest_rvh->ForwardMouseEvent( | |
643 *static_cast<const blink::WebMouseEvent*>(event)); | |
644 return; | |
645 } | |
646 | |
647 if (event->type == blink::WebInputEvent::MouseWheel) { | |
648 guest_rvh->ForwardWheelEvent( | |
649 *static_cast<const blink::WebMouseWheelEvent*>(event)); | |
650 return; | |
651 } | |
652 | |
653 if (blink::WebInputEvent::isKeyboardEventType(event->type)) { | |
654 RenderViewHostImpl* embedder_rvh = static_cast<RenderViewHostImpl*>( | |
655 embedder_web_contents_->GetRenderViewHost()); | |
656 if (!embedder_rvh->GetLastKeyboardEvent()) | |
657 return; | |
658 NativeWebKeyboardEvent keyboard_event( | |
659 *embedder_rvh->GetLastKeyboardEvent()); | |
660 guest_rvh->ForwardKeyboardEvent(keyboard_event); | |
661 return; | |
662 } | |
663 | |
664 if (blink::WebInputEvent::isTouchEventType(event->type)) { | |
665 guest_rvh->ForwardTouchEventWithLatencyInfo( | |
666 *static_cast<const blink::WebTouchEvent*>(event), | |
667 ui::LatencyInfo()); | |
668 return; | |
669 } | |
670 | |
671 if (blink::WebInputEvent::isGestureEventType(event->type)) { | |
672 guest_rvh->ForwardGestureEvent( | |
673 *static_cast<const blink::WebGestureEvent*>(event)); | |
674 return; | |
675 } | |
676 } | |
677 | |
678 void BrowserPluginGuest::OnLockMouse(bool user_gesture, | 642 void BrowserPluginGuest::OnLockMouse(bool user_gesture, |
679 bool last_unlocked_by_target, | 643 bool last_unlocked_by_target, |
680 bool privileged) { | 644 bool privileged) { |
681 if (pending_lock_request_) { | 645 if (pending_lock_request_) { |
682 // Immediately reject the lock because only one pointerLock may be active | 646 // Immediately reject the lock because only one pointerLock may be active |
683 // at a time. | 647 // at a time. |
684 Send(new ViewMsg_LockMouse_ACK(routing_id(), false)); | 648 Send(new ViewMsg_LockMouse_ACK(routing_id(), false)); |
685 return; | 649 return; |
686 } | 650 } |
687 | 651 |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
869 void BrowserPluginGuest::OnImeCompositionRangeChanged( | 833 void BrowserPluginGuest::OnImeCompositionRangeChanged( |
870 const gfx::Range& range, | 834 const gfx::Range& range, |
871 const std::vector<gfx::Rect>& character_bounds) { | 835 const std::vector<gfx::Rect>& character_bounds) { |
872 static_cast<RenderWidgetHostViewBase*>( | 836 static_cast<RenderWidgetHostViewBase*>( |
873 web_contents()->GetRenderWidgetHostView())->ImeCompositionRangeChanged( | 837 web_contents()->GetRenderWidgetHostView())->ImeCompositionRangeChanged( |
874 range, character_bounds); | 838 range, character_bounds); |
875 } | 839 } |
876 #endif | 840 #endif |
877 | 841 |
878 } // namespace content | 842 } // namespace content |
OLD | NEW |