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 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
184 | 184 |
185 bool SiteInstanceImpl::HasSite() const { | 185 bool SiteInstanceImpl::HasSite() const { |
186 return has_site_; | 186 return has_site_; |
187 } | 187 } |
188 | 188 |
189 bool SiteInstanceImpl::HasRelatedSiteInstance(const GURL& url) { | 189 bool SiteInstanceImpl::HasRelatedSiteInstance(const GURL& url) { |
190 return browsing_instance_->HasSiteInstance(url); | 190 return browsing_instance_->HasSiteInstance(url); |
191 } | 191 } |
192 | 192 |
193 SiteInstance* SiteInstanceImpl::GetRelatedSiteInstance(const GURL& url) { | 193 SiteInstance* SiteInstanceImpl::GetRelatedSiteInstance(const GURL& url) { |
194 return browsing_instance_->GetSiteInstanceForURL(url); | 194 SiteInstance* result = browsing_instance_->GetSiteInstanceForURL(url); |
195 if (render_process_host_factory_) | |
196 result->SetRenderProcessHostFactoryForTesting(render_process_host_factory_); | |
Jeffrey Yasskin
2013/04/08 16:30:48
I got a "calling functions intended only for testi
jam
2013/04/08 16:54:53
ah, since there's a call path in a non-test file,
Paweł Hajdan Jr.
2013/04/08 20:03:51
By the way, calling Set, a mutating method in a me
Jeffrey Yasskin
2013/04/08 22:09:38
What? The Set() is on the newly-constructed result
Jeffrey Yasskin
2013/04/08 22:09:38
Well, I could put back the changes to browsing_ins
Paweł Hajdan Jr.
2013/04/08 22:17:38
Oops, this makes more sense. Please ignore my earl
Jeffrey Yasskin
2013/04/08 22:38:02
Done, although I can switch to directly modifying
| |
197 return result; | |
195 } | 198 } |
196 | 199 |
197 bool SiteInstanceImpl::IsRelatedSiteInstance(const SiteInstance* instance) { | 200 bool SiteInstanceImpl::IsRelatedSiteInstance(const SiteInstance* instance) { |
198 return browsing_instance_ == | 201 return browsing_instance_ == |
199 static_cast<const SiteInstanceImpl*>(instance)->browsing_instance_; | 202 static_cast<const SiteInstanceImpl*>(instance)->browsing_instance_; |
200 } | 203 } |
201 | 204 |
202 bool SiteInstanceImpl::HasWrongProcessForURL(const GURL& url) { | 205 bool SiteInstanceImpl::HasWrongProcessForURL(const GURL& url) { |
203 // Having no process isn't a problem, since we'll assign it correctly. | 206 // Having no process isn't a problem, since we'll assign it correctly. |
204 // Note that HasProcess() may return true if process_ is null, in | 207 // Note that HasProcess() may return true if process_ is null, in |
(...skipping 12 matching lines...) Expand all Loading... | |
217 // process is not (or vice versa), make sure we notice and fix it. | 220 // process is not (or vice versa), make sure we notice and fix it. |
218 GURL site_url = GetSiteForURL(browsing_instance_->browser_context(), url); | 221 GURL site_url = GetSiteForURL(browsing_instance_->browser_context(), url); |
219 return !RenderProcessHostImpl::IsSuitableHost( | 222 return !RenderProcessHostImpl::IsSuitableHost( |
220 GetProcess(), browsing_instance_->browser_context(), site_url); | 223 GetProcess(), browsing_instance_->browser_context(), site_url); |
221 } | 224 } |
222 | 225 |
223 BrowserContext* SiteInstanceImpl::GetBrowserContext() const { | 226 BrowserContext* SiteInstanceImpl::GetBrowserContext() const { |
224 return browsing_instance_->browser_context(); | 227 return browsing_instance_->browser_context(); |
225 } | 228 } |
226 | 229 |
230 void SiteInstanceImpl::SetRenderProcessHostFactoryForTesting( | |
231 const RenderProcessHostFactory* rph_factory) { | |
232 render_process_host_factory_ = rph_factory; | |
233 } | |
234 | |
227 /*static*/ | 235 /*static*/ |
228 SiteInstance* SiteInstance::Create(BrowserContext* browser_context) { | 236 SiteInstance* SiteInstance::Create(BrowserContext* browser_context) { |
229 return new SiteInstanceImpl(new BrowsingInstance(browser_context)); | 237 return new SiteInstanceImpl(new BrowsingInstance(browser_context)); |
230 } | 238 } |
231 | 239 |
232 /*static*/ | 240 /*static*/ |
233 SiteInstance* SiteInstance::CreateForURL(BrowserContext* browser_context, | 241 SiteInstance* SiteInstance::CreateForURL(BrowserContext* browser_context, |
234 const GURL& url) { | 242 const GURL& url) { |
235 // This BrowsingInstance may be deleted if it returns an existing | 243 // This BrowsingInstance may be deleted if it returns an existing |
236 // SiteInstance. | 244 // SiteInstance. |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
330 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 338 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
331 if (command_line.HasSwitch(switches::kEnableStrictSiteIsolation) || | 339 if (command_line.HasSwitch(switches::kEnableStrictSiteIsolation) || |
332 command_line.HasSwitch(switches::kSitePerProcess)) { | 340 command_line.HasSwitch(switches::kSitePerProcess)) { |
333 ChildProcessSecurityPolicyImpl* policy = | 341 ChildProcessSecurityPolicyImpl* policy = |
334 ChildProcessSecurityPolicyImpl::GetInstance(); | 342 ChildProcessSecurityPolicyImpl::GetInstance(); |
335 policy->LockToOrigin(process_->GetID(), site_); | 343 policy->LockToOrigin(process_->GetID(), site_); |
336 } | 344 } |
337 } | 345 } |
338 | 346 |
339 } // namespace content | 347 } // namespace content |
OLD | NEW |