| 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" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 #include "chrome/common/channel_info.h" | 22 #include "chrome/common/channel_info.h" |
| 23 #include "chrome/common/chrome_features.h" | 23 #include "chrome/common/chrome_features.h" |
| 24 #include "components/bookmarks/browser/bookmark_model.h" | 24 #include "components/bookmarks/browser/bookmark_model.h" |
| 25 #include "components/browser_sync/profile_sync_service.h" | 25 #include "components/browser_sync/profile_sync_service.h" |
| 26 #include "components/image_fetcher/image_decoder.h" | 26 #include "components/image_fetcher/image_decoder.h" |
| 27 #include "components/image_fetcher/image_fetcher.h" | 27 #include "components/image_fetcher/image_fetcher.h" |
| 28 #include "components/image_fetcher/image_fetcher_impl.h" | 28 #include "components/image_fetcher/image_fetcher_impl.h" |
| 29 #include "components/keyed_service/content/browser_context_dependency_manager.h" | 29 #include "components/keyed_service/content/browser_context_dependency_manager.h" |
| 30 #include "components/keyed_service/core/service_access_type.h" | 30 #include "components/keyed_service/core/service_access_type.h" |
| 31 #include "components/ntp_snippets/bookmarks/bookmark_suggestions_provider.h" | 31 #include "components/ntp_snippets/bookmarks/bookmark_suggestions_provider.h" |
| 32 #include "components/ntp_snippets/category_rankers/constant_category_ranker.h" | 32 #include "components/ntp_snippets/category_rankers/category_ranker.h" |
| 33 #include "components/ntp_snippets/content_suggestions_service.h" | 33 #include "components/ntp_snippets/content_suggestions_service.h" |
| 34 #include "components/ntp_snippets/features.h" | 34 #include "components/ntp_snippets/features.h" |
| 35 #include "components/ntp_snippets/ntp_snippets_constants.h" | 35 #include "components/ntp_snippets/ntp_snippets_constants.h" |
| 36 #include "components/ntp_snippets/remote/ntp_snippets_fetcher.h" | 36 #include "components/ntp_snippets/remote/ntp_snippets_fetcher.h" |
| 37 #include "components/ntp_snippets/remote/persistent_scheduler.h" | 37 #include "components/ntp_snippets/remote/persistent_scheduler.h" |
| 38 #include "components/ntp_snippets/remote/remote_suggestions_database.h" | 38 #include "components/ntp_snippets/remote/remote_suggestions_database.h" |
| 39 #include "components/ntp_snippets/remote/remote_suggestions_provider_impl.h" | 39 #include "components/ntp_snippets/remote/remote_suggestions_provider_impl.h" |
| 40 #include "components/ntp_snippets/remote/remote_suggestions_status_service.h" | 40 #include "components/ntp_snippets/remote/remote_suggestions_status_service.h" |
| 41 #include "components/ntp_snippets/remote/scheduling_remote_suggestions_provider.
h" | 41 #include "components/ntp_snippets/remote/scheduling_remote_suggestions_provider.
h" |
| 42 #include "components/ntp_snippets/sessions/foreign_sessions_suggestions_provider
.h" | 42 #include "components/ntp_snippets/sessions/foreign_sessions_suggestions_provider
.h" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 69 using offline_pages::OfflinePageModel; | 69 using offline_pages::OfflinePageModel; |
| 70 using offline_pages::OfflinePageModelFactory; | 70 using offline_pages::OfflinePageModelFactory; |
| 71 using physical_web::PhysicalWebDataSource; | 71 using physical_web::PhysicalWebDataSource; |
| 72 #endif // OS_ANDROID | 72 #endif // OS_ANDROID |
| 73 | 73 |
| 74 using bookmarks::BookmarkModel; | 74 using bookmarks::BookmarkModel; |
| 75 using content::BrowserThread; | 75 using content::BrowserThread; |
| 76 using history::HistoryService; | 76 using history::HistoryService; |
| 77 using image_fetcher::ImageFetcherImpl; | 77 using image_fetcher::ImageFetcherImpl; |
| 78 using ntp_snippets::BookmarkSuggestionsProvider; | 78 using ntp_snippets::BookmarkSuggestionsProvider; |
| 79 using ntp_snippets::CategoryRanker; |
| 79 using ntp_snippets::ContentSuggestionsService; | 80 using ntp_snippets::ContentSuggestionsService; |
| 80 using ntp_snippets::ForeignSessionsSuggestionsProvider; | 81 using ntp_snippets::ForeignSessionsSuggestionsProvider; |
| 81 using ntp_snippets::NTPSnippetsFetcher; | 82 using ntp_snippets::NTPSnippetsFetcher; |
| 82 using ntp_snippets::PersistentScheduler; | 83 using ntp_snippets::PersistentScheduler; |
| 83 using ntp_snippets::RemoteSuggestionsDatabase; | 84 using ntp_snippets::RemoteSuggestionsDatabase; |
| 84 using ntp_snippets::RemoteSuggestionsProviderImpl; | 85 using ntp_snippets::RemoteSuggestionsProviderImpl; |
| 85 using ntp_snippets::RemoteSuggestionsStatusService; | 86 using ntp_snippets::RemoteSuggestionsStatusService; |
| 86 using ntp_snippets::SchedulingRemoteSuggestionsProvider; | 87 using ntp_snippets::SchedulingRemoteSuggestionsProvider; |
| 87 using ntp_snippets::TabDelegateSyncAdapter; | 88 using ntp_snippets::TabDelegateSyncAdapter; |
| 88 using suggestions::ImageDecoderImpl; | 89 using suggestions::ImageDecoderImpl; |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 // Create the ContentSuggestionsService. | 246 // Create the ContentSuggestionsService. |
| 246 State state = | 247 State state = |
| 247 base::FeatureList::IsEnabled(ntp_snippets::kContentSuggestionsFeature) | 248 base::FeatureList::IsEnabled(ntp_snippets::kContentSuggestionsFeature) |
| 248 ? State::ENABLED | 249 ? State::ENABLED |
| 249 : State::DISABLED; | 250 : State::DISABLED; |
| 250 SigninManagerBase* signin_manager = | 251 SigninManagerBase* signin_manager = |
| 251 SigninManagerFactory::GetForProfile(profile); | 252 SigninManagerFactory::GetForProfile(profile); |
| 252 HistoryService* history_service = HistoryServiceFactory::GetForProfile( | 253 HistoryService* history_service = HistoryServiceFactory::GetForProfile( |
| 253 profile, ServiceAccessType::EXPLICIT_ACCESS); | 254 profile, ServiceAccessType::EXPLICIT_ACCESS); |
| 254 PrefService* pref_service = profile->GetPrefs(); | 255 PrefService* pref_service = profile->GetPrefs(); |
| 255 auto category_ranker = | 256 std::unique_ptr<CategoryRanker> category_ranker = |
| 256 base::MakeUnique<ntp_snippets::ConstantCategoryRanker>(); | 257 ntp_snippets::BuildSelectedCategoryRanker(pref_service); |
| 257 auto* service = | 258 auto* service = |
| 258 new ContentSuggestionsService(state, signin_manager, history_service, | 259 new ContentSuggestionsService(state, signin_manager, history_service, |
| 259 pref_service, std::move(category_ranker)); | 260 pref_service, std::move(category_ranker)); |
| 260 if (state == State::DISABLED) { | 261 if (state == State::DISABLED) { |
| 261 // Since we won't initialise the services, they won't get a chance to | 262 // Since we won't initialise the services, they won't get a chance to |
| 262 // unschedule their tasks. We do it explicitly here instead. | 263 // unschedule their tasks. We do it explicitly here instead. |
| 263 ClearScheduledTasks(); | 264 ClearScheduledTasks(); |
| 264 return service; | 265 return service; |
| 265 } | 266 } |
| 266 | 267 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 318 language_model, pref_service, profile); | 319 language_model, pref_service, profile); |
| 319 } | 320 } |
| 320 | 321 |
| 321 if (base::FeatureList::IsEnabled( | 322 if (base::FeatureList::IsEnabled( |
| 322 ntp_snippets::kForeignSessionsSuggestionsFeature)) { | 323 ntp_snippets::kForeignSessionsSuggestionsFeature)) { |
| 323 RegisterForeignSessionsProvider(sync_service, service, pref_service); | 324 RegisterForeignSessionsProvider(sync_service, service, pref_service); |
| 324 } | 325 } |
| 325 | 326 |
| 326 return service; | 327 return service; |
| 327 } | 328 } |
| OLD | NEW |