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

Unified Diff: chrome/browser/ntp_snippets/ntp_snippets_service_factory.cc

Issue 1438043008: Creating the NTP snippet service. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase fix: Don't trust git. 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: chrome/browser/ntp_snippets/ntp_snippets_service_factory.cc
diff --git a/chrome/browser/ntp_snippets/ntp_snippets_service_factory.cc b/chrome/browser/ntp_snippets/ntp_snippets_service_factory.cc
new file mode 100644
index 0000000000000000000000000000000000000000..5730e2f68d6fbf5adf3eed3aafa47eda1201ae88
--- /dev/null
+++ b/chrome/browser/ntp_snippets/ntp_snippets_service_factory.cc
@@ -0,0 +1,39 @@
+// 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 "chrome/browser/ntp_snippets/ntp_snippets_service_factory.h"
+
+#include "base/logging.h"
+#include "base/memory/singleton.h"
+#include "chrome/browser/browser_process.h"
+#include "chrome/browser/profiles/profile.h"
+#include "components/keyed_service/content/browser_context_dependency_manager.h"
+#include "components/ntp_snippets/ntp_snippets_service.h"
+#include "content/public/browser/browser_context.h"
+
+// static
+NTPSnippetsServiceFactory* NTPSnippetsServiceFactory::GetInstance() {
+ return base::Singleton<NTPSnippetsServiceFactory>::get();
+}
+
+// static
+ntp_snippets::NTPSnippetsService* NTPSnippetsServiceFactory::GetForProfile(
+ Profile* profile) {
+ DCHECK(!profile->IsOffTheRecord());
+ return static_cast<ntp_snippets::NTPSnippetsService*>(
+ GetInstance()->GetServiceForBrowserContext(profile, true));
+}
+
+NTPSnippetsServiceFactory::NTPSnippetsServiceFactory()
+ : BrowserContextKeyedServiceFactory(
+ "NTPSnippetsService",
+ BrowserContextDependencyManager::GetInstance()) {}
+
+NTPSnippetsServiceFactory::~NTPSnippetsServiceFactory() {}
+
+KeyedService* NTPSnippetsServiceFactory::BuildServiceInstanceFor(
+ content::BrowserContext* context) const {
+ return new ntp_snippets::NTPSnippetsService(
+ g_browser_process->GetApplicationLocale());
+}

Powered by Google App Engine
This is Rietveld 408576698