OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "components/variations/net/variations_http_headers.h" | 5 #include "components/variations/net/variations_http_headers.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
(...skipping 26 matching lines...) Expand all Loading... |
37 }; | 37 }; |
38 | 38 |
39 const char kChromeUMAEnabled[] = "X-Chrome-UMA-Enabled"; | 39 const char kChromeUMAEnabled[] = "X-Chrome-UMA-Enabled"; |
40 const char kClientData[] = "X-Client-Data"; | 40 const char kClientData[] = "X-Client-Data"; |
41 | 41 |
42 } // namespace | 42 } // namespace |
43 | 43 |
44 void AppendVariationHeaders(const GURL& url, | 44 void AppendVariationHeaders(const GURL& url, |
45 bool incognito, | 45 bool incognito, |
46 bool uma_enabled, | 46 bool uma_enabled, |
47 bool is_signed_in, | |
48 net::HttpRequestHeaders* headers) { | 47 net::HttpRequestHeaders* headers) { |
49 // Note the criteria for attaching client experiment headers: | 48 // Note the criteria for attaching client experiment headers: |
50 // 1. We only transmit to Google owned domains which can evaluate experiments. | 49 // 1. We only transmit to Google owned domains which can evaluate experiments. |
51 // 1a. These include hosts which have a standard postfix such as: | 50 // 1a. These include hosts which have a standard postfix such as: |
52 // *.doubleclick.net or *.googlesyndication.com or | 51 // *.doubleclick.net or *.googlesyndication.com or |
53 // exactly www.googleadservices.com or | 52 // exactly www.googleadservices.com or |
54 // international TLD domains *.google.<TLD> or *.youtube.<TLD>. | 53 // international TLD domains *.google.<TLD> or *.youtube.<TLD>. |
55 // 2. Only transmit for non-Incognito profiles. | 54 // 2. Only transmit for non-Incognito profiles. |
56 // 3. For the X-Chrome-UMA-Enabled bit, only set it if UMA is in fact enabled | 55 // 3. For the X-Chrome-UMA-Enabled bit, only set it if UMA is in fact enabled |
57 // for this install of Chrome. | 56 // for this install of Chrome. |
58 // 4. For the X-Client-Data header, only include non-empty variation IDs. | 57 // 4. For the X-Client-Data header, only include non-empty variation IDs. |
59 if (incognito || !internal::ShouldAppendVariationHeaders(url)) | 58 if (incognito || !internal::ShouldAppendVariationHeaders(url)) |
60 return; | 59 return; |
61 | 60 |
62 if (uma_enabled) | 61 if (uma_enabled) |
63 headers->SetHeaderIfMissing(kChromeUMAEnabled, "1"); | 62 headers->SetHeaderIfMissing(kChromeUMAEnabled, "1"); |
64 | 63 |
65 const std::string variation_ids_header = | 64 const std::string variation_ids_header = |
66 VariationsHttpHeaderProvider::GetInstance()->GetClientDataHeader( | 65 VariationsHttpHeaderProvider::GetInstance()->GetClientDataHeader(); |
67 is_signed_in); | |
68 if (!variation_ids_header.empty()) { | 66 if (!variation_ids_header.empty()) { |
69 // Note that prior to M33 this header was named X-Chrome-Variations. | 67 // Note that prior to M33 this header was named X-Chrome-Variations. |
70 headers->SetHeaderIfMissing(kClientData, variation_ids_header); | 68 headers->SetHeaderIfMissing(kClientData, variation_ids_header); |
71 } | 69 } |
72 } | 70 } |
73 | 71 |
74 std::set<std::string> GetVariationHeaderNames() { | 72 std::set<std::string> GetVariationHeaderNames() { |
75 std::set<std::string> headers; | 73 std::set<std::string> headers; |
76 headers.insert(kChromeUMAEnabled); | 74 headers.insert(kChromeUMAEnabled); |
77 headers.insert(kClientData); | 75 headers.insert(kClientData); |
(...skipping 25 matching lines...) Expand all Loading... |
103 return true; | 101 return true; |
104 } | 102 } |
105 | 103 |
106 return google_util::IsYoutubeDomainUrl(url, google_util::ALLOW_SUBDOMAIN, | 104 return google_util::IsYoutubeDomainUrl(url, google_util::ALLOW_SUBDOMAIN, |
107 google_util::ALLOW_NON_STANDARD_PORTS); | 105 google_util::ALLOW_NON_STANDARD_PORTS); |
108 } | 106 } |
109 | 107 |
110 } // namespace internal | 108 } // namespace internal |
111 | 109 |
112 } // namespace variations | 110 } // namespace variations |
OLD | NEW |