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

Unified Diff: ios/chrome/browser/ntp_snippets/ios_chrome_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
Index: ios/chrome/browser/ntp_snippets/ios_chrome_content_suggestions_service_factory.cc
diff --git a/ios/chrome/browser/ntp_snippets/ios_chrome_content_suggestions_service_factory.cc b/ios/chrome/browser/ntp_snippets/ios_chrome_content_suggestions_service_factory.cc
index 8493ae510276205e9859b4e495a354bf1b851f75..39bc08887d118e69f3c3cc90afc05e051a93f3e8 100644
--- a/ios/chrome/browser/ntp_snippets/ios_chrome_content_suggestions_service_factory.cc
+++ b/ios/chrome/browser/ntp_snippets/ios_chrome_content_suggestions_service_factory.cc
@@ -156,12 +156,17 @@ IOSChromeContentSuggestionsServiceFactory::BuildServiceInstanceFor(
base::SequencedWorkerPool::GetSequenceToken(),
base::SequencedWorkerPool::CONTINUE_ON_SHUTDOWN);
+ 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 = 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, prefs, nullptr,
- base::Bind(&ParseJson), GetFetchEndpoint(GetChannel()),
- GetChannel() == version_info::Channel::STABLE
- ? google_apis::GetAPIKey()
- : google_apis::GetNonStableAPIKey(),
+ base::Bind(&ParseJson), GetFetchEndpoint(GetChannel()), api_key,
service->user_classifier());
auto provider = base::MakeUnique<RemoteSuggestionsProviderImpl>(
« no previous file with comments | « components/ntp_snippets/remote/remote_suggestions_fetcher_unittest.cc ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698