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

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

Issue 2606753002: Post notification after fetching articles (Closed)
Patch Set: Add TODO. Created 3 years, 11 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_notifier_service_facto ry.h"
6
7 #include "base/memory/ptr_util.h"
8 #include "base/memory/singleton.h"
9 #include "chrome/browser/ntp_snippets/content_suggestions_service_factory.h"
10 #include "chrome/browser/ntp_snippets/ntp_snippets_features.h"
11 #include "chrome/browser/profiles/profile.h"
12 #include "components/keyed_service/content/browser_context_dependency_manager.h"
13 #include "components/variations/variations_associated_data.h"
14
15 #if defined(OS_ANDROID)
16 #include "chrome/browser/android/ntp/content_suggestions_notifier_service.h"
17 #endif
18
19 ContentSuggestionsNotifierServiceFactory*
20 ContentSuggestionsNotifierServiceFactory::GetInstance() {
21 return base::Singleton<ContentSuggestionsNotifierServiceFactory>::get();
22 }
23
24 ContentSuggestionsNotifierService*
25 ContentSuggestionsNotifierServiceFactory::GetForProfile(Profile* profile) {
26 #if defined(OS_ANDROID)
27 return static_cast<ContentSuggestionsNotifierService*>(
28 GetInstance()->GetServiceForBrowserContext(profile, true));
29 #else
30 return nullptr;
31 #endif
32 }
33
34 ContentSuggestionsNotifierService*
35 ContentSuggestionsNotifierServiceFactory::GetForProfileIfExists(
36 Profile* profile) {
37 #if defined(OS_ANDROID)
38 return static_cast<ContentSuggestionsNotifierService*>(
39 GetInstance()->GetServiceForBrowserContext(profile, false));
40 #else
41 return nullptr;
42 #endif
43 }
44
45 ContentSuggestionsNotifierServiceFactory::
46 ContentSuggestionsNotifierServiceFactory()
47 : BrowserContextKeyedServiceFactory(
48 "ContentSuggestionsNotifierService",
49 BrowserContextDependencyManager::GetInstance()) {
50 DependsOn(ContentSuggestionsServiceFactory::GetInstance());
51 }
52
53 ContentSuggestionsNotifierServiceFactory::
54 ~ContentSuggestionsNotifierServiceFactory() = default;
55
56 // BrowserContextKeyedServiceFactory implementation.
57 KeyedService* ContentSuggestionsNotifierServiceFactory::BuildServiceInstanceFor(
58 content::BrowserContext* context) const {
59 #if defined(OS_ANDROID)
60 if (base::FeatureList::IsEnabled(kContentSuggestionsNotificationsFeature)) {
61 Profile* profile = Profile::FromBrowserContext(context);
62 ntp_snippets::ContentSuggestionsService* suggestions =
63 ContentSuggestionsServiceFactory::GetForProfile(profile);
64 return new ContentSuggestionsNotifierService(profile, suggestions,
65 profile->GetPrefs());
66 }
67 #endif
68 return nullptr;
69 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698