Index: chrome/browser/ntp_snippets/content_suggestions_service_factory.cc |
diff --git a/chrome/browser/ntp_snippets/content_suggestions_service_factory.cc b/chrome/browser/ntp_snippets/content_suggestions_service_factory.cc |
index 6d029c47a7cc420b154823f9b73b8256e72451b2..e3e2481e401335a5bdff1f134c1ccae8660b6ac2 100644 |
--- a/chrome/browser/ntp_snippets/content_suggestions_service_factory.cc |
+++ b/chrome/browser/ntp_snippets/content_suggestions_service_factory.cc |
@@ -47,6 +47,7 @@ |
#include "components/ntp_snippets/sessions/foreign_sessions_suggestions_provider.h" |
#include "components/ntp_snippets/sessions/tab_delegate_sync_adapter.h" |
#include "components/ntp_snippets/user_classifier.h" |
+#include "components/offline_pages/features/features.h" |
#include "components/prefs/pref_service.h" |
#include "components/safe_json/safe_json_parser.h" |
#include "components/signin/core/browser/profile_oauth2_token_service.h" |
@@ -62,30 +63,35 @@ |
#if defined(OS_ANDROID) |
#include "chrome/browser/android/chrome_feature_list.h" |
#include "chrome/browser/android/ntp/ntp_snippets_launcher.h" |
-#include "chrome/browser/android/offline_pages/offline_page_model_factory.h" |
-#include "chrome/browser/android/offline_pages/request_coordinator_factory.h" |
#include "chrome/browser/download/download_core_service.h" |
#include "chrome/browser/download/download_core_service_factory.h" |
#include "chrome/browser/download/download_history.h" |
#include "chrome/browser/ntp_snippets/download_suggestions_provider.h" |
-#include "components/ntp_snippets/offline_pages/recent_tab_suggestions_provider.h" |
#include "components/ntp_snippets/physical_web_pages/physical_web_page_suggestions_provider.h" |
-#include "components/offline_pages/content/suggested_articles_observer.h" |
+#include "components/physical_web/data_source/physical_web_data_source.h" |
+ |
+using content::DownloadManager; |
+using ntp_snippets::PhysicalWebPageSuggestionsProvider; |
+using physical_web::PhysicalWebDataSource; |
+#endif // OS_ANDROID |
+ |
+#if BUILDFLAG(ENABLE_OFFLINE_PAGES) |
Bernhard Bauer
2017/05/18 19:11:31
Nit: If you're touching this code anyway, I would
dewittj
2017/05/22 22:00:08
Done.
|
+#include "chrome/browser/android/offline_pages/offline_page_model_factory.h" |
+#include "chrome/browser/android/offline_pages/request_coordinator_factory.h" |
+#include "chrome/browser/offline_pages/prefetch/prefetch_service_factory.h" |
+#include "components/ntp_snippets/offline_pages/recent_tab_suggestions_provider.h" |
#include "components/offline_pages/core/background/request_coordinator.h" |
#include "components/offline_pages/core/offline_page_feature.h" |
#include "components/offline_pages/core/offline_page_model.h" |
+#include "components/offline_pages/core/prefetch/suggested_articles_observer.h" |
#include "components/offline_pages/core/recent_tabs/recent_tabs_ui_adapter_delegate.h" |
-#include "components/physical_web/data_source/physical_web_data_source.h" |
-using content::DownloadManager; |
-using ntp_snippets::PhysicalWebPageSuggestionsProvider; |
using ntp_snippets::RecentTabSuggestionsProvider; |
using offline_pages::OfflinePageModel; |
using offline_pages::RequestCoordinator; |
using offline_pages::OfflinePageModelFactory; |
using offline_pages::RequestCoordinatorFactory; |
-using physical_web::PhysicalWebDataSource; |
-#endif // OS_ANDROID |
+#endif // BUILDFLAG(ENABLE_OFFLINE_PAGES) |
using bookmarks::BookmarkModel; |
using content::BrowserThread; |
@@ -130,7 +136,7 @@ bool IsChromeHomeEnabled() { |
#endif |
} |
-#if defined(OS_ANDROID) |
+#if BUILDFLAG(ENABLE_OFFLINE_PAGES) |
bool IsRecentTabProviderEnabled() { |
return base::FeatureList::IsEnabled( |
@@ -151,6 +157,10 @@ void RegisterRecentTabProvider(OfflinePageModel* offline_page_model, |
service->RegisterProvider(std::move(provider)); |
} |
+#endif // BUILDFLAG(ENABLE_OFFLINE_PAGES) |
+ |
+#if defined(OS_ANDROID) |
+ |
void RegisterDownloadsProvider(OfflinePageModel* offline_page_model, |
DownloadManager* download_manager, |
DownloadHistory* download_history, |
@@ -286,9 +296,10 @@ ContentSuggestionsServiceFactory::ContentSuggestionsServiceFactory() |
DependsOn(BookmarkModelFactory::GetInstance()); |
DependsOn(HistoryServiceFactory::GetInstance()); |
DependsOn(LargeIconServiceFactory::GetInstance()); |
-#if defined(OS_ANDROID) |
+#if BUILDFLAG(ENABLE_OFFLINE_PAGES) |
DependsOn(OfflinePageModelFactory::GetInstance()); |
-#endif // OS_ANDROID |
+ DependsOn(offline_pages::PrefetchServiceFactory::GetInstance()); |
+#endif // BUILDFLAG(ENABLE_OFFLINE_PAGES) |
DependsOn(ProfileOAuth2TokenServiceFactory::GetInstance()); |
DependsOn(ProfileSyncServiceFactory::GetInstance()); |
DependsOn(SigninManagerFactory::GetInstance()); |
@@ -333,7 +344,7 @@ KeyedService* ContentSuggestionsServiceFactory::BuildServiceInstanceFor( |
pref_service, std::move(category_ranker), std::move(user_classifier), |
std::move(scheduler)); |
-#if defined(OS_ANDROID) |
+#if BUILDFLAG(ENABLE_OFFLINE_PAGES) |
OfflinePageModel* offline_page_model = |
OfflinePageModelFactory::GetForBrowserContext(profile); |
if (IsRecentTabProviderEnabled()) { |
@@ -343,6 +354,12 @@ KeyedService* ContentSuggestionsServiceFactory::BuildServiceInstanceFor( |
pref_service); |
} |
+ offline_pages::PrefetchService* prefetch_service = |
+ offline_pages::PrefetchServiceFactory::GetForBrowserContext(profile); |
+ prefetch_service->ObserveContentSuggestionsService(service); |
+#endif // BUILDFLAG(ENABLE_OFFLINE_PAGES) |
+ |
+#if defined(OS_ANDROID) |
bool show_asset_downloads = |
!IsChromeHomeEnabled() && |
base::FeatureList::IsEnabled(features::kAssetDownloadSuggestionsFeature); |
@@ -362,9 +379,6 @@ KeyedService* ContentSuggestionsServiceFactory::BuildServiceInstanceFor( |
show_asset_downloads ? download_manager : nullptr, download_history, |
service, pref_service); |
} |
- |
- offline_pages::SuggestedArticlesObserver::ObserveContentSuggestionsService( |
- profile, service); |
#endif // OS_ANDROID |
// |bookmark_model| can be null in tests. |