diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2017-11-20 15:06:40 +0100 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2017-11-22 11:48:58 +0000 |
commit | daa093eea7c773db06799a13bd7e4e2e2a9f8f14 (patch) | |
tree | 96cc5e7b9194c1b29eab927730bfa419e7111c25 /chromium/content/browser/site_instance_impl.cc | |
parent | be59a35641616a4cf23c4a13fa0632624b021c1b (diff) | |
download | qtwebengine-chromium-daa093eea7c773db06799a13bd7e4e2e2a9f8f14.tar.gz |
BASELINE: Update Chromium to 63.0.3239.58
Change-Id: Ia93b322a00ba4dd4004f3bcf1254063ba90e1605
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'chromium/content/browser/site_instance_impl.cc')
-rw-r--r-- | chromium/content/browser/site_instance_impl.cc | 45 |
1 files changed, 31 insertions, 14 deletions
diff --git a/chromium/content/browser/site_instance_impl.cc b/chromium/content/browser/site_instance_impl.cc index f7bae497810..6be22050f5c 100644 --- a/chromium/content/browser/site_instance_impl.cc +++ b/chromium/content/browser/site_instance_impl.cc @@ -51,7 +51,7 @@ SiteInstanceImpl::~SiteInstanceImpl() { scoped_refptr<SiteInstanceImpl> SiteInstanceImpl::Create( BrowserContext* browser_context) { - return make_scoped_refptr( + return base::WrapRefCounted( new SiteInstanceImpl(new BrowsingInstance(browser_context))); } @@ -471,6 +471,18 @@ bool SiteInstanceImpl::ShouldLockToOrigin(BrowserContext* browser_context, return true; } +// static +bool SiteInstanceImpl::ShouldAssignSiteForURL(const GURL& url) { + // about:blank should not "use up" a new SiteInstance. The SiteInstance can + // still be used for a normal web site. + if (url == url::kAboutBlankURL) + return false; + + // The embedder will then have the opportunity to determine if the URL + // should "use up" the SiteInstance. + return GetContentClient()->browser()->ShouldAssignSiteForURL(url); +} + void SiteInstanceImpl::RenderProcessHostDestroyed(RenderProcessHost* host) { DCHECK_EQ(process_, host); process_->RemoveObserver(this); @@ -504,27 +516,22 @@ void SiteInstanceImpl::LockToOriginIfNeeded() { // We can get here either when we commit a URL into a SiteInstance that does // not yet have a site, or when we create a process for a SiteInstance with a // preassigned site. - bool was_unused = process_->IsUnused(); process_->SetIsUsed(); - // TODO(nick): When all sites are isolated, this operation provides strong - // protection. If only some sites are isolated, we need additional logic to - // prevent the non-isolated sites from requesting resources for isolated - // sites. https://crbug.com/509125 + ChildProcessSecurityPolicyImpl* policy = + ChildProcessSecurityPolicyImpl::GetInstance(); + auto lock_state = policy->CheckOriginLock(process_->GetID(), site_); if (ShouldLockToOrigin(GetBrowserContext(), process_, site_)) { - ChildProcessSecurityPolicyImpl* policy = - ChildProcessSecurityPolicyImpl::GetInstance(); - // Sanity check that this won't try to assign an origin lock to a <webview> // process, which can't be locked. CHECK(!process_->IsForGuestsOnly()); - auto lock_state = policy->CheckOriginLock(process_->GetID(), site_); switch (lock_state) { case ChildProcessSecurityPolicyImpl::CheckOriginLockResult::NO_LOCK: { - // TODO(alexmos): Turn this into a CHECK once https://crbug.com/738634 - // is fixed. - DCHECK(was_unused); + // TODO(nick): When all sites are isolated, this operation provides + // strong protection. If only some sites are isolated, we need + // additional logic to prevent the non-isolated sites from requesting + // resources for isolated sites. https://crbug.com/509125 policy->LockToOrigin(process_->GetID(), site_); break; } @@ -532,7 +539,9 @@ void SiteInstanceImpl::LockToOriginIfNeeded() { HAS_WRONG_LOCK: // We should never attempt to reassign a different origin lock to a // process. - CHECK(false); + CHECK(false) << "Trying to lock a process to " << site_ + << " but the process is already locked to " + << policy->GetOriginLock(process_->GetID()); break; case ChildProcessSecurityPolicyImpl::CheckOriginLockResult:: HAS_EQUAL_LOCK: @@ -542,6 +551,14 @@ void SiteInstanceImpl::LockToOriginIfNeeded() { default: NOTREACHED(); } + } else { + // If the site that we've just committed doesn't require a dedicated + // process, make sure we aren't putting it in a process for a site that + // does. + CHECK_EQ(lock_state, + ChildProcessSecurityPolicyImpl::CheckOriginLockResult::NO_LOCK) + << "Trying to commit non-isolated site " << site_ + << " in process locked to " << policy->GetOriginLock(process_->GetID()); } } |