Index: ios/chrome/browser/ntp_content/ntp_content_service_factory.cc |
diff --git a/ios/chrome/browser/ntp_content/ntp_content_service_factory.cc b/ios/chrome/browser/ntp_content/ntp_content_service_factory.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..6d26b188f905bae2b138c8a72e26483e7115809c |
--- /dev/null |
+++ b/ios/chrome/browser/ntp_content/ntp_content_service_factory.cc |
@@ -0,0 +1,48 @@ |
+// Copyright 2015 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "ios/chrome/browser/ntp_content/ntp_content_service_factory.h" |
+ |
+#include "base/logging.h" |
+#include "base/memory/singleton.h" |
+#include "components/keyed_service/ios/browser_state_dependency_manager.h" |
+#include "components/ntp_content/ntp_content_service.h" |
+#include "ios/chrome/browser/application_context.h" |
+#include "ios/chrome/browser/browser_state/browser_state_otr_helper.h" |
+#include "ios/public/provider/chrome/browser/browser_state/chrome_browser_state.h" |
+ |
+namespace ntp_content { |
+ |
+// static |
+NTPContentServiceFactory* NTPContentServiceFactory::GetInstance() { |
+ return base::Singleton<NTPContentServiceFactory>::get(); |
+} |
+ |
+// static |
+NTPContentService* NTPContentServiceFactory::GetForBrowserState( |
+ ios::ChromeBrowserState* browser_state) { |
+ return static_cast<NTPContentService*>( |
+ GetInstance()->GetServiceForBrowserState(browser_state, true)); |
+} |
+ |
+NTPContentServiceFactory::NTPContentServiceFactory() |
+ : BrowserStateKeyedServiceFactory( |
+ "NTPContentService", |
+ BrowserStateDependencyManager::GetInstance()) {} |
+ |
+NTPContentServiceFactory::~NTPContentServiceFactory() {} |
+ |
+scoped_ptr<KeyedService> NTPContentServiceFactory::BuildServiceInstanceFor( |
+ web::BrowserState* browser_state) const { |
+ DCHECK(!browser_state->IsOffTheRecord()); |
+ return make_scoped_ptr( |
+ new NTPContentService(GetApplicationContext()->GetApplicationLocale())); |
+} |
+ |
+web::BrowserState* NTPContentServiceFactory::GetBrowserStateToUse( |
+ web::BrowserState* context) const { |
+ return GetBrowserStateRedirectedInIncognito(context); |
+} |
+ |
+} // namespace ntp_content |