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