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

Side by Side Diff: chrome/browser/ntp_snippets/content_suggestions_service_factory.cc

Issue 2102023002: Add ContentSuggestionsService (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Minor corrections Created 4 years, 5 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 unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/ntp_snippets/content_suggestions_service_factory.h"
6
7 #include "base/feature_list.h"
8 #include "base/memory/singleton.h"
9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/common/pref_names.h"
11 #include "components/keyed_service/content/browser_context_dependency_manager.h"
12 #include "components/ntp_snippets/content_suggestions_service.h"
13 #include "components/prefs/pref_service.h"
14 #include "content/public/browser/browser_context.h"
15
16 #if defined(OS_ANDROID)
17 #include "chrome/browser/android/chrome_feature_list.h"
18 #endif // OS_ANDROID
19
20 // static
21 ContentSuggestionsServiceFactory*
22 ContentSuggestionsServiceFactory::GetInstance() {
23 return base::Singleton<ContentSuggestionsServiceFactory>::get();
24 }
25
26 // static
27 ntp_snippets::ContentSuggestionsService*
28 ContentSuggestionsServiceFactory::GetForProfile(Profile* profile) {
29 DCHECK(!profile->IsOffTheRecord());
30 return static_cast<ntp_snippets::ContentSuggestionsService*>(
31 GetInstance()->GetServiceForBrowserContext(profile, true));
32 }
33
34 ContentSuggestionsServiceFactory::ContentSuggestionsServiceFactory()
35 : BrowserContextKeyedServiceFactory(
36 "ContentSuggestionsService",
37 BrowserContextDependencyManager::GetInstance()) {}
38
39 ContentSuggestionsServiceFactory::~ContentSuggestionsServiceFactory() {}
40
41 KeyedService* ContentSuggestionsServiceFactory::BuildServiceInstanceFor(
42 content::BrowserContext* context) const {
43 // TODO(mvanouwerkerk): Move the enable logic into the service once we start
44 // observing pref changes.
45 bool enabled = true;
46 #if defined(OS_ANDROID)
47 enabled = enabled &&
48 base::FeatureList::IsEnabled(chrome::android::kNTPSnippetsFeature);
Marc Treib 2016/06/30 10:36:53 Please add a TODO to split the feature.
Philipp Keck 2016/06/30 17:14:07 I added the TODO, a corresponding CL is already pr
49 #endif // OS_ANDROID
50
51 return new ntp_snippets::ContentSuggestionsService(enabled);
52 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698