OLD | NEW |
(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/common/chrome_constants.h" |
| 10 #include "components/keyed_service/content/browser_context_dependency_manager.h" |
| 11 |
| 12 // static |
| 13 scoped_refptr<history::TopSites> TopSitesFactory::GetForProfile( |
| 14 Profile* profile) { |
| 15 return static_cast<history::TopSites*>( |
| 16 GetInstance()->GetServiceForBrowserContext(profile, true).get()); |
| 17 } |
| 18 |
| 19 // static |
| 20 scoped_refptr<history::TopSites> TopSitesFactory::GetForProfileIfExists( |
| 21 Profile* profile) { |
| 22 return static_cast<history::TopSites*>( |
| 23 GetInstance()->GetServiceForBrowserContext(profile, false).get()); |
| 24 } |
| 25 |
| 26 // static |
| 27 TopSitesFactory* TopSitesFactory::GetInstance() { |
| 28 return Singleton<TopSitesFactory>::get(); |
| 29 } |
| 30 |
| 31 scoped_refptr<RefcountedKeyedService> TopSitesFactory::BuildServiceInstanceFor( |
| 32 content::BrowserContext* context) const { |
| 33 history::TopSitesImpl* top_sites = |
| 34 new history::TopSitesImpl(static_cast<Profile*>(context)); |
| 35 top_sites->Init(context->GetPath().Append(chrome::kTopSitesFilename)); |
| 36 return make_scoped_refptr(top_sites); |
| 37 } |
| 38 |
| 39 bool TopSitesFactory::ServiceIsNULLWhileTesting() const { |
| 40 return true; |
| 41 } |
| 42 |
| 43 TopSitesFactory::TopSitesFactory() |
| 44 : RefcountedBrowserContextKeyedServiceFactory( |
| 45 "TopSites", |
| 46 BrowserContextDependencyManager::GetInstance()) { |
| 47 } |
| 48 |
| 49 TopSitesFactory::~TopSitesFactory() { |
| 50 } |
OLD | NEW |