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

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

Issue 11772005: Implement a prototype to render cross-site iframes in a separate process from their parent. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge with ToT. Created 7 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | content/browser/child_process_security_policy_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_embedder.h" 5 #include "content/browser/browser_plugin/browser_plugin_embedder.h"
6 6
7 #include "base/command_line.h"
7 #include "base/stl_util.h" 8 #include "base/stl_util.h"
8 #include "content/browser/browser_plugin/browser_plugin_guest.h" 9 #include "content/browser/browser_plugin/browser_plugin_guest.h"
9 #include "content/browser/browser_plugin/browser_plugin_host_factory.h" 10 #include "content/browser/browser_plugin/browser_plugin_host_factory.h"
10 #include "content/browser/renderer_host/render_view_host_impl.h" 11 #include "content/browser/renderer_host/render_view_host_impl.h"
11 #include "content/browser/web_contents/web_contents_impl.h" 12 #include "content/browser/web_contents/web_contents_impl.h"
12 #include "content/common/browser_plugin_messages.h" 13 #include "content/common/browser_plugin_messages.h"
13 #include "content/common/gpu/gpu_messages.h" 14 #include "content/common/gpu/gpu_messages.h"
14 #include "content/public/browser/notification_details.h" 15 #include "content/public/browser/notification_details.h"
15 #include "content/public/browser/notification_service.h" 16 #include "content/public/browser/notification_service.h"
16 #include "content/public/browser/notification_source.h" 17 #include "content/public/browser/notification_source.h"
17 #include "content/public/browser/notification_types.h" 18 #include "content/public/browser/notification_types.h"
18 #include "content/public/browser/user_metrics.h" 19 #include "content/public/browser/user_metrics.h"
20 #include "content/public/common/content_switches.h"
19 #include "content/public/common/result_codes.h" 21 #include "content/public/common/result_codes.h"
20 #include "content/public/common/url_constants.h" 22 #include "content/public/common/url_constants.h"
21 #include "net/base/escape.h" 23 #include "net/base/escape.h"
22 24
23 namespace content { 25 namespace content {
24 26
25 // static 27 // static
26 BrowserPluginHostFactory* BrowserPluginEmbedder::factory_ = NULL; 28 BrowserPluginHostFactory* BrowserPluginEmbedder::factory_ = NULL;
27 29
28 BrowserPluginEmbedder::BrowserPluginEmbedder( 30 BrowserPluginEmbedder::BrowserPluginEmbedder(
(...skipping 25 matching lines...) Expand all
54 } 56 }
55 return new BrowserPluginEmbedder(web_contents, render_view_host); 57 return new BrowserPluginEmbedder(web_contents, render_view_host);
56 } 58 }
57 59
58 void BrowserPluginEmbedder::CreateGuest( 60 void BrowserPluginEmbedder::CreateGuest(
59 int instance_id, 61 int instance_id,
60 int routing_id, 62 int routing_id,
61 BrowserPluginGuest* guest_opener, 63 BrowserPluginGuest* guest_opener,
62 const BrowserPluginHostMsg_CreateGuest_Params& params) { 64 const BrowserPluginHostMsg_CreateGuest_Params& params) {
63 WebContentsImpl* guest_web_contents = NULL; 65 WebContentsImpl* guest_web_contents = NULL;
66 SiteInstance* guest_site_instance = NULL;
64 BrowserPluginGuest* guest = GetGuestByInstanceID(instance_id); 67 BrowserPluginGuest* guest = GetGuestByInstanceID(instance_id);
65 CHECK(!guest); 68 CHECK(!guest);
66 69
67 // Validate that the partition id coming from the renderer is valid UTF-8, 70 // Validate that the partition id coming from the renderer is valid UTF-8,
68 // since we depend on this in other parts of the code, such as FilePath 71 // since we depend on this in other parts of the code, such as FilePath
69 // creation. If the validation fails, treat it as a bad message and kill the 72 // creation. If the validation fails, treat it as a bad message and kill the
70 // renderer process. 73 // renderer process.
71 if (!IsStringUTF8(params.storage_partition_id)) { 74 if (!IsStringUTF8(params.storage_partition_id)) {
72 content::RecordAction(UserMetricsAction("BadMessageTerminate_BPE")); 75 content::RecordAction(UserMetricsAction("BadMessageTerminate_BPE"));
73 base::KillProcess(render_view_host_->GetProcess()->GetHandle(), 76 base::KillProcess(render_view_host_->GetProcess()->GetHandle(),
74 content::RESULT_CODE_KILLED_BAD_MESSAGE, false); 77 content::RESULT_CODE_KILLED_BAD_MESSAGE, false);
75 return; 78 return;
76 } 79 }
77 80
78 const std::string& host = 81 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
79 render_view_host_->GetSiteInstance()->GetSiteURL().host(); 82 if (command_line.HasSwitch(switches::kSitePerProcess)) {
80 std::string url_encoded_partition = net::EscapeQueryParamValue( 83 // When --site-per-process is specified, the behavior of BrowserPlugin
81 params.storage_partition_id, false); 84 // as <webview> is broken and we use it for rendering out-of-process
85 // iframes instead. We use the src URL sent by the renderer to find the
86 // right process in which to place this instance.
87 // Note: Since BrowserPlugin doesn't support cross-process navigation,
88 // the instance will stay in the initially assigned process, regardless
89 // of the site it is navigated to.
90 // TODO(nasko): Fix this, and such that cross-process navigations are
91 // supported.
92 guest_site_instance =
93 web_contents()->GetSiteInstance()->GetRelatedSiteInstance(
94 GURL(params.src));
95 } else {
96 const std::string& host =
97 render_view_host_->GetSiteInstance()->GetSiteURL().host();
98 std::string url_encoded_partition = net::EscapeQueryParamValue(
99 params.storage_partition_id, false);
82 100
83 SiteInstance* guest_site_instance = NULL; 101 if (guest_opener) {
84 if (guest_opener) { 102 guest_site_instance = guest_opener->GetWebContents()->GetSiteInstance();
85 guest_site_instance = guest_opener->GetWebContents()->GetSiteInstance(); 103 } else {
86 } else { 104 // The SiteInstance of a given webview tag is based on the fact that it's
87 // The SiteInstance of a given webview tag is based on the fact that it's a 105 // a guest process in addition to which platform application the tag
88 // guest process in addition to which platform application the tag belongs 106 // belongs to and what storage partition is in use, rather than the URL
89 // to and what storage partition is in use, rather than the URL that the tag 107 // that the tag is being navigated to.
90 // is being navigated to. 108 GURL guest_site(
91 GURL guest_site( 109 base::StringPrintf("%s://%s/%s?%s", chrome::kGuestScheme,
92 base::StringPrintf("%s://%s/%s?%s", chrome::kGuestScheme, 110 host.c_str(),
93 host.c_str(), params.persist_storage ? "persist" : "", 111 params.persist_storage ? "persist" : "",
94 url_encoded_partition.c_str())); 112 url_encoded_partition.c_str()));
95 113
96 // If we already have a webview tag in the same app using the same storage 114 // If we already have a webview tag in the same app using the same storage
97 // partition, we should use the same SiteInstance so the existing tag and 115 // partition, we should use the same SiteInstance so the existing tag and
98 // the new tag can script each other. 116 // the new tag can script each other.
99 for (ContainerInstanceMap::const_iterator it = 117 for (ContainerInstanceMap::const_iterator it =
100 guest_web_contents_by_instance_id_.begin(); 118 guest_web_contents_by_instance_id_.begin();
101 it != guest_web_contents_by_instance_id_.end(); ++it) { 119 it != guest_web_contents_by_instance_id_.end(); ++it) {
102 if (it->second->GetSiteInstance()->GetSiteURL() == guest_site) { 120 if (it->second->GetSiteInstance()->GetSiteURL() == guest_site) {
103 guest_site_instance = it->second->GetSiteInstance(); 121 guest_site_instance = it->second->GetSiteInstance();
104 break; 122 break;
123 }
124 }
125 if (!guest_site_instance) {
126 // Create the SiteInstance in a new BrowsingInstance, which will ensure
127 // that webview tags are also not allowed to send messages across
128 // different partitions.
129 guest_site_instance = SiteInstance::CreateForURL(
130 web_contents()->GetBrowserContext(), guest_site);
105 } 131 }
106 } 132 }
107 if (!guest_site_instance) {
108 // Create the SiteInstance in a new BrowsingInstance, which will ensure
109 // that webview tags are also not allowed to send messages across
110 // different partitions.
111 guest_site_instance = SiteInstance::CreateForURL(
112 web_contents()->GetBrowserContext(), guest_site);
113 }
114 } 133 }
134
115 WebContentsImpl* opener_web_contents = static_cast<WebContentsImpl*>( 135 WebContentsImpl* opener_web_contents = static_cast<WebContentsImpl*>(
116 guest_opener ? guest_opener->GetWebContents() : NULL); 136 guest_opener ? guest_opener->GetWebContents() : NULL);
117 guest_web_contents = WebContentsImpl::CreateGuest( 137 guest_web_contents = WebContentsImpl::CreateGuest(
118 web_contents()->GetBrowserContext(), 138 web_contents()->GetBrowserContext(),
119 guest_site_instance, 139 guest_site_instance,
120 routing_id, 140 routing_id,
121 opener_web_contents, 141 opener_web_contents,
122 instance_id, 142 instance_id,
123 params); 143 params);
124 144
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 uint32 sync_point) { 365 uint32 sync_point) {
346 AcceleratedSurfaceMsg_BufferPresented_Params ack_params; 366 AcceleratedSurfaceMsg_BufferPresented_Params ack_params;
347 ack_params.mailbox_name = mailbox_name; 367 ack_params.mailbox_name = mailbox_name;
348 ack_params.sync_point = sync_point; 368 ack_params.sync_point = sync_point;
349 RenderWidgetHostImpl::AcknowledgeBufferPresent(route_id, 369 RenderWidgetHostImpl::AcknowledgeBufferPresent(route_id,
350 gpu_host_id, 370 gpu_host_id,
351 ack_params); 371 ack_params);
352 } 372 }
353 373
354 } // namespace content 374 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/browser/child_process_security_policy_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698