Chromium Code Reviews| 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 3fba36e8cbca8b3012abe9216e3aa0a64521c5aa..e916cac9f5292618f0f34b094799f3e4ba0b1c33 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" |
| @@ -60,6 +62,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); |
| @@ -74,43 +77,54 @@ 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)) { |
| + // We use the src URL passed by the webview tag to allow us to group |
| + // same site iframes in the same process when running in --site-per-process |
|
Charlie Reis
2013/01/17 19:44:54
Can you change this comment a bit? We're not tech
nasko
2013/01/17 22:19:13
Done.
|
| + // model. |
| + 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( |
| @@ -153,7 +167,6 @@ void BrowserPluginEmbedder::CreateGuest( |
| CreateSwappedOutRenderView(web_contents()->GetSiteInstance()); |
| render_view_host_->Send(new BrowserPluginMsg_GuestContentWindowReady( |
| render_view_host_->GetRoutingID(), instance_id, guest_routing_id)); |
| - |
|
Charlie Reis
2013/01/17 19:44:54
No need for this change.
nasko
2013/01/17 22:19:13
Done.
|
| guest->Initialize(params, guest_web_contents->GetRenderViewHost()); |
| } |