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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/history/top_sites_factory.h"
6
7 #include "base/memory/singleton.h"
8 #include "chrome/browser/history/top_sites_impl.h"
9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/common/chrome_constants.h"
11 #include "components/keyed_service/content/browser_context_dependency_manager.h"
12
13 // static
14 scoped_refptr<history::TopSites> TopSitesFactory::GetForProfile(
15 Profile* profile) {
16 return static_cast<history::TopSites*>(
17 GetInstance()->GetServiceForBrowserContext(profile, true).get());
18 }
19
20 // static
21 scoped_refptr<history::TopSites> TopSitesFactory::GetForProfileIfExists(
22 Profile* profile) {
23 return static_cast<history::TopSites*>(
24 GetInstance()->GetServiceForBrowserContext(profile, false).get());
25 }
26
27 // static
28 TopSitesFactory* TopSitesFactory::GetInstance() {
29 return Singleton<TopSitesFactory>::get();
30 }
31
32 TopSitesFactory::TopSitesFactory()
33 : RefcountedBrowserContextKeyedServiceFactory(
34 "TopSites",
35 BrowserContextDependencyManager::GetInstance()) {
36 }
37
38 TopSitesFactory::~TopSitesFactory() {
39 }
40
41 scoped_refptr<RefcountedKeyedService> TopSitesFactory::BuildServiceInstanceFor(
42 content::BrowserContext* context) const {
43 history::TopSitesImpl* top_sites =
44 new history::TopSitesImpl(static_cast<Profile*>(context));
45 top_sites->Init(context->GetPath().Append(chrome::kTopSitesFilename));
46 return make_scoped_refptr(top_sites);
47 }
48
49 bool TopSitesFactory::ServiceIsNULLWhileTesting() const {
50 return true;
51 }
OLDNEW
« 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