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

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: Cleanup 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 &&
134 rwhv->OnMessageReceivedFromEmbedder(message, embedder_web_contents())) {
135 return true;
136 }
137
131 bool handled = true; 138 bool handled = true;
132 IPC_BEGIN_MESSAGE_MAP(BrowserPluginGuest, message) 139 IPC_BEGIN_MESSAGE_MAP(BrowserPluginGuest, message)
133 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_CompositorFrameSwappedACK, 140 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_CompositorFrameSwappedACK,
134 OnCompositorFrameSwappedACK) 141 OnCompositorFrameSwappedACK)
135 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_CopyFromCompositingSurfaceAck, 142 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_CopyFromCompositingSurfaceAck,
136 OnCopyFromCompositingSurfaceAck) 143 OnCopyFromCompositingSurfaceAck)
137 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_DragStatusUpdate, 144 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_DragStatusUpdate,
138 OnDragStatusUpdate) 145 OnDragStatusUpdate)
139 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_ExecuteEditCommand, 146 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_ExecuteEditCommand,
140 OnExecuteEditCommand) 147 OnExecuteEditCommand)
141 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_ExtendSelectionAndDelete, 148 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_ExtendSelectionAndDelete,
142 OnExtendSelectionAndDelete) 149 OnExtendSelectionAndDelete)
143 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_HandleInputEvent,
144 OnHandleInputEvent)
145 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_ImeConfirmComposition, 150 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_ImeConfirmComposition,
146 OnImeConfirmComposition) 151 OnImeConfirmComposition)
147 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_ImeSetComposition, 152 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_ImeSetComposition,
148 OnImeSetComposition) 153 OnImeSetComposition)
149 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_LockMouse_ACK, OnLockMouseAck) 154 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_LockMouse_ACK, OnLockMouseAck)
150 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_PluginDestroyed, OnPluginDestroyed) 155 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_PluginDestroyed, OnPluginDestroyed)
151 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_ReclaimCompositorResources, 156 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_ReclaimCompositorResources,
152 OnReclaimCompositorResources) 157 OnReclaimCompositorResources)
153 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_ResizeGuest, OnResizeGuest) 158 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_ResizeGuest, OnResizeGuest)
154 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_SetEditCommandsForNextKeyEvent, 159 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_SetEditCommandsForNextKeyEvent,
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 // static 262 // static
258 bool BrowserPluginGuest::IsGuest(RenderViewHostImpl* render_view_host) { 263 bool BrowserPluginGuest::IsGuest(RenderViewHostImpl* render_view_host) {
259 return render_view_host && IsGuest( 264 return render_view_host && IsGuest(
260 static_cast<WebContentsImpl*>(WebContents::FromRenderViewHost( 265 static_cast<WebContentsImpl*>(WebContents::FromRenderViewHost(
261 render_view_host))); 266 render_view_host)));
262 } 267 }
263 268
264 RenderWidgetHostView* BrowserPluginGuest::GetEmbedderRenderWidgetHostView() { 269 RenderWidgetHostView* BrowserPluginGuest::GetEmbedderRenderWidgetHostView() {
265 if (!attached()) 270 if (!attached())
266 return NULL; 271 return NULL;
267 return embedder_web_contents_->GetRenderWidgetHostView(); 272 return embedder_web_contents()->GetRenderWidgetHostView();
Charlie Reis 2014/09/10 04:42:04 These changes aren't really necessary anymore.
Fady Samuel 2014/09/10 11:43:44 Done.
268 } 273 }
269 274
270 void BrowserPluginGuest::UpdateVisibility() { 275 void BrowserPluginGuest::UpdateVisibility() {
271 OnSetVisibility(browser_plugin_instance_id(), visible()); 276 OnSetVisibility(browser_plugin_instance_id(), visible());
272 } 277 }
273 278
274 void BrowserPluginGuest::CopyFromCompositingSurface( 279 void BrowserPluginGuest::CopyFromCompositingSurface(
275 gfx::Rect src_subrect, 280 gfx::Rect src_subrect,
276 gfx::Size dst_size, 281 gfx::Size dst_size,
277 const base::Callback<void(bool, const SkBitmap&)>& callback) { 282 const base::Callback<void(bool, const SkBitmap&)>& callback) {
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 void BrowserPluginGuest::SendMessageToEmbedder(IPC::Message* msg) { 375 void BrowserPluginGuest::SendMessageToEmbedder(IPC::Message* msg) {
371 if (!attached()) { 376 if (!attached()) {
372 // Some pages such as data URLs, javascript URLs, and about:blank 377 // Some pages such as data URLs, javascript URLs, and about:blank
373 // do not load external resources and so they load prior to attachment. 378 // 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 379 // As a result, we must save all these IPCs until attachment and then
375 // forward them so that the embedder gets a chance to see and process 380 // forward them so that the embedder gets a chance to see and process
376 // the load events. 381 // the load events.
377 pending_messages_.push_back(linked_ptr<IPC::Message>(msg)); 382 pending_messages_.push_back(linked_ptr<IPC::Message>(msg));
378 return; 383 return;
379 } 384 }
380 msg->set_routing_id(embedder_web_contents_->GetRoutingID()); 385 msg->set_routing_id(embedder_web_contents()->GetRoutingID());
381 embedder_web_contents_->Send(msg); 386 embedder_web_contents()->Send(msg);
382 } 387 }
383 388
384 void BrowserPluginGuest::DragSourceEndedAt(int client_x, int client_y, 389 void BrowserPluginGuest::DragSourceEndedAt(int client_x, int client_y,
385 int screen_x, int screen_y, blink::WebDragOperation operation) { 390 int screen_x, int screen_y, blink::WebDragOperation operation) {
386 web_contents()->GetRenderViewHost()->DragSourceEndedAt(client_x, client_y, 391 web_contents()->GetRenderViewHost()->DragSourceEndedAt(client_x, client_y,
387 screen_x, screen_y, operation); 392 screen_x, screen_y, operation);
388 } 393 }
389 394
390 void BrowserPluginGuest::EndSystemDrag() { 395 void BrowserPluginGuest::EndSystemDrag() {
391 RenderViewHostImpl* guest_rvh = static_cast<RenderViewHostImpl*>( 396 RenderViewHostImpl* guest_rvh = static_cast<RenderViewHostImpl*>(
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
559 } 564 }
560 565
561 void BrowserPluginGuest::OnDragStatusUpdate(int browser_plugin_instance_id, 566 void BrowserPluginGuest::OnDragStatusUpdate(int browser_plugin_instance_id,
562 blink::WebDragStatus drag_status, 567 blink::WebDragStatus drag_status,
563 const DropData& drop_data, 568 const DropData& drop_data,
564 blink::WebDragOperationsMask mask, 569 blink::WebDragOperationsMask mask,
565 const gfx::Point& location) { 570 const gfx::Point& location) {
566 RenderViewHost* host = GetWebContents()->GetRenderViewHost(); 571 RenderViewHost* host = GetWebContents()->GetRenderViewHost();
567 switch (drag_status) { 572 switch (drag_status) {
568 case blink::WebDragStatusEnter: 573 case blink::WebDragStatusEnter:
569 embedder_web_contents_->GetBrowserPluginEmbedder()->DragEnteredGuest( 574 embedder_web_contents()->GetBrowserPluginEmbedder()->DragEnteredGuest(
570 this); 575 this);
571 host->DragTargetDragEnter(drop_data, location, location, mask, 0); 576 host->DragTargetDragEnter(drop_data, location, location, mask, 0);
572 break; 577 break;
573 case blink::WebDragStatusOver: 578 case blink::WebDragStatusOver:
574 host->DragTargetDragOver(location, location, mask, 0); 579 host->DragTargetDragOver(location, location, mask, 0);
575 break; 580 break;
576 case blink::WebDragStatusLeave: 581 case blink::WebDragStatusLeave:
577 embedder_web_contents_->GetBrowserPluginEmbedder()->DragLeftGuest(this); 582 embedder_web_contents()->GetBrowserPluginEmbedder()->DragLeftGuest(this);
578 host->DragTargetDragLeave(); 583 host->DragTargetDragLeave();
579 break; 584 break;
580 case blink::WebDragStatusDrop: 585 case blink::WebDragStatusDrop:
581 host->DragTargetDrop(location, location, 0); 586 host->DragTargetDrop(location, location, 0);
582 EndSystemDrag(); 587 EndSystemDrag();
583 break; 588 break;
584 case blink::WebDragStatusUnknown: 589 case blink::WebDragStatusUnknown:
585 NOTREACHED(); 590 NOTREACHED();
586 } 591 }
587 } 592 }
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
624 629
625 void BrowserPluginGuest::OnReclaimCompositorResources( 630 void BrowserPluginGuest::OnReclaimCompositorResources(
626 int browser_plugin_instance_id, 631 int browser_plugin_instance_id,
627 const FrameHostMsg_ReclaimCompositorResources_Params& params) { 632 const FrameHostMsg_ReclaimCompositorResources_Params& params) {
628 RenderWidgetHostImpl::SendReclaimCompositorResources(params.route_id, 633 RenderWidgetHostImpl::SendReclaimCompositorResources(params.route_id,
629 params.output_surface_id, 634 params.output_surface_id,
630 params.renderer_host_id, 635 params.renderer_host_id,
631 params.ack); 636 params.ack);
632 } 637 }
633 638
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, 639 void BrowserPluginGuest::OnLockMouse(bool user_gesture,
679 bool last_unlocked_by_target, 640 bool last_unlocked_by_target,
680 bool privileged) { 641 bool privileged) {
681 if (pending_lock_request_) { 642 if (pending_lock_request_) {
682 // Immediately reject the lock because only one pointerLock may be active 643 // Immediately reject the lock because only one pointerLock may be active
683 // at a time. 644 // at a time.
684 Send(new ViewMsg_LockMouse_ACK(routing_id(), false)); 645 Send(new ViewMsg_LockMouse_ACK(routing_id(), false));
685 return; 646 return;
686 } 647 }
687 648
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
821 new BrowserPluginMsg_SetCursor(browser_plugin_instance_id(), cursor)); 782 new BrowserPluginMsg_SetCursor(browser_plugin_instance_id(), cursor));
822 } 783 }
823 784
824 #if defined(OS_MACOSX) 785 #if defined(OS_MACOSX)
825 void BrowserPluginGuest::OnShowPopup( 786 void BrowserPluginGuest::OnShowPopup(
826 RenderFrameHost* render_frame_host, 787 RenderFrameHost* render_frame_host,
827 const FrameHostMsg_ShowPopup_Params& params) { 788 const FrameHostMsg_ShowPopup_Params& params) {
828 gfx::Rect translated_bounds(params.bounds); 789 gfx::Rect translated_bounds(params.bounds);
829 translated_bounds.Offset(guest_window_rect_.OffsetFromOrigin()); 790 translated_bounds.Offset(guest_window_rect_.OffsetFromOrigin());
830 BrowserPluginPopupMenuHelper popup_menu_helper( 791 BrowserPluginPopupMenuHelper popup_menu_helper(
831 embedder_web_contents_->GetRenderViewHost(), render_frame_host); 792 embedder_web_contents()->GetRenderViewHost(), render_frame_host);
832 popup_menu_helper.ShowPopupMenu(translated_bounds, 793 popup_menu_helper.ShowPopupMenu(translated_bounds,
833 params.item_height, 794 params.item_height,
834 params.item_font_size, 795 params.item_font_size,
835 params.selected_item, 796 params.selected_item,
836 params.popup_items, 797 params.popup_items,
837 params.right_aligned, 798 params.right_aligned,
838 params.allow_multiple_selection); 799 params.allow_multiple_selection);
839 } 800 }
840 #endif 801 #endif
841 802
(...skipping 27 matching lines...) Expand all
869 void BrowserPluginGuest::OnImeCompositionRangeChanged( 830 void BrowserPluginGuest::OnImeCompositionRangeChanged(
870 const gfx::Range& range, 831 const gfx::Range& range,
871 const std::vector<gfx::Rect>& character_bounds) { 832 const std::vector<gfx::Rect>& character_bounds) {
872 static_cast<RenderWidgetHostViewBase*>( 833 static_cast<RenderWidgetHostViewBase*>(
873 web_contents()->GetRenderWidgetHostView())->ImeCompositionRangeChanged( 834 web_contents()->GetRenderWidgetHostView())->ImeCompositionRangeChanged(
874 range, character_bounds); 835 range, character_bounds);
875 } 836 }
876 #endif 837 #endif
877 838
878 } // namespace content 839 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/browser_plugin/browser_plugin_guest.h ('k') | content/browser/frame_host/render_widget_host_view_guest.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698