Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(93)

Unified Diff: chrome/browser/ntp_snippets/content_suggestions_service_factory.cc

Issue 2686053002: Don't instantiate ContentSuggestionsService on non-Android (Closed)
Patch Set: Add browsertest Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/ntp_snippets/content_suggestions_service_factory_browsertest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 903d743053999085c3735f64373deed816a0cc5f..87cc2830272571b6a1614bec43d1bf49231bf018 100644
--- a/chrome/browser/ntp_snippets/content_suggestions_service_factory.cc
+++ b/chrome/browser/ntp_snippets/content_suggestions_service_factory.cc
@@ -95,6 +95,18 @@ using suggestions::ImageDecoderImpl;
using syncer::SyncService;
using translate::LanguageModel;
+// For now, ContentSuggestionsService must only be instantiated on Android.
+// See also crbug.com/688366.
+#if defined(OS_ANDROID)
+#define CONTENT_SUGGESTIONS_ENABLED 1
+#else
+#define CONTENT_SUGGESTIONS_ENABLED 0
+#endif // OS_ANDROID
+
+// The actual #if that does the work is below in BuildServiceInstanceFor. This
+// one is just required to avoid "unused code" compiler errors.
+#if CONTENT_SUGGESTIONS_ENABLED
+
namespace {
#if defined(OS_ANDROID)
@@ -124,6 +136,7 @@ void RegisterDownloadsProvider(OfflinePageModel* offline_page_model,
pref_service, base::MakeUnique<base::DefaultClock>());
service->RegisterProvider(std::move(provider));
}
+
#endif // OS_ANDROID
void RegisterBookmarkProvider(BookmarkModel* bookmark_model,
@@ -150,6 +163,7 @@ void RegisterPhysicalWebPageProvider(
service, physical_web_data_source, pref_service);
service->RegisterProvider(std::move(provider));
}
+
#endif // OS_ANDROID
void RegisterArticleProvider(SigninManagerBase* signin_manager,
@@ -213,6 +227,8 @@ void RegisterForeignSessionsProvider(SyncService* sync_service,
} // namespace
+#endif // CONTENT_SUGGESTIONS_ENABLED
+
// static
ContentSuggestionsServiceFactory*
ContentSuggestionsServiceFactory::GetInstance() {
@@ -251,6 +267,8 @@ ContentSuggestionsServiceFactory::~ContentSuggestionsServiceFactory() = default;
KeyedService* ContentSuggestionsServiceFactory::BuildServiceInstanceFor(
content::BrowserContext* context) const {
+#if CONTENT_SUGGESTIONS_ENABLED
+
using State = ContentSuggestionsService::State;
Profile* profile = Profile::FromBrowserContext(context);
DCHECK(!profile->IsOffTheRecord());
@@ -329,4 +347,8 @@ KeyedService* ContentSuggestionsServiceFactory::BuildServiceInstanceFor(
}
return service;
+
+#else
+ return nullptr;
+#endif // CONTENT_SUGGESTIONS_ENABLED
}
« no previous file with comments | « no previous file | chrome/browser/ntp_snippets/content_suggestions_service_factory_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698