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..14f38f0943613005843e9690c94783c4cde916ef 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,16 @@ void FilterCategories( |
} // namespace |
+std::string GetFetchEndpoint(bool is_stable_or_beta_channel) { |
+ std::string endpoint = variations::GetVariationParamValueByFeature( |
+ ntp_snippets::kArticleSuggestionsFeature, kContentSuggestionsBackend); |
+ if (endpoint.empty()) { |
+ endpoint = is_stable_or_beta_channel ? kContentSuggestionsServer |
+ : kContentSuggestionsStagingServer; |
+ } |
+ return endpoint; |
+} |
+ |
CategoryInfo BuildArticleCategoryInfo( |
const base::Optional<base::string16>& title) { |
return CategoryInfo( |
@@ -246,6 +250,7 @@ RemoteSuggestionsFetcher::RemoteSuggestionsFetcher( |
PrefService* pref_service, |
LanguageModel* language_model, |
const ParseJSONCallback& parse_json_callback, |
+ const std::string& api_endpoint, |
const std::string& api_key, |
const UserClassifier* user_classifier) |
: OAuth2TokenService::Consumer("ntp_snippets"), |
@@ -254,7 +259,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), |