| 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.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 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 if (IsURLSameAsAnySiteInstance(url)) | 134 if (IsURLSameAsAnySiteInstance(url)) |
| 135 return false; | 135 return false; |
| 136 | 136 |
| 137 // 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 |
| 138 // 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. |
| 139 GURL site_url = GetSiteForURL(browsing_instance_->browser_context(), url); | 139 GURL site_url = GetSiteForURL(browsing_instance_->browser_context(), url); |
| 140 return !RenderProcessHostImpl::IsSuitableHost( | 140 return !RenderProcessHostImpl::IsSuitableHost( |
| 141 process_, browsing_instance_->browser_context(), site_url); | 141 process_, browsing_instance_->browser_context(), site_url); |
| 142 } | 142 } |
| 143 | 143 |
| 144 content::BrowserContext* SiteInstance::GetBrowserContext() const { |
| 145 return browsing_instance_->browser_context(); |
| 146 } |
| 147 |
| 144 /*static*/ | 148 /*static*/ |
| 145 SiteInstance* SiteInstance::CreateSiteInstance( | 149 SiteInstance* SiteInstance::CreateSiteInstance( |
| 146 content::BrowserContext* browser_context) { | 150 content::BrowserContext* browser_context) { |
| 147 return new SiteInstance(new BrowsingInstance(browser_context)); | 151 return new SiteInstance(new BrowsingInstance(browser_context)); |
| 148 } | 152 } |
| 149 | 153 |
| 150 /*static*/ | 154 /*static*/ |
| 151 SiteInstance* SiteInstance::CreateSiteInstanceForURL( | 155 SiteInstance* SiteInstance::CreateSiteInstanceForURL( |
| 152 content::BrowserContext* browser_context, const GURL& url) { | 156 content::BrowserContext* browser_context, const GURL& url) { |
| 153 // This BrowsingInstance may be deleted if it returns an existing | 157 // This BrowsingInstance may be deleted if it returns an existing |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 | 244 |
| 241 void SiteInstance::LockToOrigin() { | 245 void SiteInstance::LockToOrigin() { |
| 242 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 246 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 243 if (command_line.HasSwitch(switches::kEnableStrictSiteIsolation)) { | 247 if (command_line.HasSwitch(switches::kEnableStrictSiteIsolation)) { |
| 244 ChildProcessSecurityPolicy* policy = | 248 ChildProcessSecurityPolicy* policy = |
| 245 ChildProcessSecurityPolicy::GetInstance(); | 249 ChildProcessSecurityPolicy::GetInstance(); |
| 246 policy->LockToOrigin(process_->GetID(), site_); | 250 policy->LockToOrigin(process_->GetID(), site_); |
| 247 } | 251 } |
| 248 } | 252 } |
| 249 | 253 |
| OLD | NEW |