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

Unified Diff: components/ntp_snippets/ntp_snippets_fetcher.cc

Issue 2292053004: Inject API key directly into snippets fetcher. (Closed)
Patch Set: rebase Created 4 years, 4 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: components/ntp_snippets/ntp_snippets_fetcher.cc
diff --git a/components/ntp_snippets/ntp_snippets_fetcher.cc b/components/ntp_snippets/ntp_snippets_fetcher.cc
index 0c6f4603075ae7279357b8dc9722c4a4fee4eaec..0854d6b976427fa91b3b08544e892bba086fd39c 100644
--- a/components/ntp_snippets/ntp_snippets_fetcher.cc
+++ b/components/ntp_snippets/ntp_snippets_fetcher.cc
@@ -28,7 +28,6 @@
#include "components/signin/core/browser/signin_manager_base.h"
#include "components/variations/net/variations_http_headers.h"
#include "components/variations/variations_associated_data.h"
-#include "google_apis/google_api_keys.h"
Marc Treib 2016/08/31 09:26:16 Can we remove the google_apis/ dependency from com
sfiera 2016/08/31 10:09:16 Nope, we still use OAuth2TokenService.
#include "net/base/load_flags.h"
#include "net/http/http_request_headers.h"
#include "net/http/http_response_headers.h"
@@ -181,7 +180,7 @@ NTPSnippetsFetcher::NTPSnippetsFetcher(
PrefService* pref_service,
CategoryFactory* category_factory,
const ParseJSONCallback& parse_json_callback,
- bool is_stable_channel)
+ const std::string& api_key)
: OAuth2TokenService::Consumer("ntp_snippets"),
signin_manager_(signin_manager),
token_service_(token_service),
@@ -193,7 +192,7 @@ NTPSnippetsFetcher::NTPSnippetsFetcher(
fetch_api_(UsesChromeContentSuggestionsAPI(fetch_url_)
? CHROME_CONTENT_SUGGESTIONS_API
: CHROME_READER_API),
- is_stable_channel_(is_stable_channel),
+ api_key_(api_key),
interactive_request_(false),
tick_clock_(new base::DefaultTickClock()),
request_throttler_(
@@ -431,11 +430,8 @@ bool NTPSnippetsFetcher::UsesAuthentication() const {
void NTPSnippetsFetcher::FetchSnippetsNonAuthenticated() {
// When not providing OAuth token, we need to pass the Google API key.
- const std::string& key = is_stable_channel_
- ? google_apis::GetAPIKey()
- : google_apis::GetNonStableAPIKey();
GURL url(base::StringPrintf(kSnippetsServerNonAuthorizedFormat,
- fetch_url_.spec().c_str(), key.c_str()));
+ fetch_url_.spec().c_str(), api_key_.c_str()));
RequestParams params;
params.fetch_api = fetch_api_;

Powered by Google App Engine
This is Rietveld 408576698