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

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, 3 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 84b29d206dda0c27483fef38f07190d0ab3e9d5f..9828eb8d9f38ef7c076d871077d2a864da6e338f 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"
#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_;
« no previous file with comments | « components/ntp_snippets/ntp_snippets_fetcher.h ('k') | components/ntp_snippets/ntp_snippets_fetcher_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698