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

Side by Side Diff: chrome/browser/ntp_suggestions/ntp_suggestions_service_factory.cc

Issue 1438043008: Creating the NTP snippet service. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years, 1 month 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 2015 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_suggestions/ntp_suggestions_service_factory.h"
6
7 #include "base/logging.h"
8 #include "base/memory/singleton.h"
9 #include "chrome/browser/browser_process.h"
10 #include "chrome/browser/profiles/incognito_helpers.h"
11 #include "components/keyed_service/content/browser_context_dependency_manager.h"
12 #include "components/ntp_suggestions/ntp_suggestions_service.h"
13 #include "content/public/browser/browser_context.h"
14
15 // static
16 NTPSuggestionsServiceFactory* NTPSuggestionsServiceFactory::GetInstance() {
17 return base::Singleton<NTPSuggestionsServiceFactory>::get();
18 }
19
20 // static
21 ntp_suggestions::NTPSuggestionsService*
22 NTPSuggestionsServiceFactory::GetForBrowserContext(
23 content::BrowserContext* context) {
24 DCHECK(!context->IsOffTheRecord());
sdefresne 2015/11/17 13:57:29 nit: The default implementation of BrowserContextK
noyau (Ping after 24h) 2015/11/17 17:00:33 I prefer a crash rather than a null that needs to
25 return static_cast<ntp_suggestions::NTPSuggestionsService*>(
26 GetInstance()->GetServiceForBrowserContext(context, true));
27 }
28
29 NTPSuggestionsServiceFactory::NTPSuggestionsServiceFactory()
30 : BrowserContextKeyedServiceFactory(
31 "NTPSuggestionsService",
32 BrowserContextDependencyManager::GetInstance()) {}
33
34 NTPSuggestionsServiceFactory::~NTPSuggestionsServiceFactory() {}
35
36 KeyedService* NTPSuggestionsServiceFactory::BuildServiceInstanceFor(
37 content::BrowserContext* context) const {
38 DCHECK(!context->IsOffTheRecord());
sdefresne 2015/11/17 13:57:29 Remove this DCHECK, it is useless.
noyau (Ping after 24h) 2015/11/17 17:00:33 Done.
39 return new ntp_suggestions::NTPSuggestionsService(
40 g_browser_process->GetApplicationLocale());
41 }
42
43 content::BrowserContext* NTPSuggestionsServiceFactory::GetBrowserContextToUse(
44 content::BrowserContext* context) const {
45 return chrome::GetBrowserContextRedirectedInIncognito(context);
sdefresne 2015/11/17 13:57:29 By default BrowserContextKeyedServiceFactory will
noyau (Ping after 24h) 2015/11/17 17:00:33 Done.
46 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698