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 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
134 | 134 |
135 void SiteInstanceImpl::SetSite(const GURL& url) { | 135 void SiteInstanceImpl::SetSite(const GURL& url) { |
136 TRACE_EVENT2("navigation", "SiteInstanceImpl::SetSite", | 136 TRACE_EVENT2("navigation", "SiteInstanceImpl::SetSite", |
137 "site id", id_, "url", url.possibly_invalid_spec()); | 137 "site id", id_, "url", url.possibly_invalid_spec()); |
138 // A SiteInstance's site should not change. | 138 // A SiteInstance's site should not change. |
139 // TODO(creis): When following links or script navigations, we can currently | 139 // TODO(creis): When following links or script navigations, we can currently |
140 // render pages from other sites in this SiteInstance. This will eventually | 140 // render pages from other sites in this SiteInstance. This will eventually |
141 // be fixed, but until then, we should still not set the site of a | 141 // be fixed, but until then, we should still not set the site of a |
142 // SiteInstance more than once. | 142 // SiteInstance more than once. |
143 DCHECK(!has_site_); | 143 DCHECK(!has_site_); |
144 DCHECK(!browsing_instance_->HasSiteInstance(url)); | |
Charlie Reis
2014/11/26 01:06:40
I think this can fail, right? See the comment in
carlosk
2014/11/27 11:02:44
Yes, you are right. I had read that note but later
| |
144 | 145 |
145 // Remember that this SiteInstance has been used to load a URL, even if the | 146 // Remember that this SiteInstance has been used to load a URL, even if the |
146 // URL is invalid. | 147 // URL is invalid. |
147 has_site_ = true; | 148 has_site_ = true; |
148 BrowserContext* browser_context = browsing_instance_->browser_context(); | 149 BrowserContext* browser_context = browsing_instance_->browser_context(); |
149 site_ = GetSiteForURL(browser_context, url); | 150 site_ = GetSiteForURL(browser_context, url); |
150 | 151 |
151 // Now that we have a site, register it with the BrowsingInstance. This | 152 // Now that we have a site, register it with the BrowsingInstance. This |
152 // ensures that we won't create another SiteInstance for this site within | 153 // ensures that we won't create another SiteInstance for this site within |
153 // the same BrowsingInstance, because all same-site pages within a | 154 // the same BrowsingInstance, because all same-site pages within a |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
345 *base::CommandLine::ForCurrentProcess(); | 346 *base::CommandLine::ForCurrentProcess(); |
346 if (command_line.HasSwitch(switches::kEnableStrictSiteIsolation) || | 347 if (command_line.HasSwitch(switches::kEnableStrictSiteIsolation) || |
347 command_line.HasSwitch(switches::kSitePerProcess)) { | 348 command_line.HasSwitch(switches::kSitePerProcess)) { |
348 ChildProcessSecurityPolicyImpl* policy = | 349 ChildProcessSecurityPolicyImpl* policy = |
349 ChildProcessSecurityPolicyImpl::GetInstance(); | 350 ChildProcessSecurityPolicyImpl::GetInstance(); |
350 policy->LockToOrigin(process_->GetID(), site_); | 351 policy->LockToOrigin(process_->GetID(), site_); |
351 } | 352 } |
352 } | 353 } |
353 | 354 |
354 } // namespace content | 355 } // namespace content |
OLD | NEW |