| 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 "chrome/browser/google/google_util.h" | 10 #include "chrome/browser/google/google_util.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 // Note the criteria for attaching Chrome experiment headers: | 31 // Note the criteria for attaching Chrome experiment headers: |
| 32 // 1. We only transmit to *.google.<TLD> domains. NOTE that this use of | 32 // 1. We only transmit to *.google.<TLD> domains. NOTE that this use of |
| 33 // google_util helpers to check this does not guarantee that the URL is | 33 // google_util helpers to check this does not guarantee that the URL is |
| 34 // Google-owned, only that it is of the form *.google.<TLD>. In the future | 34 // Google-owned, only that it is of the form *.google.<TLD>. In the future |
| 35 // we may choose to reinforce this check. | 35 // we may choose to reinforce this check. |
| 36 // 2. Only transmit for non-Incognito profiles. | 36 // 2. Only transmit for non-Incognito profiles. |
| 37 // 3. For the X-Chrome-UMA-Enabled bit, only set it if UMA is in fact enabled | 37 // 3. For the X-Chrome-UMA-Enabled bit, only set it if UMA is in fact enabled |
| 38 // for this install of Chrome. | 38 // for this install of Chrome. |
| 39 // 4. For the X-Chrome-Variations, only include non-empty variation IDs. | 39 // 4. For the X-Chrome-Variations, only include non-empty variation IDs. |
| 40 if (incognito || | 40 if (incognito || |
| 41 !google_util::IsGoogleDomainUrl(url.spec(), | 41 !google_util::IsGoogleDomainUrl(url, google_util::ALLOW_SUBDOMAIN, |
| 42 google_util::ALLOW_SUBDOMAIN, | |
| 43 google_util::ALLOW_NON_STANDARD_PORTS)) { | 42 google_util::ALLOW_NON_STANDARD_PORTS)) { |
| 44 return; | 43 return; |
| 45 } | 44 } |
| 46 | 45 |
| 47 if (uma_enabled) | 46 if (uma_enabled) |
| 48 headers->SetHeaderIfMissing("X-Chrome-UMA-Enabled", "1"); | 47 headers->SetHeaderIfMissing("X-Chrome-UMA-Enabled", "1"); |
| 49 | 48 |
| 50 // Lazily initialize the header, if not already done, before attempting to | 49 // Lazily initialize the header, if not already done, before attempting to |
| 51 // transmit it. | 50 // transmit it. |
| 52 InitVariationIDsCacheIfNeeded(); | 51 InitVariationIDsCacheIfNeeded(); |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 // if IDs are added as the header is recreated. The receiving servers are OK | 150 // if IDs are added as the header is recreated. The receiving servers are OK |
| 152 // with such descrepancies. | 151 // with such descrepancies. |
| 153 variation_ids_header_ = hashed; | 152 variation_ids_header_ = hashed; |
| 154 } else { | 153 } else { |
| 155 NOTREACHED() << "Failed to base64 encode Variation IDs value: " | 154 NOTREACHED() << "Failed to base64 encode Variation IDs value: " |
| 156 << serialized; | 155 << serialized; |
| 157 } | 156 } |
| 158 } | 157 } |
| 159 | 158 |
| 160 } // namespace chrome_variations | 159 } // namespace chrome_variations |
| OLD | NEW |