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/frame_host/debug_urls.h" | 10 #include "content/browser/frame_host/debug_urls.h" |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
175 | 175 |
176 SiteInstance* SiteInstanceImpl::GetRelatedSiteInstance(const GURL& url) { | 176 SiteInstance* SiteInstanceImpl::GetRelatedSiteInstance(const GURL& url) { |
177 return browsing_instance_->GetSiteInstanceForURL(url); | 177 return browsing_instance_->GetSiteInstanceForURL(url); |
178 } | 178 } |
179 | 179 |
180 bool SiteInstanceImpl::IsRelatedSiteInstance(const SiteInstance* instance) { | 180 bool SiteInstanceImpl::IsRelatedSiteInstance(const SiteInstance* instance) { |
181 return browsing_instance_.get() == static_cast<const SiteInstanceImpl*>( | 181 return browsing_instance_.get() == static_cast<const SiteInstanceImpl*>( |
182 instance)->browsing_instance_.get(); | 182 instance)->browsing_instance_.get(); |
183 } | 183 } |
184 | 184 |
185 size_t SiteInstanceImpl::GetRelatedActiveContentsCount() const { | |
186 return browsing_instance_->active_contents_count(); | |
187 } | |
188 | |
185 bool SiteInstanceImpl::HasWrongProcessForURL(const GURL& url) { | 189 bool SiteInstanceImpl::HasWrongProcessForURL(const GURL& url) { |
186 // Having no process isn't a problem, since we'll assign it correctly. | 190 // Having no process isn't a problem, since we'll assign it correctly. |
187 // Note that HasProcess() may return true if process_ is null, in | 191 // Note that HasProcess() may return true if process_ is null, in |
188 // process-per-site cases where there's an existing process available. | 192 // process-per-site cases where there's an existing process available. |
189 // We want to use such a process in the IsSuitableHost check, so we | 193 // We want to use such a process in the IsSuitableHost check, so we |
190 // may end up assigning process_ in the GetProcess() call below. | 194 // may end up assigning process_ in the GetProcess() call below. |
191 if (!HasProcess()) | 195 if (!HasProcess()) |
192 return false; | 196 return false; |
193 | 197 |
194 // If the URL to navigate to can be associated with any site instance, | 198 // If the URL to navigate to can be associated with any site instance, |
195 // we want to keep it in the same process. | 199 // we want to keep it in the same process. |
196 if (IsRendererDebugURL(url)) | 200 if (IsRendererDebugURL(url)) |
197 return false; | 201 return false; |
198 | 202 |
199 // If the site URL is an extension (e.g., for hosted apps or WebUI) but the | 203 // If the site URL is an extension (e.g., for hosted apps or WebUI) but the |
200 // process is not (or vice versa), make sure we notice and fix it. | 204 // process is not (or vice versa), make sure we notice and fix it. |
201 GURL site_url = GetSiteForURL(browsing_instance_->browser_context(), url); | 205 GURL site_url = GetSiteForURL(browsing_instance_->browser_context(), url); |
202 return !RenderProcessHostImpl::IsSuitableHost( | 206 return !RenderProcessHostImpl::IsSuitableHost( |
203 GetProcess(), browsing_instance_->browser_context(), site_url); | 207 GetProcess(), browsing_instance_->browser_context(), site_url); |
204 } | 208 } |
205 | 209 |
210 void SiteInstanceImpl::IncrementRelatedActiveContentsCount() { | |
211 browsing_instance_->increment_active_contents_count(); | |
Charlie Reis
2014/04/29 17:31:08
These are one-liners that could be inlined, right?
davidben
2014/04/29 21:31:40
That would require BrowsingInstance to be included
| |
212 } | |
213 | |
214 void SiteInstanceImpl::DecrementRelatedActiveContentsCount() { | |
215 browsing_instance_->decrement_active_contents_count(); | |
216 } | |
217 | |
206 void SiteInstanceImpl::set_render_process_host_factory( | 218 void SiteInstanceImpl::set_render_process_host_factory( |
207 const RenderProcessHostFactory* rph_factory) { | 219 const RenderProcessHostFactory* rph_factory) { |
208 g_render_process_host_factory_ = rph_factory; | 220 g_render_process_host_factory_ = rph_factory; |
209 } | 221 } |
210 | 222 |
211 BrowserContext* SiteInstanceImpl::GetBrowserContext() const { | 223 BrowserContext* SiteInstanceImpl::GetBrowserContext() const { |
212 return browsing_instance_->browser_context(); | 224 return browsing_instance_->browser_context(); |
213 } | 225 } |
214 | 226 |
215 /*static*/ | 227 /*static*/ |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
320 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 332 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
321 if (command_line.HasSwitch(switches::kEnableStrictSiteIsolation) || | 333 if (command_line.HasSwitch(switches::kEnableStrictSiteIsolation) || |
322 command_line.HasSwitch(switches::kSitePerProcess)) { | 334 command_line.HasSwitch(switches::kSitePerProcess)) { |
323 ChildProcessSecurityPolicyImpl* policy = | 335 ChildProcessSecurityPolicyImpl* policy = |
324 ChildProcessSecurityPolicyImpl::GetInstance(); | 336 ChildProcessSecurityPolicyImpl::GetInstance(); |
325 policy->LockToOrigin(process_->GetID(), site_); | 337 policy->LockToOrigin(process_->GetID(), site_); |
326 } | 338 } |
327 } | 339 } |
328 | 340 |
329 } // namespace content | 341 } // namespace content |
OLD | NEW |