Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7877)

Unified Diff: chrome/browser/ntp_snippets/content_suggestions_service_factory.cc

Issue 2750393002: [NTP Snippets] Don't attempt to fetch remote suggestions without API key (Closed)
Patch Set: Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | components/ntp_snippets/remote/json_request.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ntp_snippets/content_suggestions_service_factory.cc
diff --git a/chrome/browser/ntp_snippets/content_suggestions_service_factory.cc b/chrome/browser/ntp_snippets/content_suggestions_service_factory.cc
index bbcc054008d36983d2bf715b0077960052637940..28b217042a202caf3b1949d6c8964127de466e2f 100644
--- a/chrome/browser/ntp_snippets/content_suggestions_service_factory.cc
+++ b/chrome/browser/ntp_snippets/content_suggestions_service_factory.cc
@@ -194,14 +194,18 @@ void RegisterArticleProvider(SigninManagerBase* signin_manager,
->GetSequencedTaskRunnerWithShutdownBehavior(
base::SequencedWorkerPool::GetSequenceToken(),
base::SequencedWorkerPool::CONTINUE_ON_SHUTDOWN);
- bool is_stable_channel =
- chrome::GetChannel() == version_info::Channel::STABLE;
+ std::string api_key;
+ // The API is private. If we don't have the official API key, don't even try.
+ if (google_apis::IsGoogleChromeAPIKeyUsed()) {
+ bool is_stable_channel =
+ chrome::GetChannel() == version_info::Channel::STABLE;
+ api_key = is_stable_channel ? google_apis::GetAPIKey()
+ : google_apis::GetNonStableAPIKey();
+ }
auto suggestions_fetcher = base::MakeUnique<RemoteSuggestionsFetcher>(
signin_manager, token_service, request_context, pref_service,
language_model, base::Bind(&safe_json::SafeJsonParser::Parse),
- GetFetchEndpoint(chrome::GetChannel()),
- is_stable_channel ? google_apis::GetAPIKey()
- : google_apis::GetNonStableAPIKey(),
+ GetFetchEndpoint(chrome::GetChannel()), api_key,
service->user_classifier());
auto provider = base::MakeUnique<RemoteSuggestionsProviderImpl>(
service, pref_service, g_browser_process->GetApplicationLocale(),
@@ -295,9 +299,9 @@ KeyedService* ContentSuggestionsServiceFactory::BuildServiceInstanceFor(
std::unique_ptr<CategoryRanker> category_ranker =
ntp_snippets::BuildSelectedCategoryRanker(
pref_service, base::MakeUnique<base::DefaultClock>());
- auto* service =
- new ContentSuggestionsService(State::ENABLED, signin_manager,
- history_service, pref_service, std::move(category_ranker));
+ auto* service = new ContentSuggestionsService(State::ENABLED, signin_manager,
+ history_service, pref_service,
+ std::move(category_ranker));
#if defined(OS_ANDROID)
OfflinePageModel* offline_page_model =
« no previous file with comments | « no previous file | components/ntp_snippets/remote/json_request.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698