Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(186)

Side by Side Diff: content/browser/browser_plugin/browser_plugin_guest.cc

Issue 554733003: Browser Plugin: Move input to RWHVGuest to support interstitial pages (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@remove_to_guest_rect
Patch Set: Added TODO Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 && rwhv->OnMessageReceivedFromEmbedder(message))
Charlie Reis 2014/09/10 00:28:21 Can we pass embedder_web_contents_ here instead of
Fady Samuel 2014/09/10 02:51:37 Done.
134 return true;
135
131 bool handled = true; 136 bool handled = true;
132 IPC_BEGIN_MESSAGE_MAP(BrowserPluginGuest, message) 137 IPC_BEGIN_MESSAGE_MAP(BrowserPluginGuest, message)
133 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_CompositorFrameSwappedACK, 138 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_CompositorFrameSwappedACK,
134 OnCompositorFrameSwappedACK) 139 OnCompositorFrameSwappedACK)
135 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_CopyFromCompositingSurfaceAck, 140 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_CopyFromCompositingSurfaceAck,
136 OnCopyFromCompositingSurfaceAck) 141 OnCopyFromCompositingSurfaceAck)
137 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_DragStatusUpdate, 142 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_DragStatusUpdate,
138 OnDragStatusUpdate) 143 OnDragStatusUpdate)
139 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_ExecuteEditCommand, 144 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_ExecuteEditCommand,
140 OnExecuteEditCommand) 145 OnExecuteEditCommand)
141 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_ExtendSelectionAndDelete, 146 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_ExtendSelectionAndDelete,
142 OnExtendSelectionAndDelete) 147 OnExtendSelectionAndDelete)
143 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_HandleInputEvent,
144 OnHandleInputEvent)
145 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_ImeConfirmComposition, 148 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_ImeConfirmComposition,
146 OnImeConfirmComposition) 149 OnImeConfirmComposition)
147 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_ImeSetComposition, 150 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_ImeSetComposition,
148 OnImeSetComposition) 151 OnImeSetComposition)
149 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_LockMouse_ACK, OnLockMouseAck) 152 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_LockMouse_ACK, OnLockMouseAck)
150 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_PluginDestroyed, OnPluginDestroyed) 153 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_PluginDestroyed, OnPluginDestroyed)
151 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_ReclaimCompositorResources, 154 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_ReclaimCompositorResources,
152 OnReclaimCompositorResources) 155 OnReclaimCompositorResources)
153 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_ResizeGuest, OnResizeGuest) 156 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_ResizeGuest, OnResizeGuest)
154 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_SetEditCommandsForNextKeyEvent, 157 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_SetEditCommandsForNextKeyEvent,
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 return static_cast<WebContentsImpl*>(web_contents()); 355 return static_cast<WebContentsImpl*>(web_contents());
353 } 356 }
354 357
355 gfx::Point BrowserPluginGuest::GetScreenCoordinates( 358 gfx::Point BrowserPluginGuest::GetScreenCoordinates(
356 const gfx::Point& relative_position) const { 359 const gfx::Point& relative_position) const {
357 if (!attached()) 360 if (!attached())
358 return relative_position; 361 return relative_position;
359 362
360 gfx::Point screen_pos(relative_position); 363 gfx::Point screen_pos(relative_position);
361 screen_pos += guest_window_rect_.OffsetFromOrigin(); 364 screen_pos += guest_window_rect_.OffsetFromOrigin();
362 if (embedder_web_contents()->GetBrowserPluginGuest()) { 365 if (embedder_web_contents_->GetBrowserPluginGuest()) {
363 BrowserPluginGuest* embedder_guest = 366 BrowserPluginGuest* embedder_guest =
364 embedder_web_contents()->GetBrowserPluginGuest(); 367 embedder_web_contents_->GetBrowserPluginGuest();
365 screen_pos += embedder_guest->guest_window_rect_.OffsetFromOrigin(); 368 screen_pos += embedder_guest->guest_window_rect_.OffsetFromOrigin();
366 } 369 }
367 return screen_pos; 370 return screen_pos;
368 } 371 }
369 372
370 void BrowserPluginGuest::SendMessageToEmbedder(IPC::Message* msg) { 373 void BrowserPluginGuest::SendMessageToEmbedder(IPC::Message* msg) {
371 if (!attached()) { 374 if (!attached()) {
372 // Some pages such as data URLs, javascript URLs, and about:blank 375 // Some pages such as data URLs, javascript URLs, and about:blank
373 // do not load external resources and so they load prior to attachment. 376 // do not load external resources and so they load prior to attachment.
374 // As a result, we must save all these IPCs until attachment and then 377 // As a result, we must save all these IPCs until attachment and then
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
624 627
625 void BrowserPluginGuest::OnReclaimCompositorResources( 628 void BrowserPluginGuest::OnReclaimCompositorResources(
626 int browser_plugin_instance_id, 629 int browser_plugin_instance_id,
627 const FrameHostMsg_ReclaimCompositorResources_Params& params) { 630 const FrameHostMsg_ReclaimCompositorResources_Params& params) {
628 RenderWidgetHostImpl::SendReclaimCompositorResources(params.route_id, 631 RenderWidgetHostImpl::SendReclaimCompositorResources(params.route_id,
629 params.output_surface_id, 632 params.output_surface_id,
630 params.renderer_host_id, 633 params.renderer_host_id,
631 params.ack); 634 params.ack);
632 } 635 }
633 636
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, 637 void BrowserPluginGuest::OnLockMouse(bool user_gesture,
679 bool last_unlocked_by_target, 638 bool last_unlocked_by_target,
680 bool privileged) { 639 bool privileged) {
681 if (pending_lock_request_) { 640 if (pending_lock_request_) {
682 // Immediately reject the lock because only one pointerLock may be active 641 // Immediately reject the lock because only one pointerLock may be active
683 // at a time. 642 // at a time.
684 Send(new ViewMsg_LockMouse_ACK(routing_id(), false)); 643 Send(new ViewMsg_LockMouse_ACK(routing_id(), false));
685 return; 644 return;
686 } 645 }
687 646
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
869 void BrowserPluginGuest::OnImeCompositionRangeChanged( 828 void BrowserPluginGuest::OnImeCompositionRangeChanged(
870 const gfx::Range& range, 829 const gfx::Range& range,
871 const std::vector<gfx::Rect>& character_bounds) { 830 const std::vector<gfx::Rect>& character_bounds) {
872 static_cast<RenderWidgetHostViewBase*>( 831 static_cast<RenderWidgetHostViewBase*>(
873 web_contents()->GetRenderWidgetHostView())->ImeCompositionRangeChanged( 832 web_contents()->GetRenderWidgetHostView())->ImeCompositionRangeChanged(
874 range, character_bounds); 833 range, character_bounds);
875 } 834 }
876 #endif 835 #endif
877 836
878 } // namespace content 837 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698