Commit d4c4ca38 authored by Alex Moshchuk's avatar Alex Moshchuk Committed by Commit Bot

Remove RenderprocessHost param from ShouldLockToOrigin.

This param was only being used to check for --single-process mode,
which can be done via a static function on RenderProcessHost instead.
This CL will simplify some of the plumbing in a later CL for locking
hosted apps to an origin (https://crrev.com/c/959346).

Bug: 791796
Change-Id: I0ef1e8f3a4a00f80e74f1109a092b795f3c63722
Reviewed-on: https://chromium-review.googlesource.com/1176216Reviewed-by: default avatarŁukasz Anforowicz <lukasza@chromium.org>
Commit-Queue: Alex Moshchuk <alexmos@chromium.org>
Cr-Commit-Position: refs/heads/master@{#583376}
parent 1adf0357
......@@ -3546,8 +3546,8 @@ bool RenderProcessHostImpl::IsSuitableHost(RenderProcessHost* host,
case CheckOriginLockResult::HAS_WRONG_LOCK:
return false;
case CheckOriginLockResult::NO_LOCK:
if (!host->IsUnused() && SiteInstanceImpl::ShouldLockToOrigin(
browser_context, host, site_url)) {
if (!host->IsUnused() &&
SiteInstanceImpl::ShouldLockToOrigin(browser_context, site_url)) {
// If this process has been used to host any other content, it cannot
// be reused if the destination site requires a dedicated process and
// should use a process locked to just that site.
......
......@@ -540,11 +540,10 @@ bool SiteInstanceImpl::DoesSiteRequireDedicatedProcess(
// static
bool SiteInstanceImpl::ShouldLockToOrigin(BrowserContext* browser_context,
RenderProcessHost* host,
GURL site_url) {
// Don't lock to origin in --single-process mode, since this mode puts
// cross-site pages into the same process.
if (host->run_renderer_in_process())
if (RenderProcessHost::run_renderer_in_process())
return false;
if (!DoesSiteRequireDedicatedProcess(browser_context, site_url))
......@@ -607,7 +606,7 @@ void SiteInstanceImpl::LockToOriginIfNeeded() {
ChildProcessSecurityPolicyImpl* policy =
ChildProcessSecurityPolicyImpl::GetInstance();
auto lock_state = policy->CheckOriginLock(process_->GetID(), site_);
if (ShouldLockToOrigin(GetBrowserContext(), process_, site_)) {
if (ShouldLockToOrigin(GetBrowserContext(), site_)) {
// Sanity check that this won't try to assign an origin lock to a <webview>
// process, which can't be locked.
CHECK(!process_->IsForGuestsOnly());
......
......@@ -203,18 +203,17 @@ class CONTENT_EXPORT SiteInstanceImpl final : public SiteInstance,
static bool DoesSiteRequireDedicatedProcess(BrowserContext* browser_context,
const GURL& url);
// Returns true if a process |host| can be locked to a site |site_url|.
// Returning true here also implies that |site_url| requires a dedicated
// process. However, the converse does not hold: this might still return
// false for certain special cases where an origin lock can't be applied even
// when |site_url| requires a dedicated process (e.g., with
// Returns true if a process can be locked to a site |site_url|. Returning
// true here also implies that |site_url| requires a dedicated process.
// However, the converse does not hold: this might still return false for
// certain special cases where an origin lock can't be applied even when
// |site_url| requires a dedicated process (e.g., with
// --site-per-process). Examples of those cases include <webview> guests,
// WebUI, single-process mode, or extensions where a process is currently
// allowed to be reused for different extensions. Most of these special
// cases should eventually be removed, and this function should become
// equivalent to DoesSiteRequireDedicatedProcess().
static bool ShouldLockToOrigin(BrowserContext* browser_context,
RenderProcessHost* host,
GURL site_url);
private:
......
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