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

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

Issue 972313002: Make <webview> use out-of-process iframe architecture. (Closed) Base URL: ssh://saopaulo.wat/mnt/dev/shared/src@testoopif2z-better-chrome
Patch Set: Make <webview> work without --site-per-process as well Created 5 years, 7 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 // Note that all IPC sent out from this class will be dropped on the
6 // floor b/c we don't have a BrowserPlugin anymore.
Charlie Reis 2015/04/30 23:06:45 Class-level comments belong on the class declarati
lazyboy 2015/05/05 07:28:13 Done.
5 #include "content/browser/browser_plugin/browser_plugin_guest.h" 7 #include "content/browser/browser_plugin/browser_plugin_guest.h"
6 8
7 #include <algorithm> 9 #include <algorithm>
8 10
11 #include "base/command_line.h"
9 #include "base/message_loop/message_loop.h" 12 #include "base/message_loop/message_loop.h"
10 #include "base/pickle.h" 13 #include "base/pickle.h"
11 #include "base/strings/utf_string_conversions.h" 14 #include "base/strings/utf_string_conversions.h"
12 #include "content/browser/browser_plugin/browser_plugin_embedder.h" 15 #include "content/browser/browser_plugin/browser_plugin_embedder.h"
13 #include "content/browser/browser_thread_impl.h" 16 #include "content/browser/browser_thread_impl.h"
14 #include "content/browser/child_process_security_policy_impl.h" 17 #include "content/browser/child_process_security_policy_impl.h"
15 #include "content/browser/frame_host/render_frame_host_impl.h" 18 #include "content/browser/frame_host/render_frame_host_impl.h"
16 #include "content/browser/frame_host/render_widget_host_view_guest.h" 19 #include "content/browser/frame_host/render_widget_host_view_guest.h"
17 #include "content/browser/loader/resource_dispatcher_host_impl.h" 20 #include "content/browser/loader/resource_dispatcher_host_impl.h"
18 #include "content/browser/renderer_host/render_view_host_impl.h" 21 #include "content/browser/renderer_host/render_view_host_impl.h"
19 #include "content/browser/renderer_host/render_widget_host_impl.h" 22 #include "content/browser/renderer_host/render_widget_host_impl.h"
20 #include "content/browser/renderer_host/render_widget_host_view_base.h" 23 #include "content/browser/renderer_host/render_widget_host_view_base.h"
21 #include "content/browser/web_contents/web_contents_impl.h" 24 #include "content/browser/web_contents/web_contents_impl.h"
22 #include "content/browser/web_contents/web_contents_view_guest.h" 25 #include "content/browser/web_contents/web_contents_view_guest.h"
23 #include "content/common/browser_plugin/browser_plugin_constants.h" 26 #include "content/common/browser_plugin/browser_plugin_constants.h"
24 #include "content/common/browser_plugin/browser_plugin_messages.h" 27 #include "content/common/browser_plugin/browser_plugin_messages.h"
25 #include "content/common/content_constants_internal.h" 28 #include "content/common/content_constants_internal.h"
26 #include "content/common/drag_messages.h" 29 #include "content/common/drag_messages.h"
27 #include "content/common/frame_messages.h" 30 #include "content/common/frame_messages.h"
28 #include "content/common/host_shared_bitmap_manager.h" 31 #include "content/common/host_shared_bitmap_manager.h"
29 #include "content/common/input_messages.h" 32 #include "content/common/input_messages.h"
30 #include "content/common/view_messages.h" 33 #include "content/common/view_messages.h"
31 #include "content/public/browser/browser_context.h" 34 #include "content/public/browser/browser_context.h"
32 #include "content/public/browser/browser_plugin_guest_manager.h" 35 #include "content/public/browser/browser_plugin_guest_manager.h"
33 #include "content/public/browser/content_browser_client.h" 36 #include "content/public/browser/content_browser_client.h"
34 #include "content/public/browser/guest_host.h" 37 #include "content/public/browser/guest_host.h"
35 #include "content/public/browser/render_widget_host_view.h" 38 #include "content/public/browser/render_widget_host_view.h"
36 #include "content/public/browser/user_metrics.h" 39 #include "content/public/browser/user_metrics.h"
37 #include "content/public/browser/web_contents_observer.h" 40 #include "content/public/browser/web_contents_observer.h"
41 #include "content/public/common/content_switches.h"
38 #include "content/public/common/drop_data.h" 42 #include "content/public/common/drop_data.h"
39 #include "ui/gfx/geometry/size_conversions.h" 43 #include "ui/gfx/geometry/size_conversions.h"
40 44
41 #if defined(OS_MACOSX) 45 #if defined(OS_MACOSX)
42 #include "content/browser/browser_plugin/browser_plugin_popup_menu_helper_mac.h" 46 #include "content/browser/browser_plugin/browser_plugin_popup_menu_helper_mac.h"
43 #endif 47 #endif
44 48
45 namespace content { 49 namespace content {
46 50
47 class BrowserPluginGuest::EmbedderVisibilityObserver 51 class BrowserPluginGuest::EmbedderVisibilityObserver
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 delegate_(delegate), 100 delegate_(delegate),
97 weak_ptr_factory_(this) { 101 weak_ptr_factory_(this) {
98 DCHECK(web_contents); 102 DCHECK(web_contents);
99 DCHECK(delegate); 103 DCHECK(delegate);
100 RecordAction(base::UserMetricsAction("BrowserPlugin.Guest.Create")); 104 RecordAction(base::UserMetricsAction("BrowserPlugin.Guest.Create"));
101 web_contents->SetBrowserPluginGuest(this); 105 web_contents->SetBrowserPluginGuest(this);
102 delegate->SetGuestHost(this); 106 delegate->SetGuestHost(this);
103 } 107 }
104 108
105 int BrowserPluginGuest::GetGuestProxyRoutingID() { 109 int BrowserPluginGuest::GetGuestProxyRoutingID() {
110 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
111 switches::kSitePerProcess)) {
112 // Don't create the proxy here, we'll create it later.
Charlie Reis 2015/04/30 23:06:45 nit: Semi-colon or period. (In general, two compl
lazyboy 2015/05/05 07:28:13 Done.
113 return MSG_ROUTING_NONE;
114 }
115
106 if (guest_proxy_routing_id_ != MSG_ROUTING_NONE) 116 if (guest_proxy_routing_id_ != MSG_ROUTING_NONE)
107 return guest_proxy_routing_id_; 117 return guest_proxy_routing_id_;
108 118
109 // Create a swapped out RenderView for the guest in the embedder renderer 119 // Create a swapped out RenderView for the guest in the embedder renderer
110 // process, so that the embedder can access the guest's window object. 120 // process, so that the embedder can access the guest's window object.
111 // On reattachment, we can reuse the same swapped out RenderView because 121 // On reattachment, we can reuse the same swapped out RenderView because
112 // the embedder process will always be the same even if the embedder 122 // the embedder process will always be the same even if the embedder
113 // WebContents changes. 123 // WebContents changes.
114 // 124 //
115 // TODO(fsamuel): Make sure this works for transferring guests across 125 // TODO(fsamuel): Make sure this works for transferring guests across
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 blink::WebFocusTypeNone); 266 blink::WebFocusTypeNone);
257 267
258 guest_visible_ = params.visible; 268 guest_visible_ = params.visible;
259 UpdateVisibility(); 269 UpdateVisibility();
260 270
261 is_full_page_plugin_ = params.is_full_page_plugin; 271 is_full_page_plugin_ = params.is_full_page_plugin;
262 guest_window_rect_ = params.view_rect; 272 guest_window_rect_ = params.view_rect;
263 273
264 if (owner_web_contents_ != owner_web_contents) { 274 if (owner_web_contents_ != owner_web_contents) {
265 WebContentsViewGuest* new_view = 275 WebContentsViewGuest* new_view =
266 static_cast<WebContentsViewGuest*>(GetWebContents()->GetView()); 276 base::CommandLine::ForCurrentProcess()->HasSwitch(
267 if (owner_web_contents_) 277 switches::kSitePerProcess) ?
278 nullptr :
279 static_cast<WebContentsViewGuest*>(GetWebContents()->GetView());
Charlie Reis 2015/04/30 23:06:45 Wrong indent? git cl format can help.
lazyboy 2015/05/05 07:28:13 Done.
280 if (owner_web_contents_ && new_view)
268 new_view->OnGuestDetached(owner_web_contents_->GetView()); 281 new_view->OnGuestDetached(owner_web_contents_->GetView());
269 282
270 // Once a BrowserPluginGuest has an embedder WebContents, it's considered to 283 // Once a BrowserPluginGuest has an embedder WebContents, it's considered to
271 // be attached. 284 // be attached.
272 owner_web_contents_ = owner_web_contents; 285 owner_web_contents_ = owner_web_contents;
273 new_view->OnGuestAttached(owner_web_contents_->GetView()); 286 if (new_view)
287 new_view->OnGuestAttached(owner_web_contents_->GetView());
274 } 288 }
275 289
276 RendererPreferences* renderer_prefs = 290 RendererPreferences* renderer_prefs =
277 GetWebContents()->GetMutableRendererPrefs(); 291 GetWebContents()->GetMutableRendererPrefs();
278 std::string guest_user_agent_override = renderer_prefs->user_agent_override; 292 std::string guest_user_agent_override = renderer_prefs->user_agent_override;
279 // Copy renderer preferences (and nothing else) from the embedder's 293 // Copy renderer preferences (and nothing else) from the embedder's
280 // WebContents to the guest. 294 // WebContents to the guest.
281 // 295 //
282 // For GTK and Aura this is necessary to get proper renderer configuration 296 // For GTK and Aura this is necessary to get proper renderer configuration
283 // values for caret blinking interval, colors related to selection and 297 // values for caret blinking interval, colors related to selection and
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after
645 RenderWidgetHostImpl::SendSwapCompositorFrameAck( 659 RenderWidgetHostImpl::SendSwapCompositorFrameAck(
646 last_pending_frame_->producing_route_id, 660 last_pending_frame_->producing_route_id,
647 last_pending_frame_->output_surface_id, 661 last_pending_frame_->output_surface_id,
648 last_pending_frame_->producing_host_id, 662 last_pending_frame_->producing_host_id,
649 ack); 663 ack);
650 last_pending_frame_.reset(); 664 last_pending_frame_.reset();
651 } 665 }
652 delegate_->WillAttach(embedder_web_contents, browser_plugin_instance_id, 666 delegate_->WillAttach(embedder_web_contents, browser_plugin_instance_id,
653 params.is_full_page_plugin); 667 params.is_full_page_plugin);
654 668
669 bool use_site_per_process =
670 base::CommandLine::ForCurrentProcess()->HasSwitch(
671 switches::kSitePerProcess);
655 // If a RenderView has already been created for this new window, then we need 672 // If a RenderView has already been created for this new window, then we need
656 // to initialize the browser-side state now so that the RenderFrameHostManager 673 // to initialize the browser-side state now so that the RenderFrameHostManager
657 // does not create a new RenderView on navigation. 674 // does not create a new RenderView on navigation.
658 if (has_render_view_) { 675 if (!use_site_per_process && has_render_view_) {
659 // This will trigger a callback to RenderViewReady after a round-trip IPC. 676 // This will trigger a callback to RenderViewReady after a round-trip IPC.
660 static_cast<RenderViewHostImpl*>( 677 static_cast<RenderViewHostImpl*>(
661 GetWebContents()->GetRenderViewHost())->Init(); 678 GetWebContents()->GetRenderViewHost())->Init();
662 WebContentsViewGuest* web_contents_view = 679 WebContentsViewGuest* web_contents_view =
663 static_cast<WebContentsViewGuest*>(GetWebContents()->GetView()); 680 static_cast<WebContentsViewGuest*>(GetWebContents()->GetView());
664 if (!web_contents()->GetRenderViewHost()->GetView()) { 681 if (!web_contents()->GetRenderViewHost()->GetView()) {
665 web_contents_view->CreateViewForWidget( 682 web_contents_view->CreateViewForWidget(
666 web_contents()->GetRenderViewHost(), true); 683 web_contents()->GetRenderViewHost(), true);
667 } 684 }
668 } 685 }
669 686
670 InitInternal(params, embedder_web_contents); 687 InitInternal(params, embedder_web_contents);
671 688
672 attached_ = true; 689 attached_ = true;
673 SendQueuedMessages(); 690 SendQueuedMessages();
674 691
675 delegate_->DidAttach(GetGuestProxyRoutingID()); 692 delegate_->DidAttach(GetGuestProxyRoutingID());
676 693
677 has_render_view_ = true; 694 if (!use_site_per_process) {
695 has_render_view_ = true;
678 696
679 // Enable input method for guest if it's enabled for the embedder. 697 // Enable input method for guest if it's enabled for the embedder.
680 if (static_cast<RenderViewHostImpl*>( 698 if (static_cast<RenderViewHostImpl*>(
681 owner_web_contents_->GetRenderViewHost())->input_method_active()) { 699 owner_web_contents_->GetRenderViewHost())->input_method_active()) {
682 RenderViewHostImpl* guest_rvh = static_cast<RenderViewHostImpl*>( 700 RenderViewHostImpl* guest_rvh = static_cast<RenderViewHostImpl*>(
683 GetWebContents()->GetRenderViewHost()); 701 GetWebContents()->GetRenderViewHost());
684 guest_rvh->SetInputMethodActive(true); 702 guest_rvh->SetInputMethodActive(true);
703 }
685 } 704 }
686 705
687 RecordAction(base::UserMetricsAction("BrowserPlugin.Guest.Attached")); 706 RecordAction(base::UserMetricsAction("BrowserPlugin.Guest.Attached"));
688 } 707 }
689 708
690 void BrowserPluginGuest::OnCompositorFrameSwappedACK( 709 void BrowserPluginGuest::OnCompositorFrameSwappedACK(
691 int browser_plugin_instance_id, 710 int browser_plugin_instance_id,
692 const FrameHostMsg_CompositorFrameSwappedACK_Params& params) { 711 const FrameHostMsg_CompositorFrameSwappedACK_Params& params) {
693 RenderWidgetHostImpl::SendSwapCompositorFrameAck(params.producing_route_id, 712 RenderWidgetHostImpl::SendSwapCompositorFrameAck(params.producing_route_id,
694 params.output_surface_id, 713 params.output_surface_id,
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
928 void BrowserPluginGuest::OnImeCompositionRangeChanged( 947 void BrowserPluginGuest::OnImeCompositionRangeChanged(
929 const gfx::Range& range, 948 const gfx::Range& range,
930 const std::vector<gfx::Rect>& character_bounds) { 949 const std::vector<gfx::Rect>& character_bounds) {
931 static_cast<RenderWidgetHostViewBase*>( 950 static_cast<RenderWidgetHostViewBase*>(
932 web_contents()->GetRenderWidgetHostView())->ImeCompositionRangeChanged( 951 web_contents()->GetRenderWidgetHostView())->ImeCompositionRangeChanged(
933 range, character_bounds); 952 range, character_bounds);
934 } 953 }
935 #endif 954 #endif
936 955
937 } // namespace content 956 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698