Commit 0b49fa16 authored by creis's avatar creis Committed by Commit Bot

Disable cross-process navigations in --single-process.

This flag takes precedence over --site-per-process and other
site isolation modes.

BUG=688617
TEST=Cross-site subframes work with --single-process --site-per-process
CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:linux_site_isolation

Review-Url: https://codereview.chromium.org/2964033002
Cr-Commit-Position: refs/heads/master@{#485292}
parent 0fd5121f
......@@ -1039,30 +1039,10 @@ void RenderFrameHostManager::DeleteRenderFrameProxyHost(
}
bool RenderFrameHostManager::ShouldTransitionCrossSite() {
// The logic below is weaker than "are all sites isolated" -- it asks instead,
// "is any site isolated". That's appropriate here since we're just trying to
// figure out if we're in any kind of site isolated mode, and in which case,
// we ignore the kSingleProcess and kProcessPerTab settings.
//
// TODO(nick): Move all handling of kSingleProcess/kProcessPerTab into
// SiteIsolationPolicy so we have a consistent behavior around the interaction
// of the process model flags.
//
// TODO(creis, alexmos): This looks like it will break single-process and
// process-per-tab. See https://crbug.com/688617.
if (SiteIsolationPolicy::AreCrossProcessFramesPossible())
return true;
// False in the single-process mode, as it makes RVHs to accumulate
// in swapped_out_hosts_.
// True if we are using process-per-site-instance (default) or
// process-per-site (kProcessPerSite).
// TODO(nick): Move handling of kSingleProcess and kProcessPerTab into
// SiteIsolationPolicy.
// False in single-process mode, which does not support cross-process
// navigations or OOPIFs.
return !base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kSingleProcess) &&
!base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kProcessPerTab);
switches::kSingleProcess);
}
bool RenderFrameHostManager::ShouldSwapBrowsingInstancesForNavigation(
......
......@@ -560,8 +560,8 @@ class CONTENT_EXPORT RenderFrameHostManager
void DeleteRenderFrameProxyHost(SiteInstance* site_instance);
// Returns whether this tab should transition to a new renderer for
// cross-site URLs. Enabled unless we see the --process-per-tab command line
// switch. Can be overridden in unit tests.
// cross-site URLs. Enabled unless we see the --single-process command line
// switch.
bool ShouldTransitionCrossSite();
// Returns true if for the navigation from |current_effective_url| to
......
......@@ -4,6 +4,7 @@
#include "content/browser/site_instance_impl.h"
#include "base/command_line.h"
#include "base/macros.h"
#include "base/memory/ptr_util.h"
#include "content/browser/browsing_instance.h"
......@@ -16,6 +17,7 @@
#include "content/public/browser/content_browser_client.h"
#include "content/public/browser/render_process_host_factory.h"
#include "content/public/browser/web_ui_controller_factory.h"
#include "content/public/common/content_switches.h"
#include "content/public/common/url_constants.h"
#include "net/base/registry_controlled_domains/registry_controlled_domain.h"
......@@ -434,6 +436,12 @@ bool SiteInstanceImpl::DoesSiteRequireDedicatedProcess(
// static
bool SiteInstanceImpl::ShouldLockToOrigin(BrowserContext* browser_context,
GURL site_url) {
// Don't lock to origin in --single-process mode, since this mode puts
// cross-site pages into the same process.
if (base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kSingleProcess))
return false;
if (!DoesSiteRequireDedicatedProcess(browser_context, site_url))
return false;
......
......@@ -720,6 +720,9 @@ const char kProcessPerSite[] = "process-per-site";
// renderer process. We default to using a renderer process for each
// site instance (i.e., group of pages from the same registered domain with
// script connections to each other).
// TODO(creis): This flag is currently a no-op. We should refactor it to avoid
// "unnecessary" process swaps for cross-site navigations but still swap when
// needed for security (e.g., isolated origins).
const char kProcessPerTab[] = "process-per-tab";
// The value of this switch determines whether the process is started as a
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment