| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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.h" | 5 #include "content/browser/site_instance.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "content/browser/browsing_instance.h" | 8 #include "content/browser/browsing_instance.h" |
| 9 #include "content/browser/child_process_security_policy.h" | 9 #include "content/browser/child_process_security_policy.h" |
| 10 #include "content/browser/renderer_host/render_process_host_impl.h" | 10 #include "content/browser/renderer_host/render_process_host_impl.h" |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 | 122 |
| 123 SiteInstance* SiteInstance::GetRelatedSiteInstance(const GURL& url) { | 123 SiteInstance* SiteInstance::GetRelatedSiteInstance(const GURL& url) { |
| 124 return browsing_instance_->GetSiteInstanceForURL(url); | 124 return browsing_instance_->GetSiteInstanceForURL(url); |
| 125 } | 125 } |
| 126 | 126 |
| 127 bool SiteInstance::HasWrongProcessForURL(const GURL& url) const { | 127 bool SiteInstance::HasWrongProcessForURL(const GURL& url) const { |
| 128 // Having no process isn't a problem, since we'll assign it correctly. | 128 // Having no process isn't a problem, since we'll assign it correctly. |
| 129 if (!HasProcess()) | 129 if (!HasProcess()) |
| 130 return false; | 130 return false; |
| 131 | 131 |
| 132 // If the URL to navigate to can be associated with any site instance, |
| 133 // we want to keep it in the same process. |
| 134 if (IsURLSameAsAnySiteInstance(url)) |
| 135 return false; |
| 136 |
| 132 // If the site URL is an extension (e.g., for hosted apps or WebUI) but the | 137 // If the site URL is an extension (e.g., for hosted apps or WebUI) but the |
| 133 // process is not (or vice versa), make sure we notice and fix it. | 138 // process is not (or vice versa), make sure we notice and fix it. |
| 134 GURL site_url = GetSiteForURL(browsing_instance_->browser_context(), url); | 139 GURL site_url = GetSiteForURL(browsing_instance_->browser_context(), url); |
| 135 return !RenderProcessHostImpl::IsSuitableHost( | 140 return !RenderProcessHostImpl::IsSuitableHost( |
| 136 process_, browsing_instance_->browser_context(), site_url); | 141 process_, browsing_instance_->browser_context(), site_url); |
| 137 } | 142 } |
| 138 | 143 |
| 139 /*static*/ | 144 /*static*/ |
| 140 SiteInstance* SiteInstance::CreateSiteInstance( | 145 SiteInstance* SiteInstance::CreateSiteInstance( |
| 141 content::BrowserContext* browser_context) { | 146 content::BrowserContext* browser_context) { |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 | 240 |
| 236 void SiteInstance::LockToOrigin() { | 241 void SiteInstance::LockToOrigin() { |
| 237 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 242 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 238 if (command_line.HasSwitch(switches::kEnableStrictSiteIsolation)) { | 243 if (command_line.HasSwitch(switches::kEnableStrictSiteIsolation)) { |
| 239 ChildProcessSecurityPolicy* policy = | 244 ChildProcessSecurityPolicy* policy = |
| 240 ChildProcessSecurityPolicy::GetInstance(); | 245 ChildProcessSecurityPolicy::GetInstance(); |
| 241 policy->LockToOrigin(process_->GetID(), site_); | 246 policy->LockToOrigin(process_->GetID(), site_); |
| 242 } | 247 } |
| 243 } | 248 } |
| 244 | 249 |
| OLD | NEW |