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