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

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

Issue 1208143002: Move existing kSitePerProcess checks to a policy-oracle object (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@swapped_out_cmdline_checks
Patch Set: Attempt to fix compile. Created 5 years, 4 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/command_line.h"
10 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
11 #include "base/pickle.h" 10 #include "base/pickle.h"
12 #include "base/strings/utf_string_conversions.h" 11 #include "base/strings/utf_string_conversions.h"
13 #include "cc/surfaces/surface.h" 12 #include "cc/surfaces/surface.h"
14 #include "cc/surfaces/surface_manager.h" 13 #include "cc/surfaces/surface_manager.h"
15 #include "content/browser/browser_plugin/browser_plugin_embedder.h" 14 #include "content/browser/browser_plugin/browser_plugin_embedder.h"
16 #include "content/browser/browser_thread_impl.h" 15 #include "content/browser/browser_thread_impl.h"
17 #include "content/browser/child_process_security_policy_impl.h" 16 #include "content/browser/child_process_security_policy_impl.h"
18 #include "content/browser/compositor/surface_utils.h" 17 #include "content/browser/compositor/surface_utils.h"
19 #include "content/browser/frame_host/render_frame_host_impl.h" 18 #include "content/browser/frame_host/render_frame_host_impl.h"
(...skipping 11 matching lines...) Expand all
31 #include "content/common/host_shared_bitmap_manager.h" 30 #include "content/common/host_shared_bitmap_manager.h"
32 #include "content/common/input_messages.h" 31 #include "content/common/input_messages.h"
33 #include "content/common/view_messages.h" 32 #include "content/common/view_messages.h"
34 #include "content/public/browser/browser_context.h" 33 #include "content/public/browser/browser_context.h"
35 #include "content/public/browser/browser_plugin_guest_manager.h" 34 #include "content/public/browser/browser_plugin_guest_manager.h"
36 #include "content/public/browser/content_browser_client.h" 35 #include "content/public/browser/content_browser_client.h"
37 #include "content/public/browser/guest_host.h" 36 #include "content/public/browser/guest_host.h"
38 #include "content/public/browser/render_widget_host_view.h" 37 #include "content/public/browser/render_widget_host_view.h"
39 #include "content/public/browser/user_metrics.h" 38 #include "content/public/browser/user_metrics.h"
40 #include "content/public/browser/web_contents_observer.h" 39 #include "content/public/browser/web_contents_observer.h"
41 #include "content/public/common/content_switches.h" 40 #include "content/public/common/browser_plugin_guest_mode.h"
42 #include "content/public/common/drop_data.h" 41 #include "content/public/common/drop_data.h"
43 #include "ui/gfx/geometry/size_conversions.h" 42 #include "ui/gfx/geometry/size_conversions.h"
44 43
45 #if defined(OS_MACOSX) 44 #if defined(OS_MACOSX)
46 #include "content/browser/browser_plugin/browser_plugin_popup_menu_helper_mac.h" 45 #include "content/browser/browser_plugin/browser_plugin_popup_menu_helper_mac.h"
47 #include "content/common/frame_messages.h" 46 #include "content/common/frame_messages.h"
48 #endif 47 #endif
49 48
50 namespace content { 49 namespace content {
51 50
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 delegate_(delegate), 101 delegate_(delegate),
103 weak_ptr_factory_(this) { 102 weak_ptr_factory_(this) {
104 DCHECK(web_contents); 103 DCHECK(web_contents);
105 DCHECK(delegate); 104 DCHECK(delegate);
106 RecordAction(base::UserMetricsAction("BrowserPlugin.Guest.Create")); 105 RecordAction(base::UserMetricsAction("BrowserPlugin.Guest.Create"));
107 web_contents->SetBrowserPluginGuest(this); 106 web_contents->SetBrowserPluginGuest(this);
108 delegate->SetGuestHost(this); 107 delegate->SetGuestHost(this);
109 } 108 }
110 109
111 int BrowserPluginGuest::GetGuestProxyRoutingID() { 110 int BrowserPluginGuest::GetGuestProxyRoutingID() {
112 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 111 if (BrowserPluginGuestMode::UseCrossProcessFramesForGuests()) {
113 switches::kSitePerProcess)) {
114 // We don't use the proxy to send postMessage in --site-per-process, since 112 // We don't use the proxy to send postMessage in --site-per-process, since
115 // we use the contentWindow directly from the frame element instead. 113 // we use the contentWindow directly from the frame element instead.
116 return MSG_ROUTING_NONE; 114 return MSG_ROUTING_NONE;
117 } 115 }
118 116
119 if (guest_proxy_routing_id_ != MSG_ROUTING_NONE) 117 if (guest_proxy_routing_id_ != MSG_ROUTING_NONE)
120 return guest_proxy_routing_id_; 118 return guest_proxy_routing_id_;
121 119
122 // Create a swapped out RenderView for the guest in the embedder renderer 120 // Create a swapped out RenderView for the guest in the embedder renderer
123 // process, so that the embedder can access the guest's window object. 121 // process, so that the embedder can access the guest's window object.
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 blink::WebFocusTypeNone); 269 blink::WebFocusTypeNone);
272 270
273 guest_visible_ = params.visible; 271 guest_visible_ = params.visible;
274 UpdateVisibility(); 272 UpdateVisibility();
275 273
276 is_full_page_plugin_ = params.is_full_page_plugin; 274 is_full_page_plugin_ = params.is_full_page_plugin;
277 guest_window_rect_ = params.view_rect; 275 guest_window_rect_ = params.view_rect;
278 276
279 if (owner_web_contents_ != owner_web_contents) { 277 if (owner_web_contents_ != owner_web_contents) {
280 WebContentsViewGuest* new_view = nullptr; 278 WebContentsViewGuest* new_view = nullptr;
281 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( 279 if (!BrowserPluginGuestMode::UseCrossProcessFramesForGuests()) {
282 switches::kSitePerProcess)) {
283 new_view = 280 new_view =
284 static_cast<WebContentsViewGuest*>(GetWebContents()->GetView()); 281 static_cast<WebContentsViewGuest*>(GetWebContents()->GetView());
285 } 282 }
286 283
287 if (owner_web_contents_ && new_view) 284 if (owner_web_contents_ && new_view)
288 new_view->OnGuestDetached(owner_web_contents_->GetView()); 285 new_view->OnGuestDetached(owner_web_contents_->GetView());
289 286
290 // Once a BrowserPluginGuest has an embedder WebContents, it's considered to 287 // Once a BrowserPluginGuest has an embedder WebContents, it's considered to
291 // be attached. 288 // be attached.
292 owner_web_contents_ = owner_web_contents; 289 owner_web_contents_ = owner_web_contents;
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
619 616
620 bool BrowserPluginGuest::OnMessageReceived(const IPC::Message& message) { 617 bool BrowserPluginGuest::OnMessageReceived(const IPC::Message& message) {
621 bool handled = true; 618 bool handled = true;
622 // In --site-per-process, we do not need most of BrowserPluginGuest to drive 619 // In --site-per-process, we do not need most of BrowserPluginGuest to drive
623 // inner WebContents. 620 // inner WebContents.
624 // Right now InputHostMsg_ImeCompositionRangeChanged hits NOTREACHED() in 621 // Right now InputHostMsg_ImeCompositionRangeChanged hits NOTREACHED() in
625 // RWHVChildFrame, so we're disabling message handling entirely here. 622 // RWHVChildFrame, so we're disabling message handling entirely here.
626 // TODO(lazyboy): Fix this as part of http://crbug.com/330264. The required 623 // TODO(lazyboy): Fix this as part of http://crbug.com/330264. The required
627 // parts of code from this class should be extracted to a separate class for 624 // parts of code from this class should be extracted to a separate class for
628 // --site-per-process. 625 // --site-per-process.
629 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 626 if (BrowserPluginGuestMode::UseCrossProcessFramesForGuests()) {
630 switches::kSitePerProcess)) {
631 return false; 627 return false;
632 } 628 }
633 629
634 IPC_BEGIN_MESSAGE_MAP(BrowserPluginGuest, message) 630 IPC_BEGIN_MESSAGE_MAP(BrowserPluginGuest, message)
635 IPC_MESSAGE_HANDLER(InputHostMsg_ImeCancelComposition, 631 IPC_MESSAGE_HANDLER(InputHostMsg_ImeCancelComposition,
636 OnImeCancelComposition) 632 OnImeCancelComposition)
637 #if defined(OS_MACOSX) || defined(USE_AURA) 633 #if defined(OS_MACOSX) || defined(USE_AURA)
638 IPC_MESSAGE_HANDLER(InputHostMsg_ImeCompositionRangeChanged, 634 IPC_MESSAGE_HANDLER(InputHostMsg_ImeCompositionRangeChanged,
639 OnImeCompositionRangeChanged) 635 OnImeCompositionRangeChanged)
640 #endif 636 #endif
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
704 delegate_->WillAttach(embedder_web_contents, browser_plugin_instance_id, 700 delegate_->WillAttach(embedder_web_contents, browser_plugin_instance_id,
705 params.is_full_page_plugin, 701 params.is_full_page_plugin,
706 base::Bind(&BrowserPluginGuest::OnWillAttachComplete, 702 base::Bind(&BrowserPluginGuest::OnWillAttachComplete,
707 weak_ptr_factory_.GetWeakPtr(), 703 weak_ptr_factory_.GetWeakPtr(),
708 embedder_web_contents, params)); 704 embedder_web_contents, params));
709 } 705 }
710 706
711 void BrowserPluginGuest::OnWillAttachComplete( 707 void BrowserPluginGuest::OnWillAttachComplete(
712 WebContentsImpl* embedder_web_contents, 708 WebContentsImpl* embedder_web_contents,
713 const BrowserPluginHostMsg_Attach_Params& params) { 709 const BrowserPluginHostMsg_Attach_Params& params) {
714 bool use_site_per_process = base::CommandLine::ForCurrentProcess()->HasSwitch( 710 bool use_cross_process_frames =
715 switches::kSitePerProcess); 711 BrowserPluginGuestMode::UseCrossProcessFramesForGuests();
716 // If a RenderView has already been created for this new window, then we need 712 // If a RenderView has already been created for this new window, then we need
717 // to initialize the browser-side state now so that the RenderFrameHostManager 713 // to initialize the browser-side state now so that the RenderFrameHostManager
718 // does not create a new RenderView on navigation. 714 // does not create a new RenderView on navigation.
719 if (!use_site_per_process && has_render_view_) { 715 if (!use_cross_process_frames && has_render_view_) {
720 // This will trigger a callback to RenderViewReady after a round-trip IPC. 716 // This will trigger a callback to RenderViewReady after a round-trip IPC.
721 static_cast<RenderViewHostImpl*>( 717 static_cast<RenderViewHostImpl*>(
722 GetWebContents()->GetRenderViewHost())->Init(); 718 GetWebContents()->GetRenderViewHost())->Init();
723 WebContentsViewGuest* web_contents_view = 719 WebContentsViewGuest* web_contents_view =
724 static_cast<WebContentsViewGuest*>(GetWebContents()->GetView()); 720 static_cast<WebContentsViewGuest*>(GetWebContents()->GetView());
725 if (!web_contents()->GetRenderViewHost()->GetView()) { 721 if (!web_contents()->GetRenderViewHost()->GetView()) {
726 web_contents_view->CreateViewForWidget( 722 web_contents_view->CreateViewForWidget(
727 web_contents()->GetRenderViewHost(), true); 723 web_contents()->GetRenderViewHost(), true);
728 } 724 }
729 } 725 }
730 726
731 InitInternal(params, embedder_web_contents); 727 InitInternal(params, embedder_web_contents);
732 728
733 attached_ = true; 729 attached_ = true;
734 has_attached_since_surface_set_ = true; 730 has_attached_since_surface_set_ = true;
735 SendQueuedMessages(); 731 SendQueuedMessages();
736 732
737 delegate_->DidAttach(GetGuestProxyRoutingID()); 733 delegate_->DidAttach(GetGuestProxyRoutingID());
738 734
739 if (!use_site_per_process) 735 if (!use_cross_process_frames)
740 has_render_view_ = true; 736 has_render_view_ = true;
741 737
742 RecordAction(base::UserMetricsAction("BrowserPlugin.Guest.Attached")); 738 RecordAction(base::UserMetricsAction("BrowserPlugin.Guest.Attached"));
743 } 739 }
744 740
745 void BrowserPluginGuest::OnCompositorFrameSwappedACK( 741 void BrowserPluginGuest::OnCompositorFrameSwappedACK(
746 int browser_plugin_instance_id, 742 int browser_plugin_instance_id,
747 const FrameHostMsg_CompositorFrameSwappedACK_Params& params) { 743 const FrameHostMsg_CompositorFrameSwappedACK_Params& params) {
748 RenderWidgetHostImpl::SendSwapCompositorFrameAck(params.producing_route_id, 744 RenderWidgetHostImpl::SendSwapCompositorFrameAck(params.producing_route_id,
749 params.output_surface_id, 745 params.output_surface_id,
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
983 void BrowserPluginGuest::OnImeCompositionRangeChanged( 979 void BrowserPluginGuest::OnImeCompositionRangeChanged(
984 const gfx::Range& range, 980 const gfx::Range& range,
985 const std::vector<gfx::Rect>& character_bounds) { 981 const std::vector<gfx::Rect>& character_bounds) {
986 static_cast<RenderWidgetHostViewBase*>( 982 static_cast<RenderWidgetHostViewBase*>(
987 web_contents()->GetRenderWidgetHostView())->ImeCompositionRangeChanged( 983 web_contents()->GetRenderWidgetHostView())->ImeCompositionRangeChanged(
988 range, character_bounds); 984 range, character_bounds);
989 } 985 }
990 #endif 986 #endif
991 987
992 } // namespace content 988 } // namespace content
OLDNEW
« no previous file with comments | « components/guest_view/renderer/iframe_guest_view_container.cc ('k') | content/browser/child_process_security_policy_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698