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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | content/browser/child_process_security_policy_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/browser_plugin/browser_plugin_embedder.cc
diff --git a/content/browser/browser_plugin/browser_plugin_embedder.cc b/content/browser/browser_plugin/browser_plugin_embedder.cc
index 779ee94006d37b0eb9d41e6195fba84dae8d2226..4ffaa3d7b383bdb45bb84d562e2a17ae8b070f4e 100644
--- a/content/browser/browser_plugin/browser_plugin_embedder.cc
+++ b/content/browser/browser_plugin/browser_plugin_embedder.cc
@@ -4,6 +4,7 @@
#include "content/browser/browser_plugin/browser_plugin_embedder.h"
+#include "base/command_line.h"
#include "base/stl_util.h"
#include "content/browser/browser_plugin/browser_plugin_guest.h"
#include "content/browser/browser_plugin/browser_plugin_host_factory.h"
@@ -16,6 +17,7 @@
#include "content/public/browser/notification_source.h"
#include "content/public/browser/notification_types.h"
#include "content/public/browser/user_metrics.h"
+#include "content/public/common/content_switches.h"
#include "content/public/common/result_codes.h"
#include "content/public/common/url_constants.h"
#include "net/base/escape.h"
@@ -61,6 +63,7 @@ void BrowserPluginEmbedder::CreateGuest(
BrowserPluginGuest* guest_opener,
const BrowserPluginHostMsg_CreateGuest_Params& params) {
WebContentsImpl* guest_web_contents = NULL;
+ SiteInstance* guest_site_instance = NULL;
BrowserPluginGuest* guest = GetGuestByInstanceID(instance_id);
CHECK(!guest);
@@ -75,43 +78,60 @@ void BrowserPluginEmbedder::CreateGuest(
return;
}
- const std::string& host =
- render_view_host_->GetSiteInstance()->GetSiteURL().host();
- std::string url_encoded_partition = net::EscapeQueryParamValue(
- params.storage_partition_id, false);
-
- SiteInstance* guest_site_instance = NULL;
- if (guest_opener) {
- guest_site_instance = guest_opener->GetWebContents()->GetSiteInstance();
+ const CommandLine& command_line = *CommandLine::ForCurrentProcess();
+ if (command_line.HasSwitch(switches::kSitePerProcess)) {
+ // When --site-per-process is specified, the behavior of BrowserPlugin
+ // as <webview> is broken and we use it for rendering out-of-process
+ // iframes instead. We use the src URL sent by the renderer to find the
+ // right process in which to place this instance.
+ // Note: Since BrowserPlugin doesn't support cross-process navigation,
+ // the instance will stay in the initially assigned process, regardless
+ // of the site it is navigated to.
+ // TODO(nasko): Fix this, and such that cross-process navigations are
+ // supported.
+ guest_site_instance =
+ web_contents()->GetSiteInstance()->GetRelatedSiteInstance(
+ GURL(params.src));
} else {
- // The SiteInstance of a given webview tag is based on the fact that it's a
- // guest process in addition to which platform application the tag belongs
- // to and what storage partition is in use, rather than the URL that the tag
- // is being navigated to.
- GURL guest_site(
- base::StringPrintf("%s://%s/%s?%s", chrome::kGuestScheme,
- host.c_str(), params.persist_storage ? "persist" : "",
- url_encoded_partition.c_str()));
-
- // If we already have a webview tag in the same app using the same storage
- // partition, we should use the same SiteInstance so the existing tag and
- // the new tag can script each other.
- for (ContainerInstanceMap::const_iterator it =
- guest_web_contents_by_instance_id_.begin();
- it != guest_web_contents_by_instance_id_.end(); ++it) {
- if (it->second->GetSiteInstance()->GetSiteURL() == guest_site) {
- guest_site_instance = it->second->GetSiteInstance();
- break;
+ const std::string& host =
+ render_view_host_->GetSiteInstance()->GetSiteURL().host();
+ std::string url_encoded_partition = net::EscapeQueryParamValue(
+ params.storage_partition_id, false);
+
+ if (guest_opener) {
+ guest_site_instance = guest_opener->GetWebContents()->GetSiteInstance();
+ } else {
+ // The SiteInstance of a given webview tag is based on the fact that it's
+ // a guest process in addition to which platform application the tag
+ // belongs to and what storage partition is in use, rather than the URL
+ // that the tag is being navigated to.
+ GURL guest_site(
+ base::StringPrintf("%s://%s/%s?%s", chrome::kGuestScheme,
+ host.c_str(),
+ params.persist_storage ? "persist" : "",
+ url_encoded_partition.c_str()));
+
+ // If we already have a webview tag in the same app using the same storage
+ // partition, we should use the same SiteInstance so the existing tag and
+ // the new tag can script each other.
+ for (ContainerInstanceMap::const_iterator it =
+ guest_web_contents_by_instance_id_.begin();
+ it != guest_web_contents_by_instance_id_.end(); ++it) {
+ if (it->second->GetSiteInstance()->GetSiteURL() == guest_site) {
+ guest_site_instance = it->second->GetSiteInstance();
+ break;
+ }
+ }
+ if (!guest_site_instance) {
+ // Create the SiteInstance in a new BrowsingInstance, which will ensure
+ // that webview tags are also not allowed to send messages across
+ // different partitions.
+ guest_site_instance = SiteInstance::CreateForURL(
+ web_contents()->GetBrowserContext(), guest_site);
}
- }
- if (!guest_site_instance) {
- // Create the SiteInstance in a new BrowsingInstance, which will ensure
- // that webview tags are also not allowed to send messages across
- // different partitions.
- guest_site_instance = SiteInstance::CreateForURL(
- web_contents()->GetBrowserContext(), guest_site);
}
}
+
WebContentsImpl* opener_web_contents = static_cast<WebContentsImpl*>(
guest_opener ? guest_opener->GetWebContents() : NULL);
guest_web_contents = WebContentsImpl::CreateGuest(
« 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