Chromium Code Reviews| 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/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 // static | |
| 33 void TopSitesFactory::ShutdownForProfile(Profile* profile) { | |
|
sdefresne
2015/01/22 19:05:05
This is unused, remove.
Jitu( very slow this week)
2015/01/23 11:36:52
Done.
| |
| 34 TopSitesFactory* factory = GetInstance(); | |
| 35 factory->BrowserContextDestroyed(profile); | |
| 36 } | |
| 37 | |
| 38 scoped_refptr<RefcountedKeyedService> TopSitesFactory::BuildServiceInstanceFor( | |
| 39 content::BrowserContext* context) const { | |
| 40 history::TopSitesImpl* top_sites = | |
| 41 new history::TopSitesImpl(static_cast<Profile*>(context)); | |
| 42 top_sites->Init(context->GetPath().Append(chrome::kTopSitesFilename)); | |
| 43 return make_scoped_refptr(top_sites); | |
| 44 } | |
| 45 | |
| 46 bool TopSitesFactory::ServiceIsNULLWhileTesting() const { | |
| 47 return true; | |
| 48 } | |
| 49 | |
| 50 TopSitesFactory::TopSitesFactory() | |
| 51 : RefcountedBrowserContextKeyedServiceFactory( | |
| 52 "TopSites", | |
| 53 BrowserContextDependencyManager::GetInstance()) { | |
| 54 } | |
| 55 | |
| 56 TopSitesFactory::~TopSitesFactory() { | |
| 57 } | |
| OLD | NEW |