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 "ios/chrome/browser/ntp_content/ntp_content_service_factory.h" |
| 6 |
| 7 #include "base/logging.h" |
| 8 #include "base/memory/singleton.h" |
| 9 #include "components/keyed_service/ios/browser_state_dependency_manager.h" |
| 10 #include "components/ntp_content/ntp_content_service.h" |
| 11 #include "ios/chrome/browser/application_context.h" |
| 12 #include "ios/chrome/browser/browser_state/browser_state_otr_helper.h" |
| 13 #include "ios/public/provider/chrome/browser/browser_state/chrome_browser_state.
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* NTPContentServiceFactory::GetForBrowserState( |
| 24 ios::ChromeBrowserState* browser_state) { |
| 25 return static_cast<NTPContentService*>( |
| 26 GetInstance()->GetServiceForBrowserState(browser_state, true)); |
| 27 } |
| 28 |
| 29 NTPContentServiceFactory::NTPContentServiceFactory() |
| 30 : BrowserStateKeyedServiceFactory( |
| 31 "NTPContentService", |
| 32 BrowserStateDependencyManager::GetInstance()) {} |
| 33 |
| 34 NTPContentServiceFactory::~NTPContentServiceFactory() {} |
| 35 |
| 36 scoped_ptr<KeyedService> NTPContentServiceFactory::BuildServiceInstanceFor( |
| 37 web::BrowserState* browser_state) const { |
| 38 DCHECK(!browser_state->IsOffTheRecord()); |
| 39 return make_scoped_ptr( |
| 40 new NTPContentService(GetApplicationContext()->GetApplicationLocale())); |
| 41 } |
| 42 |
| 43 web::BrowserState* NTPContentServiceFactory::GetBrowserStateToUse( |
| 44 web::BrowserState* context) const { |
| 45 return GetBrowserStateRedirectedInIncognito(context); |
| 46 } |
| 47 |
| 48 } // namespace ntp_content |
OLD | NEW |