| 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 "content/browser/browsing_instance.h" | 7 #include "content/browser/browsing_instance.h" |
| 8 #include "content/browser/child_process_security_policy_impl.h" | 8 #include "content/browser/child_process_security_policy_impl.h" |
| 9 #include "content/browser/frame_host/debug_urls.h" | 9 #include "content/browser/frame_host/debug_urls.h" |
| 10 #include "content/browser/frame_host/frame_tree_node.h" | 10 #include "content/browser/frame_host/frame_tree_node.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 | 21 |
| 22 const RenderProcessHostFactory* | 22 const RenderProcessHostFactory* |
| 23 SiteInstanceImpl::g_render_process_host_factory_ = NULL; | 23 SiteInstanceImpl::g_render_process_host_factory_ = NULL; |
| 24 int32_t SiteInstanceImpl::next_site_instance_id_ = 1; | 24 int32_t SiteInstanceImpl::next_site_instance_id_ = 1; |
| 25 | 25 |
| 26 SiteInstanceImpl::SiteInstanceImpl(BrowsingInstance* browsing_instance) | 26 SiteInstanceImpl::SiteInstanceImpl(BrowsingInstance* browsing_instance) |
| 27 : id_(next_site_instance_id_++), | 27 : id_(next_site_instance_id_++), |
| 28 active_frame_count_(0), | 28 active_frame_count_(0), |
| 29 browsing_instance_(browsing_instance), | 29 browsing_instance_(browsing_instance), |
| 30 process_(NULL), | 30 process_(NULL), |
| 31 has_site_(false) { | 31 has_site_(false), |
| 32 is_for_doghouse_(false) { |
| 32 DCHECK(browsing_instance); | 33 DCHECK(browsing_instance); |
| 33 } | 34 } |
| 34 | 35 |
| 35 SiteInstanceImpl::~SiteInstanceImpl() { | 36 SiteInstanceImpl::~SiteInstanceImpl() { |
| 36 GetContentClient()->browser()->SiteInstanceDeleting(this); | 37 GetContentClient()->browser()->SiteInstanceDeleting(this); |
| 37 | 38 |
| 38 if (process_) | 39 if (process_) |
| 39 process_->RemoveObserver(this); | 40 process_->RemoveObserver(this); |
| 40 | 41 |
| 41 // Now that no one is referencing us, we can safely remove ourselves from | 42 // Now that no one is referencing us, we can safely remove ourselves from |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 | 184 |
| 184 bool SiteInstanceImpl::IsRelatedSiteInstance(const SiteInstance* instance) { | 185 bool SiteInstanceImpl::IsRelatedSiteInstance(const SiteInstance* instance) { |
| 185 return browsing_instance_.get() == static_cast<const SiteInstanceImpl*>( | 186 return browsing_instance_.get() == static_cast<const SiteInstanceImpl*>( |
| 186 instance)->browsing_instance_.get(); | 187 instance)->browsing_instance_.get(); |
| 187 } | 188 } |
| 188 | 189 |
| 189 size_t SiteInstanceImpl::GetRelatedActiveContentsCount() { | 190 size_t SiteInstanceImpl::GetRelatedActiveContentsCount() { |
| 190 return browsing_instance_->active_contents_count(); | 191 return browsing_instance_->active_contents_count(); |
| 191 } | 192 } |
| 192 | 193 |
| 194 void SiteInstanceImpl::SetForDoghouse(bool value) { |
| 195 is_for_doghouse_ = value; |
| 196 } |
| 197 |
| 198 bool SiteInstanceImpl::IsForDoghouse() const { |
| 199 return is_for_doghouse_; |
| 200 } |
| 201 |
| 193 bool SiteInstanceImpl::HasWrongProcessForURL(const GURL& url) { | 202 bool SiteInstanceImpl::HasWrongProcessForURL(const GURL& url) { |
| 194 // Having no process isn't a problem, since we'll assign it correctly. | 203 // Having no process isn't a problem, since we'll assign it correctly. |
| 195 // Note that HasProcess() may return true if process_ is null, in | 204 // Note that HasProcess() may return true if process_ is null, in |
| 196 // process-per-site cases where there's an existing process available. | 205 // process-per-site cases where there's an existing process available. |
| 197 // We want to use such a process in the IsSuitableHost check, so we | 206 // We want to use such a process in the IsSuitableHost check, so we |
| 198 // may end up assigning process_ in the GetProcess() call below. | 207 // may end up assigning process_ in the GetProcess() call below. |
| 199 if (!HasProcess()) | 208 if (!HasProcess()) |
| 200 return false; | 209 return false; |
| 201 | 210 |
| 202 // If the URL to navigate to can be associated with any site instance, | 211 // If the URL to navigate to can be associated with any site instance, |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 422 browsing_instance_->browser_context(), site_)) | 431 browsing_instance_->browser_context(), site_)) |
| 423 return; | 432 return; |
| 424 | 433 |
| 425 ChildProcessSecurityPolicyImpl* policy = | 434 ChildProcessSecurityPolicyImpl* policy = |
| 426 ChildProcessSecurityPolicyImpl::GetInstance(); | 435 ChildProcessSecurityPolicyImpl::GetInstance(); |
| 427 policy->LockToOrigin(process_->GetID(), site_); | 436 policy->LockToOrigin(process_->GetID(), site_); |
| 428 } | 437 } |
| 429 } | 438 } |
| 430 | 439 |
| 431 } // namespace content | 440 } // namespace content |
| OLD | NEW |