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

Unified Diff: ios/chrome/browser/ntp_content/ntp_content_service_factory.cc

Issue 1438043008: Creating the NTP snippet service. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixing compile on non-ios platforms (ooops!) 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 side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698