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

Unified Diff: content/browser/web_contents/web_contents_impl.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, 8 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/web_contents/web_contents_impl.cc
diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc
index 59791b51e94f69bfbe162b375242ea576cb65ebc..89ebcc2abbef4b4fe7f8ae32786b75dc2d563803 100644
--- a/content/browser/web_contents/web_contents_impl.cc
+++ b/content/browser/web_contents/web_contents_impl.cc
@@ -286,6 +286,14 @@ WebContentsImpl::ColorChooserInfo::ColorChooserInfo(int render_process_id,
WebContentsImpl::ColorChooserInfo::~ColorChooserInfo() {
}
+// WebContentsImpl::WebContentsNode --------------------------------------------
+WebContentsImpl::WebContentsNode::WebContentsNode()
+ : parent_web_contents_(NULL) {
Charlie Reis 2015/04/30 23:06:46 nullptr
lazyboy 2015/05/05 07:28:14 Done.
+}
+
+WebContentsImpl::WebContentsNode::~WebContentsNode() {
Charlie Reis 2015/04/30 23:06:47 Is there any way for us to enforce that a child We
lazyboy 2015/05/05 07:28:14 Should we keep vector<WebContents*> children_ insi
+}
+
// WebContentsImpl -------------------------------------------------------------
WebContentsImpl::WebContentsImpl(BrowserContext* browser_context,
@@ -619,6 +627,42 @@ WebContentsDelegate* WebContentsImpl::GetDelegate() {
return delegate_;
}
+int WebContentsImpl::AttachLocalFrameToGuest(WebContents* embedder_web_contents,
+ int embedder_frame_process_id,
+ int embedder_frame_routing_id) {
+ DCHECK(base::CommandLine::ForCurrentProcess()->HasSwitch(
Charlie Reis 2015/04/30 23:06:46 CHECK
lazyboy 2015/05/05 07:28:14 Done.
+ switches::kSitePerProcess));
+ // 1. Create a link to our parent WebContents.
+ node_.set_parent_web_contents(
+ static_cast<WebContentsImpl*>(embedder_web_contents));
+
+ RenderFrameHostImpl* embedder_frame =
+ RenderFrameHostImpl::FromID(embedder_frame_process_id,
+ embedder_frame_routing_id);
+ DCHECK(embedder_frame);
+
+ // 2. Create a swapped out RVH and a proxy in our render manager, pointing
+ // to embedder site instance. The swapped out RVH will be used to send
Charlie Reis 2015/04/30 23:06:47 the embedder's SiteInstance.
lazyboy 2015/05/05 07:28:14 Done.
+ // postMessage to guest.
Charlie Reis 2015/04/30 23:06:46 Alex pointed out that postMessage doesn't go throu
lazyboy 2015/05/05 07:28:14 I've changed the CL to use <iframe>.contentWindow
+ int swapped_out_render_view_routing_id = MSG_ROUTING_NONE;
+ int proxy_to_embedder_routing_id = MSG_ROUTING_NONE;
+ GetRenderManager()->CreateEmbedderProxy(
+ embedder_frame->GetSiteInstance(),
+ &swapped_out_render_view_routing_id,
+ &proxy_to_embedder_routing_id);
+
+ // 3. Swap the embedder's initial frame pointing to guest with the proxy
Charlie Reis 2015/04/30 23:06:47 initial frame for the guest
lazyboy 2015/05/05 07:28:14 Done.
+ // we've created above.
+ // The proxy has a CPFC and it uses the swapped out RV as its RenderWidget,
+ // which gives us input and rendering.
+ embedder_frame->frame_tree_node()->render_manager()
+ ->ReplaceWithGuestProxy(proxy_to_embedder_routing_id);
+
+ // The swapped out render view routing ID will be used to send
+ // postMessage.
+ return swapped_out_render_view_routing_id;
Charlie Reis 2015/04/30 23:06:46 Is this needed, given that postMessage should go t
lazyboy 2015/05/05 07:28:14 Not anymore. this function returns void now.
+}
+
void WebContentsImpl::SetDelegate(WebContentsDelegate* delegate) {
// TODO(cbentzel): remove this debugging code?
if (delegate == delegate_)
@@ -1204,7 +1248,9 @@ void WebContentsImpl::Init(const WebContents::CreateParams& params) {
WebContentsViewDelegate* delegate =
GetContentClient()->browser()->GetWebContentsViewDelegate(this);
- if (browser_plugin_guest_) {
+ if (browser_plugin_guest_ &&
+ !base::CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kSitePerProcess)) {
scoped_ptr<WebContentsView> platform_view(CreateWebContentsView(
this, delegate, &render_view_host_delegate_view_));
@@ -1507,6 +1553,8 @@ void WebContentsImpl::CreateNewWindow(
int main_frame_route_id,
const ViewHostMsg_CreateWindow_Params& params,
SessionStorageNamespace* session_storage_namespace) {
+ // TODO(lazyboy): CreateNewWindow doesn't work for <webview> yet.
+ DCHECK(0);
Charlie Reis 2015/04/30 23:06:47 This needs updating to work in non-site-per-proces
lazyboy 2015/05/05 07:28:14 This doesn't break until we use new window from <w
// We usually create the new window in the same BrowsingInstance (group of
// script-related windows), by passing in the current SiteInstance. However,
// if the opener is being suppressed (in a non-guest), we create a new
@@ -1728,7 +1776,9 @@ void WebContentsImpl::ShowCreatedWidget(int route_id,
RenderWidgetHostView* view = NULL;
BrowserPluginGuest* guest = GetBrowserPluginGuest();
- if (guest && guest->embedder_web_contents()) {
+ if (guest && guest->embedder_web_contents() &&
+ base::CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kSitePerProcess)) {
view = guest->embedder_web_contents()->GetRenderWidgetHostView();
} else {
view = GetRenderWidgetHostView();
@@ -4171,10 +4221,15 @@ bool WebContentsImpl::CreateRenderViewForRenderManager(
// until RenderWidgetHost is attached to RenderFrameHost. We need to special
// case this because RWH is still a base class of RenderViewHost, and child
// frame RWHVs are unique in that they do not have their own WebContents.
- if (!for_main_frame_navigation) {
+ bool is_guest_in_site_per_process = !!browser_plugin_guest_.get() &&
+ base::CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kSitePerProcess);
+ if (!for_main_frame_navigation || is_guest_in_site_per_process) {
Charlie Reis 2015/04/30 23:06:46 Sounds like you might not need this if you don't p
lazyboy 2015/05/05 07:28:14 Not passing CREATE_RF_FOR_MAIN_FRAME_NAVIGATION st
RenderWidgetHostViewChildFrame* rwh_view_child =
new RenderWidgetHostViewChildFrame(render_view_host);
rwh_view = rwh_view_child;
+ if (is_guest_in_site_per_process)
+ GetRenderManager()->UpdateGuestRWHView(rwh_view_child);
} else {
rwh_view = view_->CreateViewForWidget(render_view_host, false);
}
@@ -4313,6 +4368,14 @@ bool WebContentsImpl::IsHidden() {
return capturer_count_ == 0 && !should_normally_be_visible_;
}
+int64 WebContentsImpl::GetEmbedderFrameTreeNodeID() {
+ if (node_.parent_web_contents()) {
+ return node_.parent_web_contents()->GetFrameTree()->root()
+ ->frame_tree_node_id();
+ }
+ return -1;
+}
+
RenderFrameHostManager* WebContentsImpl::GetRenderManager() const {
return frame_tree_.root()->render_manager();
}
@@ -4323,6 +4386,7 @@ BrowserPluginGuest* WebContentsImpl::GetBrowserPluginGuest() const {
void WebContentsImpl::SetBrowserPluginGuest(BrowserPluginGuest* guest) {
CHECK(!browser_plugin_guest_);
+ CHECK(guest);
browser_plugin_guest_.reset(guest);
}

Powered by Google App Engine
This is Rietveld 408576698