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 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 660 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
671 /*default_value=*/false); | 671 /*default_value=*/false); |
672 } | 672 } |
673 | 673 |
674 std::string NTPSnippetsFetcher::RequestBuilder::BuildHeaders() const { | 674 std::string NTPSnippetsFetcher::RequestBuilder::BuildHeaders() const { |
675 net::HttpRequestHeaders headers; | 675 net::HttpRequestHeaders headers; |
676 headers.SetHeader("Content-Type", "application/json; charset=UTF-8"); | 676 headers.SetHeader("Content-Type", "application/json; charset=UTF-8"); |
677 if (!auth_header_.empty()) { | 677 if (!auth_header_.empty()) { |
678 headers.SetHeader("Authorization", auth_header_); | 678 headers.SetHeader("Authorization", auth_header_); |
679 } | 679 } |
680 // Add X-Client-Data header with experiment IDs from field trials. | 680 // Add X-Client-Data header with experiment IDs from field trials. |
| 681 // Note: It's fine to pass in |is_signed_in| false, which does not affect |
| 682 // transmission of experiment ids coming from the variations server. |
| 683 bool is_signed_in = false; |
681 variations::AppendVariationHeaders(url_, | 684 variations::AppendVariationHeaders(url_, |
682 false, // incognito | 685 false, // incognito |
683 false, // uma_enabled | 686 false, // uma_enabled |
684 &headers); | 687 is_signed_in, &headers); |
685 return headers.ToString(); | 688 return headers.ToString(); |
686 } | 689 } |
687 | 690 |
688 std::string NTPSnippetsFetcher::RequestBuilder::BuildBody() const { | 691 std::string NTPSnippetsFetcher::RequestBuilder::BuildBody() const { |
689 auto request = base::MakeUnique<base::DictionaryValue>(); | 692 auto request = base::MakeUnique<base::DictionaryValue>(); |
690 std::string user_locale = PosixLocaleFromBCP47Language(params_.language_code); | 693 std::string user_locale = PosixLocaleFromBCP47Language(params_.language_code); |
691 switch (fetch_api_) { | 694 switch (fetch_api_) { |
692 case NTPSnippetsFetcher::CHROME_READER_API: { | 695 case NTPSnippetsFetcher::CHROME_READER_API: { |
693 auto content_params = base::MakeUnique<base::DictionaryValue>(); | 696 auto content_params = base::MakeUnique<base::DictionaryValue>(); |
694 content_params->SetBoolean("only_return_personalized_results", | 697 content_params->SetBoolean("only_return_personalized_results", |
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1097 NOTREACHED(); | 1100 NOTREACHED(); |
1098 return false; | 1101 return false; |
1099 } | 1102 } |
1100 | 1103 |
1101 bool NTPSnippetsFetcher::NeedsAuthentication() const { | 1104 bool NTPSnippetsFetcher::NeedsAuthentication() const { |
1102 return (personalization_ == Personalization::kPersonal || | 1105 return (personalization_ == Personalization::kPersonal || |
1103 personalization_ == Personalization::kBoth); | 1106 personalization_ == Personalization::kBoth); |
1104 } | 1107 } |
1105 | 1108 |
1106 } // namespace ntp_snippets | 1109 } // namespace ntp_snippets |
OLD | NEW |