OLD | NEW |
(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_snippets/ntp_snippets_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/profile.h" |
| 11 #include "components/keyed_service/content/browser_context_dependency_manager.h" |
| 12 #include "components/ntp_snippets/ntp_snippets_service.h" |
| 13 #include "content/public/browser/browser_context.h" |
| 14 |
| 15 // static |
| 16 NTPSnippetsServiceFactory* NTPSnippetsServiceFactory::GetInstance() { |
| 17 return base::Singleton<NTPSnippetsServiceFactory>::get(); |
| 18 } |
| 19 |
| 20 // static |
| 21 ntp_snippets::NTPSnippetsService* NTPSnippetsServiceFactory::GetForProfile( |
| 22 Profile* profile) { |
| 23 DCHECK(!profile->IsOffTheRecord()); |
| 24 return static_cast<ntp_snippets::NTPSnippetsService*>( |
| 25 GetInstance()->GetServiceForBrowserContext(profile, true)); |
| 26 } |
| 27 |
| 28 NTPSnippetsServiceFactory::NTPSnippetsServiceFactory() |
| 29 : BrowserContextKeyedServiceFactory( |
| 30 "NTPSnippetsService", |
| 31 BrowserContextDependencyManager::GetInstance()) {} |
| 32 |
| 33 NTPSnippetsServiceFactory::~NTPSnippetsServiceFactory() {} |
| 34 |
| 35 KeyedService* NTPSnippetsServiceFactory::BuildServiceInstanceFor( |
| 36 content::BrowserContext* context) const { |
| 37 return new ntp_snippets::NTPSnippetsService( |
| 38 g_browser_process->GetApplicationLocale()); |
| 39 } |
OLD | NEW |