| 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 <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/feature_list.h" | 9 #include "base/feature_list.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| 11 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
| 12 #include "base/memory/singleton.h" | 12 #include "base/memory/singleton.h" |
| 13 #include "base/threading/sequenced_worker_pool.h" | 13 #include "base/threading/sequenced_worker_pool.h" |
| 14 #include "base/time/default_clock.h" | 14 #include "base/time/default_clock.h" |
| 15 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 15 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
| 16 #include "chrome/browser/browser_process.h" | 16 #include "chrome/browser/browser_process.h" |
| 17 #include "chrome/browser/favicon/large_icon_service_factory.h" |
| 17 #include "chrome/browser/history/history_service_factory.h" | 18 #include "chrome/browser/history/history_service_factory.h" |
| 18 #include "chrome/browser/profiles/profile.h" | 19 #include "chrome/browser/profiles/profile.h" |
| 19 #include "chrome/browser/search/suggestions/image_decoder_impl.h" | 20 #include "chrome/browser/search/suggestions/image_decoder_impl.h" |
| 20 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" | 21 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
| 21 #include "chrome/browser/signin/signin_manager_factory.h" | 22 #include "chrome/browser/signin/signin_manager_factory.h" |
| 22 #include "chrome/browser/sync/profile_sync_service_factory.h" | 23 #include "chrome/browser/sync/profile_sync_service_factory.h" |
| 23 #include "chrome/browser/translate/language_model_factory.h" | 24 #include "chrome/browser/translate/language_model_factory.h" |
| 24 #include "chrome/common/channel_info.h" | 25 #include "chrome/common/channel_info.h" |
| 25 #include "chrome/common/chrome_features.h" | 26 #include "chrome/common/chrome_features.h" |
| 26 #include "components/bookmarks/browser/bookmark_model.h" | 27 #include "components/bookmarks/browser/bookmark_model.h" |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 return static_cast<ContentSuggestionsService*>( | 266 return static_cast<ContentSuggestionsService*>( |
| 266 GetInstance()->GetServiceForBrowserContext(profile, false)); | 267 GetInstance()->GetServiceForBrowserContext(profile, false)); |
| 267 } | 268 } |
| 268 | 269 |
| 269 ContentSuggestionsServiceFactory::ContentSuggestionsServiceFactory() | 270 ContentSuggestionsServiceFactory::ContentSuggestionsServiceFactory() |
| 270 : BrowserContextKeyedServiceFactory( | 271 : BrowserContextKeyedServiceFactory( |
| 271 "ContentSuggestionsService", | 272 "ContentSuggestionsService", |
| 272 BrowserContextDependencyManager::GetInstance()) { | 273 BrowserContextDependencyManager::GetInstance()) { |
| 273 DependsOn(BookmarkModelFactory::GetInstance()); | 274 DependsOn(BookmarkModelFactory::GetInstance()); |
| 274 DependsOn(HistoryServiceFactory::GetInstance()); | 275 DependsOn(HistoryServiceFactory::GetInstance()); |
| 276 DependsOn(LargeIconServiceFactory::GetInstance()); |
| 275 #if defined(OS_ANDROID) | 277 #if defined(OS_ANDROID) |
| 276 DependsOn(OfflinePageModelFactory::GetInstance()); | 278 DependsOn(OfflinePageModelFactory::GetInstance()); |
| 277 #endif // OS_ANDROID | 279 #endif // OS_ANDROID |
| 278 DependsOn(ProfileOAuth2TokenServiceFactory::GetInstance()); | 280 DependsOn(ProfileOAuth2TokenServiceFactory::GetInstance()); |
| 279 DependsOn(ProfileSyncServiceFactory::GetInstance()); | 281 DependsOn(ProfileSyncServiceFactory::GetInstance()); |
| 280 DependsOn(SigninManagerFactory::GetInstance()); | 282 DependsOn(SigninManagerFactory::GetInstance()); |
| 281 } | 283 } |
| 282 | 284 |
| 283 ContentSuggestionsServiceFactory::~ContentSuggestionsServiceFactory() = default; | 285 ContentSuggestionsServiceFactory::~ContentSuggestionsServiceFactory() = default; |
| 284 | 286 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 302 #endif // OS_ANDROID | 304 #endif // OS_ANDROID |
| 303 auto scheduler = base::MakeUnique<RemoteSuggestionsSchedulerImpl>( | 305 auto scheduler = base::MakeUnique<RemoteSuggestionsSchedulerImpl>( |
| 304 persistent_scheduler, user_classifier_raw, pref_service, | 306 persistent_scheduler, user_classifier_raw, pref_service, |
| 305 g_browser_process->local_state(), base::MakeUnique<base::DefaultClock>()); | 307 g_browser_process->local_state(), base::MakeUnique<base::DefaultClock>()); |
| 306 | 308 |
| 307 // Create the ContentSuggestionsService. | 309 // Create the ContentSuggestionsService. |
| 308 SigninManagerBase* signin_manager = | 310 SigninManagerBase* signin_manager = |
| 309 SigninManagerFactory::GetForProfile(profile); | 311 SigninManagerFactory::GetForProfile(profile); |
| 310 HistoryService* history_service = HistoryServiceFactory::GetForProfile( | 312 HistoryService* history_service = HistoryServiceFactory::GetForProfile( |
| 311 profile, ServiceAccessType::EXPLICIT_ACCESS); | 313 profile, ServiceAccessType::EXPLICIT_ACCESS); |
| 314 favicon::LargeIconService* large_icon_service = |
| 315 LargeIconServiceFactory::GetForBrowserContext(profile); |
| 312 std::unique_ptr<CategoryRanker> category_ranker = | 316 std::unique_ptr<CategoryRanker> category_ranker = |
| 313 ntp_snippets::BuildSelectedCategoryRanker( | 317 ntp_snippets::BuildSelectedCategoryRanker( |
| 314 pref_service, base::MakeUnique<base::DefaultClock>()); | 318 pref_service, base::MakeUnique<base::DefaultClock>()); |
| 315 auto* service = new ContentSuggestionsService( | 319 auto* service = new ContentSuggestionsService( |
| 316 State::ENABLED, signin_manager, history_service, pref_service, | 320 State::ENABLED, signin_manager, history_service, large_icon_service, |
| 317 std::move(category_ranker), std::move(user_classifier), | 321 pref_service, std::move(category_ranker), std::move(user_classifier), |
| 318 std::move(scheduler)); | 322 std::move(scheduler)); |
| 319 | 323 |
| 320 #if defined(OS_ANDROID) | 324 #if defined(OS_ANDROID) |
| 321 OfflinePageModel* offline_page_model = | 325 OfflinePageModel* offline_page_model = |
| 322 OfflinePageModelFactory::GetForBrowserContext(profile); | 326 OfflinePageModelFactory::GetForBrowserContext(profile); |
| 323 RequestCoordinator* request_coordinator = | 327 RequestCoordinator* request_coordinator = |
| 324 RequestCoordinatorFactory::GetForBrowserContext(profile); | 328 RequestCoordinatorFactory::GetForBrowserContext(profile); |
| 325 DownloadManager* download_manager = | 329 DownloadManager* download_manager = |
| 326 content::BrowserContext::GetDownloadManager(profile); | 330 content::BrowserContext::GetDownloadManager(profile); |
| 327 DownloadService* download_service = | 331 DownloadService* download_service = |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 383 ntp_snippets::kForeignSessionsSuggestionsFeature)) { | 387 ntp_snippets::kForeignSessionsSuggestionsFeature)) { |
| 384 RegisterForeignSessionsProvider(sync_service, service, pref_service); | 388 RegisterForeignSessionsProvider(sync_service, service, pref_service); |
| 385 } | 389 } |
| 386 | 390 |
| 387 return service; | 391 return service; |
| 388 | 392 |
| 389 #else | 393 #else |
| 390 return nullptr; | 394 return nullptr; |
| 391 #endif // CONTENT_SUGGESTIONS_ENABLED | 395 #endif // CONTENT_SUGGESTIONS_ENABLED |
| 392 } | 396 } |
| OLD | NEW |