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_content/ntp_content_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_content/ntp_content_service.h" |
| 13 #include "content/public/browser/browser_context.h" |
| 14 |
| 15 namespace ntp_content { |
| 16 |
| 17 // static |
| 18 NTPContentServiceFactory* NTPContentServiceFactory::GetInstance() { |
| 19 return base::Singleton<NTPContentServiceFactory>::get(); |
| 20 } |
| 21 |
| 22 // static |
| 23 NTPContentService* |
| 24 NTPContentServiceFactory::GetForBrowserContext( |
| 25 content::BrowserContext* context) { |
| 26 DCHECK(!context->IsOffTheRecord()); |
| 27 return static_cast<NTPContentService*>( |
| 28 GetInstance()->GetServiceForBrowserContext(context, true)); |
| 29 } |
| 30 |
| 31 NTPContentServiceFactory::NTPContentServiceFactory() |
| 32 : BrowserContextKeyedServiceFactory( |
| 33 "NTPContentService", |
| 34 BrowserContextDependencyManager::GetInstance()) {} |
| 35 |
| 36 NTPContentServiceFactory::~NTPContentServiceFactory() {} |
| 37 |
| 38 KeyedService* NTPContentServiceFactory::BuildServiceInstanceFor( |
| 39 content::BrowserContext* context) const { |
| 40 DCHECK(!context->IsOffTheRecord()); |
| 41 return new NTPContentService(g_browser_process->GetApplicationLocale()); |
| 42 } |
| 43 |
| 44 content::BrowserContext* NTPContentServiceFactory::GetBrowserContextToUse( |
| 45 content::BrowserContext* context) const { |
| 46 return chrome::GetBrowserContextRedirectedInIncognito(context); |
| 47 } |
| 48 |
| 49 } // namespace ntp_content |
OLD | NEW |