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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 | 10 |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 is_full_page_plugin_(false), | 98 is_full_page_plugin_(false), |
99 has_render_view_(has_render_view), | 99 has_render_view_(has_render_view), |
100 is_in_destruction_(false), | 100 is_in_destruction_(false), |
101 initialized_(false), | 101 initialized_(false), |
102 guest_proxy_routing_id_(MSG_ROUTING_NONE), | 102 guest_proxy_routing_id_(MSG_ROUTING_NONE), |
103 last_drag_status_(blink::WebDragStatusUnknown), | 103 last_drag_status_(blink::WebDragStatusUnknown), |
104 seen_embedder_system_drag_ended_(false), | 104 seen_embedder_system_drag_ended_(false), |
105 seen_embedder_drag_source_ended_at_(false), | 105 seen_embedder_drag_source_ended_at_(false), |
106 ignore_dragged_url_(true), | 106 ignore_dragged_url_(true), |
107 delegate_(delegate), | 107 delegate_(delegate), |
| 108 is_mime_handler_view_guest_(false), |
108 weak_ptr_factory_(this) { | 109 weak_ptr_factory_(this) { |
109 DCHECK(web_contents); | 110 DCHECK(web_contents); |
110 DCHECK(delegate); | 111 DCHECK(delegate); |
111 RecordAction(base::UserMetricsAction("BrowserPlugin.Guest.Create")); | 112 RecordAction(base::UserMetricsAction("BrowserPlugin.Guest.Create")); |
112 web_contents->SetBrowserPluginGuest(this); | 113 web_contents->SetBrowserPluginGuest(this); |
113 delegate->SetGuestHost(this); | 114 delegate->SetGuestHost(this); |
| 115 is_mime_handler_view_guest_ = delegate->IsMimeHandlerViewGuest(); |
114 } | 116 } |
115 | 117 |
116 int BrowserPluginGuest::GetGuestProxyRoutingID() { | 118 int BrowserPluginGuest::GetGuestProxyRoutingID() { |
117 if (BrowserPluginGuestMode::UseCrossProcessFramesForGuests()) { | 119 if (BrowserPluginGuestMode::UseCrossProcessFramesForGuests() && |
| 120 !IsMimeHandlerViewGuest()) { |
118 // We don't use the proxy to send postMessage in --site-per-process, since | 121 // We don't use the proxy to send postMessage in --site-per-process, since |
119 // we use the contentWindow directly from the frame element instead. | 122 // we use the contentWindow directly from the frame element instead. |
120 return MSG_ROUTING_NONE; | 123 return MSG_ROUTING_NONE; |
121 } | 124 } |
122 | 125 |
123 if (guest_proxy_routing_id_ != MSG_ROUTING_NONE) | 126 if (guest_proxy_routing_id_ != MSG_ROUTING_NONE) |
124 return guest_proxy_routing_id_; | 127 return guest_proxy_routing_id_; |
125 | 128 |
126 // Create a RenderFrameProxyHost for the guest in the embedder renderer | 129 // Create a RenderFrameProxyHost for the guest in the embedder renderer |
127 // process, so that the embedder can access the guest's window object. | 130 // process, so that the embedder can access the guest's window object. |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 blink::WebFocusTypeNone); | 286 blink::WebFocusTypeNone); |
284 | 287 |
285 guest_visible_ = params.visible; | 288 guest_visible_ = params.visible; |
286 UpdateVisibility(); | 289 UpdateVisibility(); |
287 | 290 |
288 is_full_page_plugin_ = params.is_full_page_plugin; | 291 is_full_page_plugin_ = params.is_full_page_plugin; |
289 guest_window_rect_ = params.view_rect; | 292 guest_window_rect_ = params.view_rect; |
290 | 293 |
291 if (owner_web_contents_ != owner_web_contents) { | 294 if (owner_web_contents_ != owner_web_contents) { |
292 WebContentsViewGuest* new_view = nullptr; | 295 WebContentsViewGuest* new_view = nullptr; |
293 if (!BrowserPluginGuestMode::UseCrossProcessFramesForGuests()) { | 296 if (!BrowserPluginGuestMode::UseCrossProcessFramesForGuests() || |
| 297 IsMimeHandlerViewGuest()) { |
294 new_view = | 298 new_view = |
295 static_cast<WebContentsViewGuest*>(GetWebContents()->GetView()); | 299 static_cast<WebContentsViewGuest*>(GetWebContents()->GetView()); |
296 } | 300 } |
297 | 301 |
298 if (owner_web_contents_ && new_view) | 302 if (owner_web_contents_ && new_view) |
299 new_view->OnGuestDetached(owner_web_contents_->GetView()); | 303 new_view->OnGuestDetached(owner_web_contents_->GetView()); |
300 | 304 |
301 // Once a BrowserPluginGuest has an embedder WebContents, it's considered to | 305 // Once a BrowserPluginGuest has an embedder WebContents, it's considered to |
302 // be attached. | 306 // be attached. |
303 owner_web_contents_ = owner_web_contents; | 307 owner_web_contents_ = owner_web_contents; |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
366 static_cast<WebContentsImpl*>(WebContents::FromRenderViewHost( | 370 static_cast<WebContentsImpl*>(WebContents::FromRenderViewHost( |
367 render_view_host))); | 371 render_view_host))); |
368 } | 372 } |
369 | 373 |
370 RenderWidgetHostView* BrowserPluginGuest::GetOwnerRenderWidgetHostView() { | 374 RenderWidgetHostView* BrowserPluginGuest::GetOwnerRenderWidgetHostView() { |
371 if (!owner_web_contents_) | 375 if (!owner_web_contents_) |
372 return nullptr; | 376 return nullptr; |
373 return owner_web_contents_->GetRenderWidgetHostView(); | 377 return owner_web_contents_->GetRenderWidgetHostView(); |
374 } | 378 } |
375 | 379 |
| 380 RenderWidgetHostView* BrowserPluginGuest::GetTopLevelRenderWidgetHostView() { |
| 381 if (!owner_web_contents_) |
| 382 return nullptr; |
| 383 return owner_web_contents_->GetTopLevelRenderWidgetHostView(); |
| 384 } |
| 385 |
376 void BrowserPluginGuest::UpdateVisibility() { | 386 void BrowserPluginGuest::UpdateVisibility() { |
377 OnSetVisibility(browser_plugin_instance_id(), visible()); | 387 OnSetVisibility(browser_plugin_instance_id(), visible()); |
378 } | 388 } |
379 | 389 |
380 BrowserPluginGuestManager* | 390 BrowserPluginGuestManager* |
381 BrowserPluginGuest::GetBrowserPluginGuestManager() const { | 391 BrowserPluginGuest::GetBrowserPluginGuestManager() const { |
382 return GetWebContents()->GetBrowserContext()->GetGuestManager(); | 392 return GetWebContents()->GetBrowserContext()->GetGuestManager(); |
383 } | 393 } |
384 | 394 |
385 void BrowserPluginGuest::EmbedderVisibilityChanged(bool visible) { | 395 void BrowserPluginGuest::EmbedderVisibilityChanged(bool visible) { |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
463 resent_wheel_event.resendingPluginId = browser_plugin_instance_id_; | 473 resent_wheel_event.resendingPluginId = browser_plugin_instance_id_; |
464 // TODO(wjmaclean): Initialize latency info correctly for OOPIFs. | 474 // TODO(wjmaclean): Initialize latency info correctly for OOPIFs. |
465 // https://crbug.com/613628 | 475 // https://crbug.com/613628 |
466 ui::LatencyInfo latency_info; | 476 ui::LatencyInfo latency_info; |
467 view->ProcessMouseWheelEvent(resent_wheel_event, latency_info); | 477 view->ProcessMouseWheelEvent(resent_wheel_event, latency_info); |
468 } else { | 478 } else { |
469 NOTIMPLEMENTED(); | 479 NOTIMPLEMENTED(); |
470 } | 480 } |
471 } | 481 } |
472 | 482 |
| 483 bool BrowserPluginGuest::IsMimeHandlerViewGuest() const { |
| 484 return is_mime_handler_view_guest_; |
| 485 } |
| 486 |
473 WebContentsImpl* BrowserPluginGuest::GetWebContents() const { | 487 WebContentsImpl* BrowserPluginGuest::GetWebContents() const { |
474 return static_cast<WebContentsImpl*>(web_contents()); | 488 return static_cast<WebContentsImpl*>(web_contents()); |
475 } | 489 } |
476 | 490 |
477 gfx::Point BrowserPluginGuest::GetScreenCoordinates( | 491 gfx::Point BrowserPluginGuest::GetScreenCoordinates( |
478 const gfx::Point& relative_position) const { | 492 const gfx::Point& relative_position) const { |
479 if (!attached()) | 493 if (!attached()) |
480 return relative_position; | 494 return relative_position; |
481 | 495 |
482 gfx::Point screen_pos(relative_position); | 496 gfx::Point screen_pos(relative_position); |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
670 | 684 |
671 bool BrowserPluginGuest::OnMessageReceived(const IPC::Message& message) { | 685 bool BrowserPluginGuest::OnMessageReceived(const IPC::Message& message) { |
672 bool handled = true; | 686 bool handled = true; |
673 // In --site-per-process, we do not need most of BrowserPluginGuest to drive | 687 // In --site-per-process, we do not need most of BrowserPluginGuest to drive |
674 // inner WebContents. | 688 // inner WebContents. |
675 // Right now InputHostMsg_ImeCompositionRangeChanged hits NOTREACHED() in | 689 // Right now InputHostMsg_ImeCompositionRangeChanged hits NOTREACHED() in |
676 // RWHVChildFrame, so we're disabling message handling entirely here. | 690 // RWHVChildFrame, so we're disabling message handling entirely here. |
677 // TODO(lazyboy): Fix this as part of http://crbug.com/330264. The required | 691 // TODO(lazyboy): Fix this as part of http://crbug.com/330264. The required |
678 // parts of code from this class should be extracted to a separate class for | 692 // parts of code from this class should be extracted to a separate class for |
679 // --site-per-process. | 693 // --site-per-process. |
680 if (BrowserPluginGuestMode::UseCrossProcessFramesForGuests()) { | 694 if (BrowserPluginGuestMode::UseCrossProcessFramesForGuests() && |
| 695 !IsMimeHandlerViewGuest()) { |
681 return false; | 696 return false; |
682 } | 697 } |
683 | 698 |
684 IPC_BEGIN_MESSAGE_MAP(BrowserPluginGuest, message) | 699 IPC_BEGIN_MESSAGE_MAP(BrowserPluginGuest, message) |
685 IPC_MESSAGE_HANDLER(InputHostMsg_ImeCancelComposition, | 700 IPC_MESSAGE_HANDLER(InputHostMsg_ImeCancelComposition, |
686 OnImeCancelComposition) | 701 OnImeCancelComposition) |
687 #if defined(OS_MACOSX) || defined(USE_AURA) | 702 #if defined(OS_MACOSX) || defined(USE_AURA) |
688 IPC_MESSAGE_HANDLER(InputHostMsg_ImeCompositionRangeChanged, | 703 IPC_MESSAGE_HANDLER(InputHostMsg_ImeCompositionRangeChanged, |
689 OnImeCompositionRangeChanged) | 704 OnImeCompositionRangeChanged) |
690 #endif | 705 #endif |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
920 void BrowserPluginGuest::OnSetEditCommandsForNextKeyEvent( | 935 void BrowserPluginGuest::OnSetEditCommandsForNextKeyEvent( |
921 int browser_plugin_instance_id, | 936 int browser_plugin_instance_id, |
922 const std::vector<EditCommand>& edit_commands) { | 937 const std::vector<EditCommand>& edit_commands) { |
923 Send(new InputMsg_SetEditCommandsForNextKeyEvent(routing_id(), | 938 Send(new InputMsg_SetEditCommandsForNextKeyEvent(routing_id(), |
924 edit_commands)); | 939 edit_commands)); |
925 } | 940 } |
926 | 941 |
927 void BrowserPluginGuest::OnSetVisibility(int browser_plugin_instance_id, | 942 void BrowserPluginGuest::OnSetVisibility(int browser_plugin_instance_id, |
928 bool visible) { | 943 bool visible) { |
929 // For OOPIF-<webivew>, the remote frame will handle visibility state. | 944 // For OOPIF-<webivew>, the remote frame will handle visibility state. |
930 if (BrowserPluginGuestMode::UseCrossProcessFramesForGuests()) | 945 if (BrowserPluginGuestMode::UseCrossProcessFramesForGuests() && |
| 946 !IsMimeHandlerViewGuest()) |
931 return; | 947 return; |
932 | 948 |
933 guest_visible_ = visible; | 949 guest_visible_ = visible; |
934 if (embedder_visible_ && guest_visible_) | 950 if (embedder_visible_ && guest_visible_) |
935 GetWebContents()->WasShown(); | 951 GetWebContents()->WasShown(); |
936 else | 952 else |
937 GetWebContents()->WasHidden(); | 953 GetWebContents()->WasHidden(); |
938 } | 954 } |
939 | 955 |
940 void BrowserPluginGuest::OnUnlockMouse() { | 956 void BrowserPluginGuest::OnUnlockMouse() { |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1017 range, character_bounds); | 1033 range, character_bounds); |
1018 } | 1034 } |
1019 #endif | 1035 #endif |
1020 | 1036 |
1021 void BrowserPluginGuest::SetContextMenuPosition(const gfx::Point& position) { | 1037 void BrowserPluginGuest::SetContextMenuPosition(const gfx::Point& position) { |
1022 if (delegate_) | 1038 if (delegate_) |
1023 delegate_->SetContextMenuPosition(position); | 1039 delegate_->SetContextMenuPosition(position); |
1024 } | 1040 } |
1025 | 1041 |
1026 } // namespace content | 1042 } // namespace content |
OLD | NEW |