Index: chrome/browser/metrics/variations/variations_http_header_provider.cc |
diff --git a/chrome/browser/metrics/variations/variations_http_header_provider.cc b/chrome/browser/metrics/variations/variations_http_header_provider.cc |
index 90fde20a0df46a7ae25e8f91559fb7d89f735aa0..2ea1cc2d8e0c7ec8c17645bc1b74787b97646822 100644 |
--- a/chrome/browser/metrics/variations/variations_http_header_provider.cc |
+++ b/chrome/browser/metrics/variations/variations_http_header_provider.cc |
@@ -20,6 +20,24 @@ |
namespace chrome_variations { |
+namespace { |
+ |
+const char* kSuffixesToSetHeadersFor[] = { |
+ "android.com", |
+ "doubleclick.com", |
+ "doubleclick.net", |
+ "ggpht.com", |
+ "googleadservices.com", |
+ "googleapis.com", |
+ "googlesyndication.com", |
+ "googleusercontent.com", |
+ "googlevideo.com", |
+ "gstatic.com", |
+ "ytimg.com", |
+}; |
+ |
+} // namespace |
+ |
VariationsHttpHeaderProvider* VariationsHttpHeaderProvider::GetInstance() { |
return Singleton<VariationsHttpHeaderProvider>::get(); |
} |
@@ -95,6 +113,9 @@ bool VariationsHttpHeaderProvider::SetDefaultVariationIds( |
VariationsHttpHeaderProvider::VariationsHttpHeaderProvider() |
: variation_ids_cache_initialized_(false) { |
+ for (size_t i = 0; i < arraysize(kSuffixesToSetHeadersFor); ++i) { |
+ suffixes_to_set_headers_for_.insert(kSuffixesToSetHeadersFor[i]); |
+ } |
} |
VariationsHttpHeaderProvider::~VariationsHttpHeaderProvider() { |
@@ -216,7 +237,6 @@ void VariationsHttpHeaderProvider::UpdateVariationIDsHeaderValue() { |
variation_ids_header_ = hashed; |
} |
-// static |
bool VariationsHttpHeaderProvider::ShouldAppendHeaders(const GURL& url) { |
if (google_util::IsGoogleDomainUrl(url, google_util::ALLOW_SUBDOMAIN, |
google_util::ALLOW_NON_STANDARD_PORTS)) { |
@@ -229,10 +249,14 @@ bool VariationsHttpHeaderProvider::ShouldAppendHeaders(const GURL& url) { |
// Some domains don't have international TLD extensions, so testing for them |
// is very straight forward. |
const std::string host = url.host(); |
- if (EndsWith(host, ".doubleclick.net", false) || |
- EndsWith(host, ".googlesyndication.com", false) || |
- LowerCaseEqualsASCII(host, "www.googleadservices.com")) { |
- return true; |
+ size_t suffix_start = host.find_last_of(".", host.length(), 2); |
Alexei Svitkine (slow)
2014/05/30 20:36:12
Remove unnecessary last arg. Same below.
|
+ if (suffix_start != std::string::npos && suffix_start > 0) { |
+ suffix_start = host.find_last_of(".", suffix_start - 1, 2); |
+ if (suffix_start != std::string::npos) { |
+ std::string suffix = StringToLowerASCII(host.substr(suffix_start + 1)); |
+ if (ContainsKey(suffixes_to_set_headers_for_, suffix)) |
+ return true; |
+ } |
} |
// The below mirrors logic in IsGoogleDomainUrl(), but for youtube.<TLD>. |