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

Unified Diff: ios/chrome/browser/ntp_snippets/ios_chrome_content_suggestions_service_factory.cc

Issue 2194793004: Create IOSChromeContentSuggestionsServiceFactory (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove IOSChromeNTPSnippetsServiceFactory Created 4 years, 5 months 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_snippets/ios_chrome_content_suggestions_service_factory.cc
diff --git a/ios/chrome/browser/ntp_snippets/ios_chrome_content_suggestions_service_factory.cc b/ios/chrome/browser/ntp_snippets/ios_chrome_content_suggestions_service_factory.cc
new file mode 100644
index 0000000000000000000000000000000000000000..570aa9b0338b95fce540bc8ed8182876a0a248b1
--- /dev/null
+++ b/ios/chrome/browser/ntp_snippets/ios_chrome_content_suggestions_service_factory.cc
@@ -0,0 +1,43 @@
+// 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_snippets/ios_chrome_content_suggestions_service_factory.h"
+
+#include "base/memory/ptr_util.h"
+#include "base/memory/singleton.h"
+#include "components/keyed_service/ios/browser_state_dependency_manager.h"
+#include "components/ntp_snippets/content_suggestions_service.h"
+#include "ios/chrome/browser/browser_state/chrome_browser_state.h"
+#include "ios/web/public/browser_state.h"
+
+// static
+IOSChromeContentSuggestionsServiceFactory*
+IOSChromeContentSuggestionsServiceFactory::GetInstance() {
+ return base::Singleton<IOSChromeContentSuggestionsServiceFactory>::get();
+}
+
+// static
+ntp_snippets::ContentSuggestionsService*
+IOSChromeContentSuggestionsServiceFactory::GetForBrowserState(
+ ios::ChromeBrowserState* browser_state) {
+ DCHECK(!browser_state->IsOffTheRecord());
+ return static_cast<ntp_snippets::ContentSuggestionsService*>(
+ GetInstance()->GetServiceForBrowserState(browser_state, true));
+}
+
+IOSChromeContentSuggestionsServiceFactory::
+ IOSChromeContentSuggestionsServiceFactory()
+ : BrowserStateKeyedServiceFactory(
+ "ContentSuggestionsService",
+ BrowserStateDependencyManager::GetInstance()) {}
+
+IOSChromeContentSuggestionsServiceFactory::
+ ~IOSChromeContentSuggestionsServiceFactory() {}
+
+std::unique_ptr<KeyedService>
+IOSChromeContentSuggestionsServiceFactory::BuildServiceInstanceFor(
+ web::BrowserState* browser_state) const {
+ return base::WrapUnique(new ntp_snippets::ContentSuggestionsService(
+ ntp_snippets::ContentSuggestionsService::State::DISABLED));
+}

Powered by Google App Engine
This is Rietveld 408576698