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

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: Partial fixes to Nasko's comments. Created 5 years, 5 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"
42 #include "content/public/common/drop_data.h" 40 #include "content/public/common/drop_data.h"
41 #include "content/public/common/site_isolation_policy.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
52 class BrowserPluginGuest::EmbedderVisibilityObserver 51 class BrowserPluginGuest::EmbedderVisibilityObserver
(...skipping 49 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 (SiteIsolationPolicy::GuestsShouldUseCrossProcessFrames()) {
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 (!SiteIsolationPolicy::GuestsShouldUseCrossProcessFrames()) {
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 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
632 629
633 bool BrowserPluginGuest::OnMessageReceived(const IPC::Message& message) { 630 bool BrowserPluginGuest::OnMessageReceived(const IPC::Message& message) {
634 bool handled = true; 631 bool handled = true;
635 // In --site-per-process, we do not need most of BrowserPluginGuest to drive 632 // In --site-per-process, we do not need most of BrowserPluginGuest to drive
636 // inner WebContents. 633 // inner WebContents.
637 // Right now InputHostMsg_ImeCompositionRangeChanged hits NOTREACHED() in 634 // Right now InputHostMsg_ImeCompositionRangeChanged hits NOTREACHED() in
638 // RWHVChildFrame, so we're disabling message handling entirely here. 635 // RWHVChildFrame, so we're disabling message handling entirely here.
639 // TODO(lazyboy): Fix this as part of http://crbug.com/330264. The required 636 // TODO(lazyboy): Fix this as part of http://crbug.com/330264. The required
640 // parts of code from this class should be extracted to a separate class for 637 // parts of code from this class should be extracted to a separate class for
641 // --site-per-process. 638 // --site-per-process.
642 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 639 if (SiteIsolationPolicy::GuestsShouldUseCrossProcessFrames()) {
643 switches::kSitePerProcess)) {
644 return false; 640 return false;
645 } 641 }
646 642
647 IPC_BEGIN_MESSAGE_MAP(BrowserPluginGuest, message) 643 IPC_BEGIN_MESSAGE_MAP(BrowserPluginGuest, message)
648 IPC_MESSAGE_HANDLER(InputHostMsg_ImeCancelComposition, 644 IPC_MESSAGE_HANDLER(InputHostMsg_ImeCancelComposition,
649 OnImeCancelComposition) 645 OnImeCancelComposition)
650 #if defined(OS_MACOSX) || defined(USE_AURA) 646 #if defined(OS_MACOSX) || defined(USE_AURA)
651 IPC_MESSAGE_HANDLER(InputHostMsg_ImeCompositionRangeChanged, 647 IPC_MESSAGE_HANDLER(InputHostMsg_ImeCompositionRangeChanged,
652 OnImeCompositionRangeChanged) 648 OnImeCompositionRangeChanged)
653 #endif 649 #endif
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
717 delegate_->WillAttach(embedder_web_contents, browser_plugin_instance_id, 713 delegate_->WillAttach(embedder_web_contents, browser_plugin_instance_id,
718 params.is_full_page_plugin, 714 params.is_full_page_plugin,
719 base::Bind(&BrowserPluginGuest::OnWillAttachComplete, 715 base::Bind(&BrowserPluginGuest::OnWillAttachComplete,
720 weak_ptr_factory_.GetWeakPtr(), 716 weak_ptr_factory_.GetWeakPtr(),
721 embedder_web_contents, params)); 717 embedder_web_contents, params));
722 } 718 }
723 719
724 void BrowserPluginGuest::OnWillAttachComplete( 720 void BrowserPluginGuest::OnWillAttachComplete(
725 WebContentsImpl* embedder_web_contents, 721 WebContentsImpl* embedder_web_contents,
726 const BrowserPluginHostMsg_Attach_Params& params) { 722 const BrowserPluginHostMsg_Attach_Params& params) {
727 bool use_site_per_process = base::CommandLine::ForCurrentProcess()->HasSwitch( 723 bool use_cross_process_frames =
728 switches::kSitePerProcess); 724 SiteIsolationPolicy::GuestsShouldUseCrossProcessFrames();
729 // If a RenderView has already been created for this new window, then we need 725 // If a RenderView has already been created for this new window, then we need
730 // to initialize the browser-side state now so that the RenderFrameHostManager 726 // to initialize the browser-side state now so that the RenderFrameHostManager
731 // does not create a new RenderView on navigation. 727 // does not create a new RenderView on navigation.
732 if (!use_site_per_process && has_render_view_) { 728 if (!use_cross_process_frames && has_render_view_) {
733 // This will trigger a callback to RenderViewReady after a round-trip IPC. 729 // This will trigger a callback to RenderViewReady after a round-trip IPC.
734 static_cast<RenderViewHostImpl*>( 730 static_cast<RenderViewHostImpl*>(
735 GetWebContents()->GetRenderViewHost())->Init(); 731 GetWebContents()->GetRenderViewHost())->Init();
736 WebContentsViewGuest* web_contents_view = 732 WebContentsViewGuest* web_contents_view =
737 static_cast<WebContentsViewGuest*>(GetWebContents()->GetView()); 733 static_cast<WebContentsViewGuest*>(GetWebContents()->GetView());
738 if (!web_contents()->GetRenderViewHost()->GetView()) { 734 if (!web_contents()->GetRenderViewHost()->GetView()) {
739 web_contents_view->CreateViewForWidget( 735 web_contents_view->CreateViewForWidget(
740 web_contents()->GetRenderViewHost(), true); 736 web_contents()->GetRenderViewHost(), true);
741 } 737 }
742 } 738 }
743 739
744 InitInternal(params, embedder_web_contents); 740 InitInternal(params, embedder_web_contents);
745 741
746 attached_ = true; 742 attached_ = true;
747 has_attached_since_surface_set_ = true; 743 has_attached_since_surface_set_ = true;
748 SendQueuedMessages(); 744 SendQueuedMessages();
749 745
750 delegate_->DidAttach(GetGuestProxyRoutingID()); 746 delegate_->DidAttach(GetGuestProxyRoutingID());
751 747
752 if (!use_site_per_process) { 748 if (!use_cross_process_frames) {
753 has_render_view_ = true; 749 has_render_view_ = true;
754 750
755 // Enable input method for guest if it's enabled for the embedder. 751 // Enable input method for guest if it's enabled for the embedder.
756 if (static_cast<RenderViewHostImpl*>( 752 if (static_cast<RenderViewHostImpl*>(
757 owner_web_contents_->GetRenderViewHost())->input_method_active()) { 753 owner_web_contents_->GetRenderViewHost())->input_method_active()) {
758 RenderViewHostImpl* guest_rvh = static_cast<RenderViewHostImpl*>( 754 RenderViewHostImpl* guest_rvh = static_cast<RenderViewHostImpl*>(
759 GetWebContents()->GetRenderViewHost()); 755 GetWebContents()->GetRenderViewHost());
760 guest_rvh->SetInputMethodActive(true); 756 guest_rvh->SetInputMethodActive(true);
761 } 757 }
762 } 758 }
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
1005 void BrowserPluginGuest::OnImeCompositionRangeChanged( 1001 void BrowserPluginGuest::OnImeCompositionRangeChanged(
1006 const gfx::Range& range, 1002 const gfx::Range& range,
1007 const std::vector<gfx::Rect>& character_bounds) { 1003 const std::vector<gfx::Rect>& character_bounds) {
1008 static_cast<RenderWidgetHostViewBase*>( 1004 static_cast<RenderWidgetHostViewBase*>(
1009 web_contents()->GetRenderWidgetHostView())->ImeCompositionRangeChanged( 1005 web_contents()->GetRenderWidgetHostView())->ImeCompositionRangeChanged(
1010 range, character_bounds); 1006 range, character_bounds);
1011 } 1007 }
1012 #endif 1008 #endif
1013 1009
1014 } // namespace content 1010 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698