| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/ntp_snippets/remote/ntp_snippets_fetcher.h" | 5 #include "components/ntp_snippets/remote/ntp_snippets_fetcher.h" |
| 6 | 6 |
| 7 #include <cstdlib> | 7 #include <cstdlib> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 519 net::LOAD_DO_NOT_SAVE_COOKIES); | 519 net::LOAD_DO_NOT_SAVE_COOKIES); |
| 520 | 520 |
| 521 data_use_measurement::DataUseUserData::AttachToFetcher( | 521 data_use_measurement::DataUseUserData::AttachToFetcher( |
| 522 url_fetcher_.get(), data_use_measurement::DataUseUserData::NTP_SNIPPETS); | 522 url_fetcher_.get(), data_use_measurement::DataUseUserData::NTP_SNIPPETS); |
| 523 | 523 |
| 524 HttpRequestHeaders headers; | 524 HttpRequestHeaders headers; |
| 525 if (!auth_header.empty()) | 525 if (!auth_header.empty()) |
| 526 headers.SetHeader("Authorization", auth_header); | 526 headers.SetHeader("Authorization", auth_header); |
| 527 headers.SetHeader("Content-Type", "application/json; charset=UTF-8"); | 527 headers.SetHeader("Content-Type", "application/json; charset=UTF-8"); |
| 528 // Add X-Client-Data header with experiment IDs from field trials. | 528 // Add X-Client-Data header with experiment IDs from field trials. |
| 529 variations::AppendVariationHeaders(url, | 529 // Note: It's fine to pass in |is_signed_in| false, which does not affect |
| 530 // transmission of experiment ids coming from the variations server. |
| 531 bool is_signed_in = false; |
| 532 variations::AppendVariationHeaders(url_, |
| 530 false, // incognito | 533 false, // incognito |
| 531 false, // uma_enabled | 534 false, // uma_enabled |
| 532 &headers); | 535 is_signed_in, &headers); |
| 533 url_fetcher_->SetExtraRequestHeaders(headers.ToString()); | 536 url_fetcher_->SetExtraRequestHeaders(headers.ToString()); |
| 534 url_fetcher_->SetUploadData("application/json", request); | 537 url_fetcher_->SetUploadData("application/json", request); |
| 535 // Log the request for debugging network issues. | 538 // Log the request for debugging network issues. |
| 536 VLOG(1) << "Sending a NTP snippets request to " << url << ":" << std::endl | 539 VLOG(1) << "Sending a NTP snippets request to " << url << ":" << std::endl |
| 537 << headers.ToString() << std::endl | 540 << headers.ToString() << std::endl |
| 538 << request; | 541 << request; |
| 539 // Fetchers are sometimes cancelled because a network change was detected. | 542 // Fetchers are sometimes cancelled because a network change was detected. |
| 540 url_fetcher_->SetAutomaticallyRetryOnNetworkChanges(3); | 543 url_fetcher_->SetAutomaticallyRetryOnNetworkChanges(3); |
| 541 // Try to make fetching the files bit more robust even with poor connection. | 544 // Try to make fetching the files bit more robust even with poor connection. |
| 542 url_fetcher_->SetMaxRetriesOn5xx(3); | 545 url_fetcher_->SetMaxRetriesOn5xx(3); |
| (...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 863 interactive_request); | 866 interactive_request); |
| 864 case UserClassifier::UserClass::ACTIVE_SUGGESTIONS_CONSUMER: | 867 case UserClassifier::UserClass::ACTIVE_SUGGESTIONS_CONSUMER: |
| 865 return request_throttler_active_suggestions_consumer_ | 868 return request_throttler_active_suggestions_consumer_ |
| 866 .DemandQuotaForRequest(interactive_request); | 869 .DemandQuotaForRequest(interactive_request); |
| 867 } | 870 } |
| 868 NOTREACHED(); | 871 NOTREACHED(); |
| 869 return false; | 872 return false; |
| 870 } | 873 } |
| 871 | 874 |
| 872 } // namespace ntp_snippets | 875 } // namespace ntp_snippets |
| OLD | NEW |