| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "chrome/browser/site_instance.h" | 5 #include "chrome/browser/site_instance.h" |
| 6 | 6 |
| 7 #include "net/base/registry_controlled_domain.h" | 7 #include "net/base/registry_controlled_domain.h" |
| 8 | 8 |
| 9 SiteInstance::~SiteInstance() { | 9 SiteInstance::~SiteInstance() { |
| 10 // Now that no one is referencing us, we can safely remove ourselves from | 10 // Now that no one is referencing us, we can safely remove ourselves from |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 SiteInstance* SiteInstance::CreateSiteInstance(Profile* profile) { | 74 SiteInstance* SiteInstance::CreateSiteInstance(Profile* profile) { |
| 75 return new SiteInstance(new BrowsingInstance(profile)); | 75 return new SiteInstance(new BrowsingInstance(profile)); |
| 76 } | 76 } |
| 77 | 77 |
| 78 /*static*/ | 78 /*static*/ |
| 79 GURL SiteInstance::GetSiteForURL(const GURL& url) { | 79 GURL SiteInstance::GetSiteForURL(const GURL& url) { |
| 80 // URLs with no host should have an empty site. | 80 // URLs with no host should have an empty site. |
| 81 GURL site; | 81 GURL site; |
| 82 | 82 |
| 83 // TODO(creis): For many protocols, we should just treat the scheme as the | 83 // TODO(creis): For many protocols, we should just treat the scheme as the |
| 84 // site, since there is no host. e.g., file:, about:, chrome-resource: | 84 // site, since there is no host. e.g., file:, about:, chrome: |
| 85 | 85 |
| 86 // If the url has a host, then determine the site. | 86 // If the url has a host, then determine the site. |
| 87 if (url.has_host()) { | 87 if (url.has_host()) { |
| 88 // Only keep the scheme and registered domain as given by GetOrigin. This | 88 // Only keep the scheme and registered domain as given by GetOrigin. This |
| 89 // may also include a port, which we need to drop. | 89 // may also include a port, which we need to drop. |
| 90 site = url.GetOrigin(); | 90 site = url.GetOrigin(); |
| 91 | 91 |
| 92 // Remove port, if any. | 92 // Remove port, if any. |
| 93 if (site.has_port()) { | 93 if (site.has_port()) { |
| 94 GURL::Replacements rep; | 94 GURL::Replacements rep; |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 } | 136 } |
| 137 | 137 |
| 138 // If the schemes differ, they aren't part of the same site. | 138 // If the schemes differ, they aren't part of the same site. |
| 139 if (url1.scheme() != url2.scheme()) { | 139 if (url1.scheme() != url2.scheme()) { |
| 140 return false; | 140 return false; |
| 141 } | 141 } |
| 142 | 142 |
| 143 return net::RegistryControlledDomainService::SameDomainOrHost(url1, url2); | 143 return net::RegistryControlledDomainService::SameDomainOrHost(url1, url2); |
| 144 } | 144 } |
| 145 | 145 |
| OLD | NEW |