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>( |