Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/browser/site_instance_impl.h" | 5 #include "content/browser/site_instance_impl.h" |
| 6 | 6 |
| 7 #include "base/macros.h" | 7 #include "base/macros.h" |
| 8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
| 9 #include "content/browser/browsing_instance.h" | 9 #include "content/browser/browsing_instance.h" |
| 10 #include "content/browser/child_process_security_policy_impl.h" | 10 #include "content/browser/child_process_security_policy_impl.h" |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 204 // We want to use such a process in the IsSuitableHost check, so we | 204 // We want to use such a process in the IsSuitableHost check, so we |
| 205 // may end up assigning process_ in the GetProcess() call below. | 205 // may end up assigning process_ in the GetProcess() call below. |
| 206 if (!HasProcess()) | 206 if (!HasProcess()) |
| 207 return false; | 207 return false; |
| 208 | 208 |
| 209 // If the URL to navigate to can be associated with any site instance, | 209 // If the URL to navigate to can be associated with any site instance, |
| 210 // we want to keep it in the same process. | 210 // we want to keep it in the same process. |
| 211 if (IsRendererDebugURL(url)) | 211 if (IsRendererDebugURL(url)) |
| 212 return false; | 212 return false; |
| 213 | 213 |
| 214 // Any process can host an about:blank URL. | |
| 215 if (url == url::kAboutBlankURL) | |
|
alexmos
2017/06/12 17:35:07
Several tests (like DumpAccessibilityTreeTest.Acce
Charlie Reis
2017/06/12 23:08:17
This makes me a bit nervous. In other places, we'
alexmos
2017/06/14 22:39:05
This is a bit tricky. Just to clarify, my intent
Charlie Reis
2017/06/17 23:13:53
Interesting points. I think you're right that we
alexmos
2017/06/19 20:03:58
Comment added - please let me know if it's helpful
Charlie Reis
2017/06/28 00:08:37
Thanks-- that works!
| |
| 216 return false; | |
| 217 | |
| 214 // If the site URL is an extension (e.g., for hosted apps or WebUI) but the | 218 // If the site URL is an extension (e.g., for hosted apps or WebUI) but the |
| 215 // process is not (or vice versa), make sure we notice and fix it. | 219 // process is not (or vice versa), make sure we notice and fix it. |
| 216 GURL site_url = GetSiteForURL(browsing_instance_->browser_context(), url); | 220 GURL site_url = GetSiteForURL(browsing_instance_->browser_context(), url); |
| 217 return !RenderProcessHostImpl::IsSuitableHost( | 221 return !RenderProcessHostImpl::IsSuitableHost( |
| 218 GetProcess(), browsing_instance_->browser_context(), site_url); | 222 GetProcess(), browsing_instance_->browser_context(), site_url); |
| 219 } | 223 } |
| 220 | 224 |
| 221 scoped_refptr<SiteInstanceImpl> | 225 scoped_refptr<SiteInstanceImpl> |
| 222 SiteInstanceImpl::GetDefaultSubframeSiteInstance() { | 226 SiteInstanceImpl::GetDefaultSubframeSiteInstance() { |
| 223 return browsing_instance_->GetDefaultSubframeSiteInstance(); | 227 return browsing_instance_->GetDefaultSubframeSiteInstance(); |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 447 // must give the embedder a chance to exempt some sites to avoid process | 451 // must give the embedder a chance to exempt some sites to avoid process |
| 448 // kills. | 452 // kills. |
| 449 if (!GetContentClient()->browser()->ShouldLockToOrigin( | 453 if (!GetContentClient()->browser()->ShouldLockToOrigin( |
| 450 browsing_instance_->browser_context(), site_)) | 454 browsing_instance_->browser_context(), site_)) |
| 451 return; | 455 return; |
| 452 | 456 |
| 453 ChildProcessSecurityPolicyImpl* policy = | 457 ChildProcessSecurityPolicyImpl* policy = |
| 454 ChildProcessSecurityPolicyImpl::GetInstance(); | 458 ChildProcessSecurityPolicyImpl::GetInstance(); |
| 455 policy->LockToOrigin(process_->GetID(), site_); | 459 policy->LockToOrigin(process_->GetID(), site_); |
| 456 } | 460 } |
| 461 | |
| 462 // From now on, this process should be considered "tainted" for future | |
| 463 // process reuse decisions: | |
| 464 // (1) If |site_| required a dedicated process, this SiteInstance's process | |
| 465 // can only host URLs for the same site. | |
| 466 // (2) Even if |site_| does not require a dedicated process, this | |
| 467 // SiteInstance's process still cannot be reused to host other sites | |
| 468 // requiring dedicated sites in the future. | |
| 469 // We can get here either when we commit a URL into a SiteInstance that does | |
| 470 // not yet have a site, or when we create a process for a SiteInstance with a | |
| 471 // predetermined site. | |
| 472 process_->UnsetCanBecomeDedicatedProcess(); | |
|
Charlie Reis
2017/06/12 23:08:17
I found it confusing that this was inside "LockToO
alexmos
2017/06/14 22:39:05
Great questions, and I agree with your concerns.
alexmos
2017/06/15 16:40:54
Hmm, the trybots show that this wasn't as straight
alexmos
2017/06/15 17:27:58
I've just uploaded the fix (PS8), which is essenti
| |
| 457 } | 473 } |
| 458 | 474 |
| 459 } // namespace content | 475 } // namespace content |
| OLD | NEW |