OLD | NEW |
---|---|
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 Loading... | |
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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
150 bool is_stable_channel = | 151 bool is_stable_channel = |
151 chrome::GetChannel() == version_info::Channel::STABLE; | 152 chrome::GetChannel() == version_info::Channel::STABLE; |
152 std::unique_ptr<NTPSnippetsService> ntp_snippets_service = | 153 std::unique_ptr<NTPSnippetsService> ntp_snippets_service = |
153 base::MakeUnique<NTPSnippetsService>( | 154 base::MakeUnique<NTPSnippetsService>( |
154 service, service->category_factory(), pref_service, history_service, | 155 service, service->category_factory(), pref_service, history_service, |
155 suggestions_service, g_browser_process->GetApplicationLocale(), | 156 suggestions_service, g_browser_process->GetApplicationLocale(), |
156 scheduler, | 157 scheduler, |
157 base::MakeUnique<NTPSnippetsFetcher>( | 158 base::MakeUnique<NTPSnippetsFetcher>( |
158 signin_manager, token_service, request_context, pref_service, | 159 signin_manager, token_service, request_context, pref_service, |
159 category_factory, base::Bind(&safe_json::SafeJsonParser::Parse), | 160 category_factory, base::Bind(&safe_json::SafeJsonParser::Parse), |
160 is_stable_channel), | 161 is_stable_channel ? google_apis::GetAPIKey() |
162 : google_apis::GetNonStableAPIKey()), | |
Marc Treib
2016/08/31 09:26:16
You'll probably have to do the same thing in the i
sfiera
2016/08/31 10:09:16
Done, possibly.
| |
161 base::MakeUnique<ImageFetcherImpl>( | 163 base::MakeUnique<ImageFetcherImpl>( |
162 base::MakeUnique<ImageDecoderImpl>(), request_context.get()), | 164 base::MakeUnique<ImageDecoderImpl>(), request_context.get()), |
163 base::MakeUnique<ImageDecoderImpl>(), | 165 base::MakeUnique<ImageDecoderImpl>(), |
164 base::MakeUnique<NTPSnippetsDatabase>(database_dir, task_runner), | 166 base::MakeUnique<NTPSnippetsDatabase>(database_dir, task_runner), |
165 base::MakeUnique<NTPSnippetsStatusService>(signin_manager, | 167 base::MakeUnique<NTPSnippetsStatusService>(signin_manager, |
166 pref_service)); | 168 pref_service)); |
167 service->set_ntp_snippets_service(ntp_snippets_service.get()); | 169 service->set_ntp_snippets_service(ntp_snippets_service.get()); |
168 service->RegisterProvider(std::move(ntp_snippets_service)); | 170 service->RegisterProvider(std::move(ntp_snippets_service)); |
169 } | 171 } |
170 | 172 |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
259 #endif // OS_ANDROID | 261 #endif // OS_ANDROID |
260 | 262 |
261 if (base::FeatureList::IsEnabled(ntp_snippets::kArticleSuggestionsFeature)) { | 263 if (base::FeatureList::IsEnabled(ntp_snippets::kArticleSuggestionsFeature)) { |
262 RegisterArticleProvider(signin_manager, token_service, history_service, | 264 RegisterArticleProvider(signin_manager, token_service, history_service, |
263 suggestions_service, service, category_factory, | 265 suggestions_service, service, category_factory, |
264 pref_service, profile); | 266 pref_service, profile); |
265 } | 267 } |
266 | 268 |
267 return service; | 269 return service; |
268 } | 270 } |
OLD | NEW |