| 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 24 matching lines...) Expand all Loading... |
| 35 #include "content/common/drag_messages.h" | 35 #include "content/common/drag_messages.h" |
| 36 #include "content/common/host_shared_bitmap_manager.h" | 36 #include "content/common/host_shared_bitmap_manager.h" |
| 37 #include "content/common/input_messages.h" | 37 #include "content/common/input_messages.h" |
| 38 #include "content/common/site_isolation_policy.h" | 38 #include "content/common/site_isolation_policy.h" |
| 39 #include "content/common/text_input_state.h" | 39 #include "content/common/text_input_state.h" |
| 40 #include "content/common/view_messages.h" | 40 #include "content/common/view_messages.h" |
| 41 #include "content/public/browser/browser_context.h" | 41 #include "content/public/browser/browser_context.h" |
| 42 #include "content/public/browser/browser_plugin_guest_manager.h" | 42 #include "content/public/browser/browser_plugin_guest_manager.h" |
| 43 #include "content/public/browser/content_browser_client.h" | 43 #include "content/public/browser/content_browser_client.h" |
| 44 #include "content/public/browser/guest_host.h" | 44 #include "content/public/browser/guest_host.h" |
| 45 #include "content/public/browser/guest_mode.h" |
| 45 #include "content/public/browser/render_process_host.h" | 46 #include "content/public/browser/render_process_host.h" |
| 46 #include "content/public/browser/render_widget_host_view.h" | 47 #include "content/public/browser/render_widget_host_view.h" |
| 47 #include "content/public/browser/user_metrics.h" | 48 #include "content/public/browser/user_metrics.h" |
| 48 #include "content/public/browser/web_contents_observer.h" | 49 #include "content/public/browser/web_contents_observer.h" |
| 49 #include "content/public/common/browser_plugin_guest_mode.h" | |
| 50 #include "content/public/common/drop_data.h" | 50 #include "content/public/common/drop_data.h" |
| 51 #include "ui/gfx/geometry/size_conversions.h" | 51 #include "ui/gfx/geometry/size_conversions.h" |
| 52 | 52 |
| 53 #if defined(OS_MACOSX) | 53 #if defined(OS_MACOSX) |
| 54 #include "content/browser/browser_plugin/browser_plugin_popup_menu_helper_mac.h" | 54 #include "content/browser/browser_plugin/browser_plugin_popup_menu_helper_mac.h" |
| 55 #include "content/common/frame_messages.h" | 55 #include "content/common/frame_messages.h" |
| 56 #endif | 56 #endif |
| 57 | 57 |
| 58 namespace content { | 58 namespace content { |
| 59 | 59 |
| (...skipping 38 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 can_use_cross_process_frames_(delegate->CanUseCrossProcessFrames()), |
| 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); |
| 114 } | 115 } |
| 115 | 116 |
| 116 int BrowserPluginGuest::GetGuestProxyRoutingID() { | 117 int BrowserPluginGuest::GetGuestProxyRoutingID() { |
| 117 if (BrowserPluginGuestMode::UseCrossProcessFramesForGuests()) { | 118 if (GuestMode::IsCrossProcessFrameGuest(GetWebContents())) { |
| 118 // We don't use the proxy to send postMessage in --site-per-process, since | 119 // 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. | 120 // we use the contentWindow directly from the frame element instead. |
| 120 return MSG_ROUTING_NONE; | 121 return MSG_ROUTING_NONE; |
| 121 } | 122 } |
| 122 | 123 |
| 123 if (guest_proxy_routing_id_ != MSG_ROUTING_NONE) | 124 if (guest_proxy_routing_id_ != MSG_ROUTING_NONE) |
| 124 return guest_proxy_routing_id_; | 125 return guest_proxy_routing_id_; |
| 125 | 126 |
| 126 // Create a RenderFrameProxyHost for the guest in the embedder renderer | 127 // Create a RenderFrameProxyHost for the guest in the embedder renderer |
| 127 // process, so that the embedder can access the guest's window object. | 128 // 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); | 284 blink::WebFocusTypeNone); |
| 284 | 285 |
| 285 guest_visible_ = params.visible; | 286 guest_visible_ = params.visible; |
| 286 UpdateVisibility(); | 287 UpdateVisibility(); |
| 287 | 288 |
| 288 is_full_page_plugin_ = params.is_full_page_plugin; | 289 is_full_page_plugin_ = params.is_full_page_plugin; |
| 289 guest_window_rect_ = params.view_rect; | 290 guest_window_rect_ = params.view_rect; |
| 290 | 291 |
| 291 if (owner_web_contents_ != owner_web_contents) { | 292 if (owner_web_contents_ != owner_web_contents) { |
| 292 WebContentsViewGuest* new_view = nullptr; | 293 WebContentsViewGuest* new_view = nullptr; |
| 293 if (!BrowserPluginGuestMode::UseCrossProcessFramesForGuests()) { | 294 if (!GuestMode::IsCrossProcessFrameGuest(GetWebContents())) { |
| 294 new_view = | 295 new_view = |
| 295 static_cast<WebContentsViewGuest*>(GetWebContents()->GetView()); | 296 static_cast<WebContentsViewGuest*>(GetWebContents()->GetView()); |
| 296 } | 297 } |
| 297 | 298 |
| 298 if (owner_web_contents_ && new_view) | 299 if (owner_web_contents_ && new_view) |
| 299 new_view->OnGuestDetached(owner_web_contents_->GetView()); | 300 new_view->OnGuestDetached(owner_web_contents_->GetView()); |
| 300 | 301 |
| 301 // Once a BrowserPluginGuest has an embedder WebContents, it's considered to | 302 // Once a BrowserPluginGuest has an embedder WebContents, it's considered to |
| 302 // be attached. | 303 // be attached. |
| 303 owner_web_contents_ = owner_web_contents; | 304 owner_web_contents_ = owner_web_contents; |
| (...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 670 | 671 |
| 671 bool BrowserPluginGuest::OnMessageReceived(const IPC::Message& message) { | 672 bool BrowserPluginGuest::OnMessageReceived(const IPC::Message& message) { |
| 672 bool handled = true; | 673 bool handled = true; |
| 673 // In --site-per-process, we do not need most of BrowserPluginGuest to drive | 674 // In --site-per-process, we do not need most of BrowserPluginGuest to drive |
| 674 // inner WebContents. | 675 // inner WebContents. |
| 675 // Right now InputHostMsg_ImeCompositionRangeChanged hits NOTREACHED() in | 676 // Right now InputHostMsg_ImeCompositionRangeChanged hits NOTREACHED() in |
| 676 // RWHVChildFrame, so we're disabling message handling entirely here. | 677 // RWHVChildFrame, so we're disabling message handling entirely here. |
| 677 // TODO(lazyboy): Fix this as part of http://crbug.com/330264. The required | 678 // 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 | 679 // parts of code from this class should be extracted to a separate class for |
| 679 // --site-per-process. | 680 // --site-per-process. |
| 680 if (BrowserPluginGuestMode::UseCrossProcessFramesForGuests()) { | 681 if (GuestMode::IsCrossProcessFrameGuest(GetWebContents())) |
| 681 return false; | 682 return false; |
| 682 } | |
| 683 | 683 |
| 684 IPC_BEGIN_MESSAGE_MAP(BrowserPluginGuest, message) | 684 IPC_BEGIN_MESSAGE_MAP(BrowserPluginGuest, message) |
| 685 IPC_MESSAGE_HANDLER(InputHostMsg_ImeCancelComposition, | 685 IPC_MESSAGE_HANDLER(InputHostMsg_ImeCancelComposition, |
| 686 OnImeCancelComposition) | 686 OnImeCancelComposition) |
| 687 #if defined(OS_MACOSX) || defined(USE_AURA) | 687 #if defined(OS_MACOSX) || defined(USE_AURA) |
| 688 IPC_MESSAGE_HANDLER(InputHostMsg_ImeCompositionRangeChanged, | 688 IPC_MESSAGE_HANDLER(InputHostMsg_ImeCompositionRangeChanged, |
| 689 OnImeCompositionRangeChanged) | 689 OnImeCompositionRangeChanged) |
| 690 #endif | 690 #endif |
| 691 IPC_MESSAGE_HANDLER(ViewHostMsg_HasTouchEventHandlers, | 691 IPC_MESSAGE_HANDLER(ViewHostMsg_HasTouchEventHandlers, |
| 692 OnHasTouchEventHandlers) | 692 OnHasTouchEventHandlers) |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 920 void BrowserPluginGuest::OnSetEditCommandsForNextKeyEvent( | 920 void BrowserPluginGuest::OnSetEditCommandsForNextKeyEvent( |
| 921 int browser_plugin_instance_id, | 921 int browser_plugin_instance_id, |
| 922 const std::vector<EditCommand>& edit_commands) { | 922 const std::vector<EditCommand>& edit_commands) { |
| 923 Send(new InputMsg_SetEditCommandsForNextKeyEvent(routing_id(), | 923 Send(new InputMsg_SetEditCommandsForNextKeyEvent(routing_id(), |
| 924 edit_commands)); | 924 edit_commands)); |
| 925 } | 925 } |
| 926 | 926 |
| 927 void BrowserPluginGuest::OnSetVisibility(int browser_plugin_instance_id, | 927 void BrowserPluginGuest::OnSetVisibility(int browser_plugin_instance_id, |
| 928 bool visible) { | 928 bool visible) { |
| 929 // For OOPIF-<webivew>, the remote frame will handle visibility state. | 929 // For OOPIF-<webivew>, the remote frame will handle visibility state. |
| 930 if (BrowserPluginGuestMode::UseCrossProcessFramesForGuests()) | 930 if (GuestMode::IsCrossProcessFrameGuest(GetWebContents())) |
| 931 return; | 931 return; |
| 932 | 932 |
| 933 guest_visible_ = visible; | 933 guest_visible_ = visible; |
| 934 if (embedder_visible_ && guest_visible_) | 934 if (embedder_visible_ && guest_visible_) |
| 935 GetWebContents()->WasShown(); | 935 GetWebContents()->WasShown(); |
| 936 else | 936 else |
| 937 GetWebContents()->WasHidden(); | 937 GetWebContents()->WasHidden(); |
| 938 } | 938 } |
| 939 | 939 |
| 940 void BrowserPluginGuest::OnUnlockMouse() { | 940 void BrowserPluginGuest::OnUnlockMouse() { |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1017 range, character_bounds); | 1017 range, character_bounds); |
| 1018 } | 1018 } |
| 1019 #endif | 1019 #endif |
| 1020 | 1020 |
| 1021 void BrowserPluginGuest::SetContextMenuPosition(const gfx::Point& position) { | 1021 void BrowserPluginGuest::SetContextMenuPosition(const gfx::Point& position) { |
| 1022 if (delegate_) | 1022 if (delegate_) |
| 1023 delegate_->SetContextMenuPosition(position); | 1023 delegate_->SetContextMenuPosition(position); |
| 1024 } | 1024 } |
| 1025 | 1025 |
| 1026 } // namespace content | 1026 } // namespace content |
| OLD | NEW |