Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(206)

Side by Side Diff: chrome/browser/metrics/variations/variations_http_header_provider.cc

Issue 23064011: Consolidate scheme checks into an easy GURL method (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/google/google_util.cc ('k') | chrome/browser/net/predictor.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
OLDNEW
« no previous file with comments | « chrome/browser/google/google_util.cc ('k') | chrome/browser/net/predictor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698