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

Unified Diff: chrome/browser/history/top_sites_factory.cc

Issue 815983002: Topsites become keyedService based. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove extra inclusion from testing_profile.h Created 5 years, 11 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
« no previous file with comments | « chrome/browser/history/top_sites_factory.h ('k') | chrome/browser/history/top_sites_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/history/top_sites_factory.cc
diff --git a/chrome/browser/history/top_sites_factory.cc b/chrome/browser/history/top_sites_factory.cc
new file mode 100644
index 0000000000000000000000000000000000000000..b0e77b55ee94eb28289c986fa513eafb6cd28dba
--- /dev/null
+++ b/chrome/browser/history/top_sites_factory.cc
@@ -0,0 +1,51 @@
+// 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/history/top_sites_factory.h"
+
+#include "base/memory/singleton.h"
+#include "chrome/browser/history/top_sites_impl.h"
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/common/chrome_constants.h"
+#include "components/keyed_service/content/browser_context_dependency_manager.h"
+
+// static
+scoped_refptr<history::TopSites> TopSitesFactory::GetForProfile(
+ Profile* profile) {
+ return static_cast<history::TopSites*>(
+ GetInstance()->GetServiceForBrowserContext(profile, true).get());
+}
+
+// static
+scoped_refptr<history::TopSites> TopSitesFactory::GetForProfileIfExists(
+ Profile* profile) {
+ return static_cast<history::TopSites*>(
+ GetInstance()->GetServiceForBrowserContext(profile, false).get());
+}
+
+// static
+TopSitesFactory* TopSitesFactory::GetInstance() {
+ return Singleton<TopSitesFactory>::get();
+}
+
+TopSitesFactory::TopSitesFactory()
+ : RefcountedBrowserContextKeyedServiceFactory(
+ "TopSites",
+ BrowserContextDependencyManager::GetInstance()) {
+}
+
+TopSitesFactory::~TopSitesFactory() {
+}
+
+scoped_refptr<RefcountedKeyedService> TopSitesFactory::BuildServiceInstanceFor(
+ content::BrowserContext* context) const {
+ history::TopSitesImpl* top_sites =
+ new history::TopSitesImpl(static_cast<Profile*>(context));
+ top_sites->Init(context->GetPath().Append(chrome::kTopSitesFilename));
+ return make_scoped_refptr(top_sites);
+}
+
+bool TopSitesFactory::ServiceIsNULLWhileTesting() const {
+ return true;
+}
« no previous file with comments | « chrome/browser/history/top_sites_factory.h ('k') | chrome/browser/history/top_sites_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698