| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/precache/most_visited_urls_provider.h" | 5 #include "chrome/browser/precache/most_visited_urls_provider.h" |
| 6 | 6 |
| 7 #include <list> | 7 #include <list> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "chrome/browser/history/top_sites.h" | 10 #include "chrome/browser/history/top_sites_provider.h" |
| 11 #include "components/history/core/browser/history_types.h" | 11 #include "components/history/core/browser/history_types.h" |
| 12 #include "url/gurl.h" | 12 #include "url/gurl.h" |
| 13 | 13 |
| 14 using history::MostVisitedURLList; | 14 using history::MostVisitedURLList; |
| 15 | 15 |
| 16 namespace { | 16 namespace { |
| 17 | 17 |
| 18 void OnMostVisitedURLsReceived( | 18 void OnMostVisitedURLsReceived( |
| 19 const precache::URLListProvider::GetURLsCallback& callback, | 19 const precache::URLListProvider::GetURLsCallback& callback, |
| 20 const MostVisitedURLList& most_visited_urls) { | 20 const MostVisitedURLList& most_visited_urls) { |
| 21 std::list<GURL> urls; | 21 std::list<GURL> urls; |
| 22 for (MostVisitedURLList::const_iterator it = most_visited_urls.begin(); | 22 for (MostVisitedURLList::const_iterator it = most_visited_urls.begin(); |
| 23 it != most_visited_urls.end(); ++it) { | 23 it != most_visited_urls.end(); ++it) { |
| 24 if (it->url.SchemeIs("http")) { | 24 if (it->url.SchemeIs("http")) { |
| 25 urls.push_back(it->url); | 25 urls.push_back(it->url); |
| 26 } | 26 } |
| 27 } | 27 } |
| 28 callback.Run(urls); | 28 callback.Run(urls); |
| 29 } | 29 } |
| 30 | 30 |
| 31 } // namespace | 31 } // namespace |
| 32 | 32 |
| 33 namespace precache { | 33 namespace precache { |
| 34 | 34 |
| 35 MostVisitedURLsProvider::MostVisitedURLsProvider(history::TopSites* top_sites) | 35 MostVisitedURLsProvider::MostVisitedURLsProvider( |
| 36 : top_sites_(top_sites) {} | 36 history::TopSitesProvider* top_sites) |
| 37 : top_sites_provider_(top_sites) { |
| 38 } |
| 37 | 39 |
| 38 MostVisitedURLsProvider::~MostVisitedURLsProvider() {} | 40 MostVisitedURLsProvider::~MostVisitedURLsProvider() {} |
| 39 | 41 |
| 40 void MostVisitedURLsProvider::GetURLs(const GetURLsCallback& callback) { | 42 void MostVisitedURLsProvider::GetURLs(const GetURLsCallback& callback) { |
| 41 top_sites_->GetMostVisitedURLs( | 43 top_sites_provider_->GetMostVisitedURLs( |
| 42 base::Bind(&OnMostVisitedURLsReceived, callback), false); | 44 base::Bind(&OnMostVisitedURLsReceived, callback), false); |
| 43 } | 45 } |
| 44 | 46 |
| 45 } // namespace precache | 47 } // namespace precache |
| OLD | NEW |