Chromium Code Reviews| Index: components/ntp_snippets/remote/remote_suggestions_fetcher.cc |
| diff --git a/components/ntp_snippets/remote/remote_suggestions_fetcher.cc b/components/ntp_snippets/remote/remote_suggestions_fetcher.cc |
| index 211ffa8d6a02a89927e32a6003e8896540147920..f401188a15f4c121dd0185cc1e7a3d8fed3bd9ed 100644 |
| --- a/components/ntp_snippets/remote/remote_suggestions_fetcher.cc |
| +++ b/components/ntp_snippets/remote/remote_suggestions_fetcher.cc |
| @@ -110,12 +110,6 @@ Status FetchResultToStatus(FetchResult result) { |
| return Status(StatusCode::PERMANENT_ERROR, std::string()); |
| } |
| -std::string GetFetchEndpoint() { |
| - std::string endpoint = variations::GetVariationParamValueByFeature( |
| - ntp_snippets::kArticleSuggestionsFeature, kContentSuggestionsBackend); |
| - return endpoint.empty() ? kContentSuggestionsServer : endpoint; |
| -} |
| - |
| bool UsesChromeContentSuggestionsAPI(const GURL& endpoint) { |
| if (endpoint == kChromeReaderServer) { |
| return false; |
| @@ -200,6 +194,27 @@ void FilterCategories( |
| } // namespace |
| +GURL GetFetchEndpoint(version_info::Channel channel) { |
| + std::string endpoint = variations::GetVariationParamValueByFeature( |
| + ntp_snippets::kArticleSuggestionsFeature, kContentSuggestionsBackend); |
| + if (!endpoint.empty()) { |
| + return GURL{endpoint}; |
|
Marc Treib
2017/02/23 14:56:42
A fan of new-style initialization syntax? Haven't
sfiera
2017/02/23 15:14:20
Well, actually, I first tried {endpoint}, but it d
|
| + } |
| + |
| + switch (channel) { |
| + case version_info::Channel::STABLE: |
| + case version_info::Channel::BETA: |
| + return GURL{kContentSuggestionsServer}; |
| + |
| + case version_info::Channel::DEV: |
| + case version_info::Channel::CANARY: |
| + case version_info::Channel::UNKNOWN: |
| + return GURL{kContentSuggestionsStagingServer}; |
| + } |
| + NOTREACHED(); |
| + return GURL{kContentSuggestionsStagingServer}; |
| +} |
| + |
| CategoryInfo BuildArticleCategoryInfo( |
| const base::Optional<base::string16>& title) { |
| return CategoryInfo( |
| @@ -246,6 +261,7 @@ RemoteSuggestionsFetcher::RemoteSuggestionsFetcher( |
| PrefService* pref_service, |
| LanguageModel* language_model, |
| const ParseJSONCallback& parse_json_callback, |
| + const GURL& api_endpoint, |
| const std::string& api_key, |
| const UserClassifier* user_classifier) |
| : OAuth2TokenService::Consumer("ntp_snippets"), |
| @@ -254,7 +270,7 @@ RemoteSuggestionsFetcher::RemoteSuggestionsFetcher( |
| url_request_context_getter_(std::move(url_request_context_getter)), |
| language_model_(language_model), |
| parse_json_callback_(parse_json_callback), |
| - fetch_url_(GetFetchEndpoint()), |
| + fetch_url_(api_endpoint), |
| fetch_api_(UsesChromeContentSuggestionsAPI(fetch_url_) |
| ? FetchAPI::CHROME_CONTENT_SUGGESTIONS_API |
| : FetchAPI::CHROME_READER_API), |