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 "chrome/browser/metrics/variations/variations_http_header_provider.h" | 5 #include "chrome/browser/metrics/variations/variations_http_header_provider.h" |
6 | 6 |
7 #include "base/base64.h" | 7 #include "base/base64.h" |
8 #include "base/memory/singleton.h" | 8 #include "base/memory/singleton.h" |
9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 } | 149 } |
150 | 150 |
151 // static | 151 // static |
152 bool VariationsHttpHeaderProvider::ShouldAppendHeaders(const GURL& url) { | 152 bool VariationsHttpHeaderProvider::ShouldAppendHeaders(const GURL& url) { |
153 if (google_util::IsGoogleDomainUrl(url, google_util::ALLOW_SUBDOMAIN, | 153 if (google_util::IsGoogleDomainUrl(url, google_util::ALLOW_SUBDOMAIN, |
154 google_util::ALLOW_NON_STANDARD_PORTS)) { | 154 google_util::ALLOW_NON_STANDARD_PORTS)) { |
155 return true; | 155 return true; |
156 } | 156 } |
157 | 157 |
158 // The below mirrors logic in IsGoogleDomainUrl(), but for youtube.<TLD>. | 158 // The below mirrors logic in IsGoogleDomainUrl(), but for youtube.<TLD>. |
159 if (!url.is_valid() || !(url.SchemeIs("http") || url.SchemeIs("https"))) | 159 if (!url.is_valid() || !url.SchemeIsHTTPOrHTTPS()) |
160 return false; | 160 return false; |
161 | 161 |
162 const std::string host = url.host(); | 162 const std::string host = url.host(); |
163 const size_t tld_length = net::registry_controlled_domains::GetRegistryLength( | 163 const size_t tld_length = net::registry_controlled_domains::GetRegistryLength( |
164 host, | 164 host, |
165 net::registry_controlled_domains::EXCLUDE_UNKNOWN_REGISTRIES, | 165 net::registry_controlled_domains::EXCLUDE_UNKNOWN_REGISTRIES, |
166 net::registry_controlled_domains::EXCLUDE_PRIVATE_REGISTRIES); | 166 net::registry_controlled_domains::EXCLUDE_PRIVATE_REGISTRIES); |
167 if ((tld_length == 0) || (tld_length == std::string::npos)) | 167 if ((tld_length == 0) || (tld_length == std::string::npos)) |
168 return false; | 168 return false; |
169 | 169 |
170 const std::string host_minus_tld(host, 0, host.length() - tld_length); | 170 const std::string host_minus_tld(host, 0, host.length() - tld_length); |
171 return LowerCaseEqualsASCII(host_minus_tld, "youtube.") || | 171 return LowerCaseEqualsASCII(host_minus_tld, "youtube.") || |
172 EndsWith(host_minus_tld, ".youtube.", false); | 172 EndsWith(host_minus_tld, ".youtube.", false); |
173 } | 173 } |
174 | 174 |
175 } // namespace chrome_variations | 175 } // namespace chrome_variations |
OLD | NEW |