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

Unified Diff: content/browser/loader/cross_site_resource_handler.cc

Issue 30323002: [DRAFT] Create RenderFrameHostManager. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 years, 1 month 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/loader/cross_site_resource_handler.cc
diff --git a/content/browser/loader/cross_site_resource_handler.cc b/content/browser/loader/cross_site_resource_handler.cc
index f6274bd0ca344c1338b6013ace48674f566ac140..e9bea980ad1e4dafd95a7780d53130d8a662b959 100644
--- a/content/browser/loader/cross_site_resource_handler.cc
+++ b/content/browser/loader/cross_site_resource_handler.cc
@@ -7,6 +7,7 @@
#include <string>
#include "base/bind.h"
+#include "base/command_line.h"
#include "base/logging.h"
#include "content/browser/cross_site_request_manager.h"
#include "content/browser/loader/resource_dispatcher_host_impl.h"
@@ -17,7 +18,9 @@
#include "content/public/browser/content_browser_client.h"
#include "content/public/browser/global_request_id.h"
#include "content/public/browser/resource_controller.h"
+#include "content/public/common/content_switches.h"
#include "content/public/common/resource_response.h"
+#include "content/public/common/url_constants.h"
#include "net/http/http_response_headers.h"
#include "net/url_request/url_request.h"
@@ -91,6 +94,26 @@ bool CrossSiteResourceHandler::OnResponseStarted(
bool should_transfer =
GetContentClient()->browser()->ShouldSwapProcessesForRedirect(
info->GetContext(), request()->original_url(), request()->url());
+
+ // When the --site-per-process flag is passed, we transfer processes for
+ // cross-site subframe navigations.
+ // TODO(creis): Skip this for chrome: pages for now, since they host cross
+ // site iframes and don't have referrers.
+ // TODO(creis): This doesn't work for hosted apps, due to passing NULL to
+ // IsSameWebSite. It should be possible to always send the navigation to the
+ // UI thread to make a policy decision, which could let us eliminate the
+ // renderer-side check in RenderViewImpl::decidePolicyForNavigation as well.
+ if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kSitePerProcess)) {
+ GURL referrer(request()->referrer());
+ if (info->GetResourceType() == ResourceType::SUB_FRAME &&
+ !request()->url().SchemeIs(chrome::kChromeUIScheme) &&
+ !SiteInstance::IsSameWebSite(NULL, request()->url(), referrer)) {
+ LOG(INFO) << "CSRH: Transferring for a cross-process subframe: " <<
+ request()->url();
+ should_transfer = true;
+ }
+ }
+
bool swap_needed = should_transfer ||
CrossSiteRequestManager::GetInstance()->
HasPendingCrossSiteRequest(info->GetChildID(), info->GetRouteID());

Powered by Google App Engine
This is Rietveld 408576698