| 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 delegate_mode_( |
| 109 BrowserPluginGuestDelegateMode::USING_CROSS_PROCESS_FRAMES), |
| 108 weak_ptr_factory_(this) { | 110 weak_ptr_factory_(this) { |
| 109 DCHECK(web_contents); | 111 DCHECK(web_contents); |
| 110 DCHECK(delegate); | 112 DCHECK(delegate); |
| 111 RecordAction(base::UserMetricsAction("BrowserPlugin.Guest.Create")); | 113 RecordAction(base::UserMetricsAction("BrowserPlugin.Guest.Create")); |
| 112 web_contents->SetBrowserPluginGuest(this); | 114 web_contents->SetBrowserPluginGuest(this); |
| 113 delegate->SetGuestHost(this); | 115 delegate->SetGuestHost(this); |
| 116 if (delegate_->IsMimeHandlerViewGuest() || |
| 117 !BrowserPluginGuestMode::UseCrossProcessFramesForGuests()) |
| 118 delegate_mode_ = |
| 119 BrowserPluginGuestDelegateMode::NOT_USING_CROSS_PROCESS_FRAMES; |
| 114 } | 120 } |
| 115 | 121 |
| 116 int BrowserPluginGuest::GetGuestProxyRoutingID() { | 122 int BrowserPluginGuest::GetGuestProxyRoutingID() { |
| 117 if (BrowserPluginGuestMode::UseCrossProcessFramesForGuests()) { | 123 if (delegate_mode_ == |
| 124 BrowserPluginGuestDelegateMode::USING_CROSS_PROCESS_FRAMES) { |
| 118 // We don't use the proxy to send postMessage in --site-per-process, since | 125 // 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. | 126 // we use the contentWindow directly from the frame element instead. |
| 120 return MSG_ROUTING_NONE; | 127 return MSG_ROUTING_NONE; |
| 121 } | 128 } |
| 122 | 129 |
| 123 if (guest_proxy_routing_id_ != MSG_ROUTING_NONE) | 130 if (guest_proxy_routing_id_ != MSG_ROUTING_NONE) |
| 124 return guest_proxy_routing_id_; | 131 return guest_proxy_routing_id_; |
| 125 | 132 |
| 126 // Create a RenderFrameProxyHost for the guest in the embedder renderer | 133 // Create a RenderFrameProxyHost for the guest in the embedder renderer |
| 127 // process, so that the embedder can access the guest's window object. | 134 // 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); | 290 blink::WebFocusTypeNone); |
| 284 | 291 |
| 285 guest_visible_ = params.visible; | 292 guest_visible_ = params.visible; |
| 286 UpdateVisibility(); | 293 UpdateVisibility(); |
| 287 | 294 |
| 288 is_full_page_plugin_ = params.is_full_page_plugin; | 295 is_full_page_plugin_ = params.is_full_page_plugin; |
| 289 guest_window_rect_ = params.view_rect; | 296 guest_window_rect_ = params.view_rect; |
| 290 | 297 |
| 291 if (owner_web_contents_ != owner_web_contents) { | 298 if (owner_web_contents_ != owner_web_contents) { |
| 292 WebContentsViewGuest* new_view = nullptr; | 299 WebContentsViewGuest* new_view = nullptr; |
| 293 if (!BrowserPluginGuestMode::UseCrossProcessFramesForGuests()) { | 300 if (delegate_mode_ == |
| 301 BrowserPluginGuestDelegateMode::NOT_USING_CROSS_PROCESS_FRAMES) { |
| 294 new_view = | 302 new_view = |
| 295 static_cast<WebContentsViewGuest*>(GetWebContents()->GetView()); | 303 static_cast<WebContentsViewGuest*>(GetWebContents()->GetView()); |
| 296 } | 304 } |
| 297 | 305 |
| 298 if (owner_web_contents_ && new_view) | 306 if (owner_web_contents_ && new_view) |
| 299 new_view->OnGuestDetached(owner_web_contents_->GetView()); | 307 new_view->OnGuestDetached(owner_web_contents_->GetView()); |
| 300 | 308 |
| 301 // Once a BrowserPluginGuest has an embedder WebContents, it's considered to | 309 // Once a BrowserPluginGuest has an embedder WebContents, it's considered to |
| 302 // be attached. | 310 // be attached. |
| 303 owner_web_contents_ = owner_web_contents; | 311 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( | 374 static_cast<WebContentsImpl*>(WebContents::FromRenderViewHost( |
| 367 render_view_host))); | 375 render_view_host))); |
| 368 } | 376 } |
| 369 | 377 |
| 370 RenderWidgetHostView* BrowserPluginGuest::GetOwnerRenderWidgetHostView() { | 378 RenderWidgetHostView* BrowserPluginGuest::GetOwnerRenderWidgetHostView() { |
| 371 if (!owner_web_contents_) | 379 if (!owner_web_contents_) |
| 372 return nullptr; | 380 return nullptr; |
| 373 return owner_web_contents_->GetRenderWidgetHostView(); | 381 return owner_web_contents_->GetRenderWidgetHostView(); |
| 374 } | 382 } |
| 375 | 383 |
| 384 RenderWidgetHostView* BrowserPluginGuest::GetTopLevelRenderWidgetHostView() { |
| 385 if (!owner_web_contents_) |
| 386 return nullptr; |
| 387 return owner_web_contents_->GetTopLevelRenderWidgetHostView(); |
| 388 } |
| 389 |
| 376 void BrowserPluginGuest::UpdateVisibility() { | 390 void BrowserPluginGuest::UpdateVisibility() { |
| 377 OnSetVisibility(browser_plugin_instance_id(), visible()); | 391 OnSetVisibility(browser_plugin_instance_id(), visible()); |
| 378 } | 392 } |
| 379 | 393 |
| 380 BrowserPluginGuestManager* | 394 BrowserPluginGuestManager* |
| 381 BrowserPluginGuest::GetBrowserPluginGuestManager() const { | 395 BrowserPluginGuest::GetBrowserPluginGuestManager() const { |
| 382 return GetWebContents()->GetBrowserContext()->GetGuestManager(); | 396 return GetWebContents()->GetBrowserContext()->GetGuestManager(); |
| 383 } | 397 } |
| 384 | 398 |
| 385 void BrowserPluginGuest::EmbedderVisibilityChanged(bool visible) { | 399 void BrowserPluginGuest::EmbedderVisibilityChanged(bool visible) { |
| (...skipping 284 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 (delegate_mode_ == |
| 695 BrowserPluginGuestDelegateMode::USING_CROSS_PROCESS_FRAMES) { |
| 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 (delegate_mode_ == |
| 946 BrowserPluginGuestDelegateMode::USING_CROSS_PROCESS_FRAMES) |
| 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 |