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 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 PrefService* pref_service) { | 158 PrefService* pref_service) { |
159 auto provider = base::MakeUnique<DownloadSuggestionsProvider>( | 159 auto provider = base::MakeUnique<DownloadSuggestionsProvider>( |
160 service, offline_page_model, download_manager, download_history, | 160 service, offline_page_model, download_manager, download_history, |
161 pref_service, base::MakeUnique<base::DefaultClock>()); | 161 pref_service, base::MakeUnique<base::DefaultClock>()); |
162 service->RegisterProvider(std::move(provider)); | 162 service->RegisterProvider(std::move(provider)); |
163 } | 163 } |
164 | 164 |
165 #endif // OS_ANDROID | 165 #endif // OS_ANDROID |
166 | 166 |
167 void RegisterBookmarkProvider(BookmarkModel* bookmark_model, | 167 void RegisterBookmarkProvider(BookmarkModel* bookmark_model, |
168 ContentSuggestionsService* service, | 168 ContentSuggestionsService* service) { |
169 PrefService* pref_service) { | 169 auto provider = |
170 auto provider = base::MakeUnique<BookmarkSuggestionsProvider>( | 170 base::MakeUnique<BookmarkSuggestionsProvider>(service, bookmark_model); |
171 service, bookmark_model, pref_service); | |
172 service->RegisterProvider(std::move(provider)); | 171 service->RegisterProvider(std::move(provider)); |
173 } | 172 } |
174 | 173 |
175 #if defined(OS_ANDROID) | 174 #if defined(OS_ANDROID) |
176 | 175 |
177 bool IsPhysicalWebPageProviderEnabled() { | 176 bool IsPhysicalWebPageProviderEnabled() { |
178 return base::FeatureList::IsEnabled( | 177 return base::FeatureList::IsEnabled( |
179 ntp_snippets::kPhysicalWebPageSuggestionsFeature) && | 178 ntp_snippets::kPhysicalWebPageSuggestionsFeature) && |
180 base::FeatureList::IsEnabled(chrome::android::kPhysicalWebFeature); | 179 base::FeatureList::IsEnabled(chrome::android::kPhysicalWebFeature); |
181 } | 180 } |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
365 | 364 |
366 offline_pages::SuggestedArticlesObserver::ObserveContentSuggestionsService( | 365 offline_pages::SuggestedArticlesObserver::ObserveContentSuggestionsService( |
367 profile, service); | 366 profile, service); |
368 #endif // OS_ANDROID | 367 #endif // OS_ANDROID |
369 | 368 |
370 // |bookmark_model| can be null in tests. | 369 // |bookmark_model| can be null in tests. |
371 BookmarkModel* bookmark_model = | 370 BookmarkModel* bookmark_model = |
372 BookmarkModelFactory::GetForBrowserContext(profile); | 371 BookmarkModelFactory::GetForBrowserContext(profile); |
373 if (base::FeatureList::IsEnabled(ntp_snippets::kBookmarkSuggestionsFeature) && | 372 if (base::FeatureList::IsEnabled(ntp_snippets::kBookmarkSuggestionsFeature) && |
374 bookmark_model && !IsChromeHomeEnabled()) { | 373 bookmark_model && !IsChromeHomeEnabled()) { |
375 RegisterBookmarkProvider(bookmark_model, service, pref_service); | 374 RegisterBookmarkProvider(bookmark_model, service); |
376 } | 375 } |
377 | 376 |
378 #if defined(OS_ANDROID) | 377 #if defined(OS_ANDROID) |
379 if (IsPhysicalWebPageProviderEnabled()) { | 378 if (IsPhysicalWebPageProviderEnabled()) { |
380 PhysicalWebDataSource* physical_web_data_source = | 379 PhysicalWebDataSource* physical_web_data_source = |
381 g_browser_process->GetPhysicalWebDataSource(); | 380 g_browser_process->GetPhysicalWebDataSource(); |
382 RegisterPhysicalWebPageProvider(service, physical_web_data_source, | 381 RegisterPhysicalWebPageProvider(service, physical_web_data_source, |
383 pref_service); | 382 pref_service); |
384 } | 383 } |
385 #endif // OS_ANDROID | 384 #endif // OS_ANDROID |
(...skipping 14 matching lines...) Expand all Loading... |
400 ProfileSyncServiceFactory::GetSyncServiceForBrowserContext(profile); | 399 ProfileSyncServiceFactory::GetSyncServiceForBrowserContext(profile); |
401 RegisterForeignSessionsProvider(sync_service, service, pref_service); | 400 RegisterForeignSessionsProvider(sync_service, service, pref_service); |
402 } | 401 } |
403 | 402 |
404 return service; | 403 return service; |
405 | 404 |
406 #else | 405 #else |
407 return nullptr; | 406 return nullptr; |
408 #endif // CONTENT_SUGGESTIONS_ENABLED | 407 #endif // CONTENT_SUGGESTIONS_ENABLED |
409 } | 408 } |
OLD | NEW |