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

Side by Side Diff: chrome/browser/ntp_snippets/content_suggestions_service_factory.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 unified diff | Download patch
« no previous file with comments | « no previous file | components/ntp_snippets/ntp_snippets_fetcher.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ntp_snippets/content_suggestions_service_factory.h" 5 #include "chrome/browser/ntp_snippets/content_suggestions_service_factory.h"
6 6
7 #include "base/feature_list.h" 7 #include "base/feature_list.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "base/memory/singleton.h" 10 #include "base/memory/singleton.h"
(...skipping 23 matching lines...) Expand all
34 #include "components/ntp_snippets/ntp_snippets_service.h" 34 #include "components/ntp_snippets/ntp_snippets_service.h"
35 #include "components/ntp_snippets/ntp_snippets_status_service.h" 35 #include "components/ntp_snippets/ntp_snippets_status_service.h"
36 #include "components/prefs/pref_service.h" 36 #include "components/prefs/pref_service.h"
37 #include "components/safe_json/safe_json_parser.h" 37 #include "components/safe_json/safe_json_parser.h"
38 #include "components/signin/core/browser/profile_oauth2_token_service.h" 38 #include "components/signin/core/browser/profile_oauth2_token_service.h"
39 #include "components/signin/core/browser/signin_manager.h" 39 #include "components/signin/core/browser/signin_manager.h"
40 #include "components/version_info/version_info.h" 40 #include "components/version_info/version_info.h"
41 #include "content/public/browser/browser_context.h" 41 #include "content/public/browser/browser_context.h"
42 #include "content/public/browser/browser_thread.h" 42 #include "content/public/browser/browser_thread.h"
43 #include "content/public/browser/storage_partition.h" 43 #include "content/public/browser/storage_partition.h"
44 #include "google_apis/google_api_keys.h"
44 #include "net/url_request/url_request_context_getter.h" 45 #include "net/url_request/url_request_context_getter.h"
45 46
46 #if defined(OS_ANDROID) 47 #if defined(OS_ANDROID)
47 #include "chrome/browser/android/chrome_feature_list.h" 48 #include "chrome/browser/android/chrome_feature_list.h"
48 #include "chrome/browser/android/ntp/ntp_snippets_launcher.h" 49 #include "chrome/browser/android/ntp/ntp_snippets_launcher.h"
49 #include "chrome/browser/android/offline_pages/offline_page_model_factory.h" 50 #include "chrome/browser/android/offline_pages/offline_page_model_factory.h"
50 #include "components/ntp_snippets/offline_pages/offline_page_suggestions_provide r.h" 51 #include "components/ntp_snippets/offline_pages/offline_page_suggestions_provide r.h"
51 #include "components/ntp_snippets/physical_web_pages/physical_web_page_suggestio ns_provider.h" 52 #include "components/ntp_snippets/physical_web_pages/physical_web_page_suggestio ns_provider.h"
52 #include "components/offline_pages/offline_page_model.h" 53 #include "components/offline_pages/offline_page_model.h"
53 54
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 bool is_stable_channel = 150 bool is_stable_channel =
150 chrome::GetChannel() == version_info::Channel::STABLE; 151 chrome::GetChannel() == version_info::Channel::STABLE;
151 std::unique_ptr<NTPSnippetsService> ntp_snippets_service = 152 std::unique_ptr<NTPSnippetsService> ntp_snippets_service =
152 base::MakeUnique<NTPSnippetsService>( 153 base::MakeUnique<NTPSnippetsService>(
153 service, service->category_factory(), pref_service, 154 service, service->category_factory(), pref_service,
154 suggestions_service, g_browser_process->GetApplicationLocale(), 155 suggestions_service, g_browser_process->GetApplicationLocale(),
155 scheduler, 156 scheduler,
156 base::MakeUnique<NTPSnippetsFetcher>( 157 base::MakeUnique<NTPSnippetsFetcher>(
157 signin_manager, token_service, request_context, pref_service, 158 signin_manager, token_service, request_context, pref_service,
158 category_factory, base::Bind(&safe_json::SafeJsonParser::Parse), 159 category_factory, base::Bind(&safe_json::SafeJsonParser::Parse),
159 is_stable_channel), 160 is_stable_channel ? google_apis::GetAPIKey()
161 : google_apis::GetNonStableAPIKey()),
160 base::MakeUnique<ImageFetcherImpl>( 162 base::MakeUnique<ImageFetcherImpl>(
161 base::MakeUnique<ImageDecoderImpl>(), request_context.get()), 163 base::MakeUnique<ImageDecoderImpl>(), request_context.get()),
162 base::MakeUnique<ImageDecoderImpl>(), 164 base::MakeUnique<ImageDecoderImpl>(),
163 base::MakeUnique<NTPSnippetsDatabase>(database_dir, task_runner), 165 base::MakeUnique<NTPSnippetsDatabase>(database_dir, task_runner),
164 base::MakeUnique<NTPSnippetsStatusService>(signin_manager, 166 base::MakeUnique<NTPSnippetsStatusService>(signin_manager,
165 pref_service)); 167 pref_service));
166 service->set_ntp_snippets_service(ntp_snippets_service.get()); 168 service->set_ntp_snippets_service(ntp_snippets_service.get());
167 service->RegisterProvider(std::move(ntp_snippets_service)); 169 service->RegisterProvider(std::move(ntp_snippets_service));
168 } 170 }
169 171
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 } 262 }
261 #endif // OS_ANDROID 263 #endif // OS_ANDROID
262 264
263 if (base::FeatureList::IsEnabled(ntp_snippets::kArticleSuggestionsFeature)) { 265 if (base::FeatureList::IsEnabled(ntp_snippets::kArticleSuggestionsFeature)) {
264 RegisterArticleProvider(signin_manager, token_service, suggestions_service, 266 RegisterArticleProvider(signin_manager, token_service, suggestions_service,
265 service, category_factory, pref_service, profile); 267 service, category_factory, pref_service, profile);
266 } 268 }
267 269
268 return service; 270 return service;
269 } 271 }
OLDNEW
« no previous file with comments | « no previous file | components/ntp_snippets/ntp_snippets_fetcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698