| 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/remote_suggestions_fetcher.h" | 5 #include "components/ntp_snippets/remote/remote_suggestions_fetcher.h" |
| 6 | 6 |
| 7 #include "components/ntp_snippets/features.h" | 7 #include "components/ntp_snippets/features.h" |
| 8 #include "components/ntp_snippets/ntp_snippets_constants.h" | 8 #include "components/ntp_snippets/ntp_snippets_constants.h" |
| 9 #include "components/strings/grit/components_strings.h" | 9 #include "components/strings/grit/components_strings.h" |
| 10 #include "components/variations/variations_associated_data.h" | 10 #include "components/variations/variations_associated_data.h" |
| 11 #include "ui/base/l10n/l10n_util.h" | 11 #include "ui/base/l10n/l10n_util.h" |
| 12 | 12 |
| 13 namespace ntp_snippets { | 13 namespace ntp_snippets { |
| 14 | 14 |
| 15 namespace { | 15 namespace { |
| 16 | 16 |
| 17 // Variation parameter for chrome-content-suggestions backend. | 17 // Variation parameter for chrome-content-suggestions backend. |
| 18 const char kContentSuggestionsBackend[] = "content_suggestions_backend"; | 18 constexpr base::FeatureParam<std::string> kContentSuggestionsBackend{ |
| 19 &kArticleSuggestionsFeature, "content_suggestions_backend", ""}; |
| 19 | 20 |
| 20 } // namespace | 21 } // namespace |
| 21 | 22 |
| 22 GURL GetFetchEndpoint(version_info::Channel channel) { | 23 GURL GetFetchEndpoint(version_info::Channel channel) { |
| 23 std::string endpoint = variations::GetVariationParamValueByFeature( | 24 std::string endpoint = kContentSuggestionsBackend.Get(); |
| 24 ntp_snippets::kArticleSuggestionsFeature, kContentSuggestionsBackend); | |
| 25 if (!endpoint.empty()) { | 25 if (!endpoint.empty()) { |
| 26 return GURL{endpoint}; | 26 return GURL{endpoint}; |
| 27 } | 27 } |
| 28 | 28 |
| 29 switch (channel) { | 29 switch (channel) { |
| 30 case version_info::Channel::STABLE: | 30 case version_info::Channel::STABLE: |
| 31 case version_info::Channel::BETA: | 31 case version_info::Channel::BETA: |
| 32 return GURL{kContentSuggestionsServer}; | 32 return GURL{kContentSuggestionsServer}; |
| 33 | 33 |
| 34 case version_info::Channel::DEV: | 34 case version_info::Channel::DEV: |
| 35 case version_info::Channel::CANARY: | 35 case version_info::Channel::CANARY: |
| 36 case version_info::Channel::UNKNOWN: | 36 case version_info::Channel::UNKNOWN: |
| 37 return GURL{kContentSuggestionsStagingServer}; | 37 return GURL{kContentSuggestionsStagingServer}; |
| 38 } | 38 } |
| 39 NOTREACHED(); | 39 NOTREACHED(); |
| 40 return GURL{kContentSuggestionsStagingServer}; | 40 return GURL{kContentSuggestionsStagingServer}; |
| 41 } | 41 } |
| 42 | 42 |
| 43 RemoteSuggestionsFetcher::~RemoteSuggestionsFetcher() = default; | 43 RemoteSuggestionsFetcher::~RemoteSuggestionsFetcher() = default; |
| 44 | 44 |
| 45 } // namespace ntp_snippets | 45 } // namespace ntp_snippets |
| OLD | NEW |