| 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/renderer_host/chrome_resource_dispatcher_host_delegate.
h" | 5 #include "chrome/browser/renderer_host/chrome_resource_dispatcher_host_delegate.
h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/base64.h" | 9 #include "base/base64.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 // google_util helpers to check this does not guarantee that the URL is | 284 // google_util helpers to check this does not guarantee that the URL is |
| 285 // Google-owned, only that it is of the form *.google.<TLD>. In the future | 285 // Google-owned, only that it is of the form *.google.<TLD>. In the future |
| 286 // we may choose to reinforce this check. | 286 // we may choose to reinforce this check. |
| 287 // 2. We only transmit for non-Incognito profiles. | 287 // 2. We only transmit for non-Incognito profiles. |
| 288 // 3. For the X-Chrome-UMA-Enabled bit, we only set it if UMA is in fact | 288 // 3. For the X-Chrome-UMA-Enabled bit, we only set it if UMA is in fact |
| 289 // enabled for this install of Chrome. | 289 // enabled for this install of Chrome. |
| 290 // 4. For the X-Chrome-Variations, we only include non-empty variation IDs. | 290 // 4. For the X-Chrome-Variations, we only include non-empty variation IDs. |
| 291 ProfileIOData* io_data = ProfileIOData::FromResourceContext(resource_context); | 291 ProfileIOData* io_data = ProfileIOData::FromResourceContext(resource_context); |
| 292 if (io_data->is_incognito() || | 292 if (io_data->is_incognito() || |
| 293 !google_util::IsGoogleDomainUrl(request->url().spec(), | 293 !google_util::IsGoogleDomainUrl(request->url().spec(), |
| 294 google_util::ALLOW_SUBDOMAIN)) | 294 google_util::ALLOW_SUBDOMAIN, |
| 295 google_util::ALLOW_NON_STANDARD_PORTS)) |
| 295 return; | 296 return; |
| 296 | 297 |
| 297 if (io_data->GetMetricsEnabledStateOnIOThread()) | 298 if (io_data->GetMetricsEnabledStateOnIOThread()) |
| 298 request->SetExtraRequestHeaderByName("X-Chrome-UMA-Enabled", "1", false); | 299 request->SetExtraRequestHeaderByName("X-Chrome-UMA-Enabled", "1", false); |
| 299 | 300 |
| 300 // Lazily initialize the header, if not already done, before we attempt to | 301 // Lazily initialize the header, if not already done, before we attempt to |
| 301 // transmit it. | 302 // transmit it. |
| 302 InitVariationIDsCacheIfNeeded(); | 303 InitVariationIDsCacheIfNeeded(); |
| 303 if (!variation_ids_header_.empty()) { | 304 if (!variation_ids_header_.empty()) { |
| 304 request->SetExtraRequestHeaderByName("X-Chrome-Variations", | 305 request->SetExtraRequestHeaderByName("X-Chrome-Variations", |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 432 if (base::Base64Encode(serialized, &hashed)) { | 433 if (base::Base64Encode(serialized, &hashed)) { |
| 433 // If successful, swap the header value with the new one. | 434 // If successful, swap the header value with the new one. |
| 434 // Note that the list of IDs and the header could be temporarily out of sync | 435 // Note that the list of IDs and the header could be temporarily out of sync |
| 435 // if IDs are added as we are recreating the header, but we're OK with those | 436 // if IDs are added as we are recreating the header, but we're OK with those |
| 436 // descrepancies. | 437 // descrepancies. |
| 437 variation_ids_header_ = hashed; | 438 variation_ids_header_ = hashed; |
| 438 } else { | 439 } else { |
| 439 DVLOG(1) << "Failed to base64 encode Variation IDs value: " << serialized; | 440 DVLOG(1) << "Failed to base64 encode Variation IDs value: " << serialized; |
| 440 } | 441 } |
| 441 } | 442 } |
| OLD | NEW |