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/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_impl.h" | 9 #include "content/browser/child_process_security_policy_impl.h" |
10 #include "content/browser/renderer_host/render_process_host_impl.h" | 10 #include "content/browser/renderer_host/render_process_host_impl.h" |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 } | 135 } |
136 | 136 |
137 bool SiteInstanceImpl::HasRelatedSiteInstance(const GURL& url) { | 137 bool SiteInstanceImpl::HasRelatedSiteInstance(const GURL& url) { |
138 return browsing_instance_->HasSiteInstance(url); | 138 return browsing_instance_->HasSiteInstance(url); |
139 } | 139 } |
140 | 140 |
141 SiteInstance* SiteInstanceImpl::GetRelatedSiteInstance(const GURL& url) { | 141 SiteInstance* SiteInstanceImpl::GetRelatedSiteInstance(const GURL& url) { |
142 return browsing_instance_->GetSiteInstanceForURL(url); | 142 return browsing_instance_->GetSiteInstanceForURL(url); |
143 } | 143 } |
144 | 144 |
| 145 bool SiteInstanceImpl::IsRelatedSiteInstance(const SiteInstance* instance) { |
| 146 return browsing_instance_ == |
| 147 static_cast<const SiteInstanceImpl*>(instance)->browsing_instance_; |
| 148 } |
| 149 |
145 bool SiteInstanceImpl::HasWrongProcessForURL(const GURL& url) const { | 150 bool SiteInstanceImpl::HasWrongProcessForURL(const GURL& url) const { |
146 // Having no process isn't a problem, since we'll assign it correctly. | 151 // Having no process isn't a problem, since we'll assign it correctly. |
147 if (!HasProcess()) | 152 if (!HasProcess()) |
148 return false; | 153 return false; |
149 | 154 |
150 // If the URL to navigate to can be associated with any site instance, | 155 // If the URL to navigate to can be associated with any site instance, |
151 // we want to keep it in the same process. | 156 // we want to keep it in the same process. |
152 if (IsURLSameAsAnySiteInstance(url)) | 157 if (IsURLSameAsAnySiteInstance(url)) |
153 return false; | 158 return false; |
154 | 159 |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 | 268 |
264 void SiteInstanceImpl::LockToOrigin() { | 269 void SiteInstanceImpl::LockToOrigin() { |
265 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 270 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
266 if (command_line.HasSwitch(switches::kEnableStrictSiteIsolation)) { | 271 if (command_line.HasSwitch(switches::kEnableStrictSiteIsolation)) { |
267 ChildProcessSecurityPolicyImpl* policy = | 272 ChildProcessSecurityPolicyImpl* policy = |
268 ChildProcessSecurityPolicyImpl::GetInstance(); | 273 ChildProcessSecurityPolicyImpl::GetInstance(); |
269 policy->LockToOrigin(process_->GetID(), site_); | 274 policy->LockToOrigin(process_->GetID(), site_); |
270 } | 275 } |
271 } | 276 } |
272 | 277 |
OLD | NEW |