| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/history/top_sites_factory.h" | 5 #include "chrome/browser/history/top_sites_factory.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 // static | 97 // static |
| 98 scoped_refptr<history::TopSites> TopSitesFactory::BuildTopSites( | 98 scoped_refptr<history::TopSites> TopSitesFactory::BuildTopSites( |
| 99 content::BrowserContext* context, | 99 content::BrowserContext* context, |
| 100 const std::vector<history::PrepopulatedPage>& prepopulated_page_list) { | 100 const std::vector<history::PrepopulatedPage>& prepopulated_page_list) { |
| 101 Profile* profile = Profile::FromBrowserContext(context); | 101 Profile* profile = Profile::FromBrowserContext(context); |
| 102 scoped_refptr<history::TopSitesImpl> top_sites(new history::TopSitesImpl( | 102 scoped_refptr<history::TopSitesImpl> top_sites(new history::TopSitesImpl( |
| 103 profile->GetPrefs(), HistoryServiceFactory::GetForProfile( | 103 profile->GetPrefs(), HistoryServiceFactory::GetForProfile( |
| 104 profile, ServiceAccessType::EXPLICIT_ACCESS), | 104 profile, ServiceAccessType::EXPLICIT_ACCESS), |
| 105 prepopulated_page_list, base::Bind(CanAddURLToHistory))); | 105 prepopulated_page_list, base::Bind(CanAddURLToHistory))); |
| 106 top_sites->Init(context->GetPath().Append(history::kTopSitesFilename), | 106 top_sites->Init(context->GetPath().Append(history::kTopSitesFilename), |
| 107 content::BrowserThread::GetMessageLoopProxyForThread( | 107 content::BrowserThread::GetTaskRunnerForThread( |
| 108 content::BrowserThread::DB)); | 108 content::BrowserThread::DB)); |
| 109 return top_sites; | 109 return top_sites; |
| 110 } | 110 } |
| 111 | 111 |
| 112 TopSitesFactory::TopSitesFactory() | 112 TopSitesFactory::TopSitesFactory() |
| 113 : RefcountedBrowserContextKeyedServiceFactory( | 113 : RefcountedBrowserContextKeyedServiceFactory( |
| 114 "TopSites", | 114 "TopSites", |
| 115 BrowserContextDependencyManager::GetInstance()) { | 115 BrowserContextDependencyManager::GetInstance()) { |
| 116 DependsOn(HistoryServiceFactory::GetInstance()); | 116 DependsOn(HistoryServiceFactory::GetInstance()); |
| 117 } | 117 } |
| 118 | 118 |
| 119 TopSitesFactory::~TopSitesFactory() { | 119 TopSitesFactory::~TopSitesFactory() { |
| 120 } | 120 } |
| 121 | 121 |
| 122 scoped_refptr<RefcountedKeyedService> TopSitesFactory::BuildServiceInstanceFor( | 122 scoped_refptr<RefcountedKeyedService> TopSitesFactory::BuildServiceInstanceFor( |
| 123 content::BrowserContext* context) const { | 123 content::BrowserContext* context) const { |
| 124 history::PrepopulatedPageList prepopulated_pages; | 124 history::PrepopulatedPageList prepopulated_pages; |
| 125 InitializePrepopulatedPageList(&prepopulated_pages); | 125 InitializePrepopulatedPageList(&prepopulated_pages); |
| 126 return BuildTopSites(context, prepopulated_pages); | 126 return BuildTopSites(context, prepopulated_pages); |
| 127 } | 127 } |
| 128 | 128 |
| 129 void TopSitesFactory::RegisterProfilePrefs( | 129 void TopSitesFactory::RegisterProfilePrefs( |
| 130 user_prefs::PrefRegistrySyncable* registry) { | 130 user_prefs::PrefRegistrySyncable* registry) { |
| 131 history::TopSitesImpl::RegisterPrefs(registry); | 131 history::TopSitesImpl::RegisterPrefs(registry); |
| 132 } | 132 } |
| 133 | 133 |
| 134 bool TopSitesFactory::ServiceIsNULLWhileTesting() const { | 134 bool TopSitesFactory::ServiceIsNULLWhileTesting() const { |
| 135 return true; | 135 return true; |
| 136 } | 136 } |
| OLD | NEW |