| 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 #ifndef CHROME_BROWSER_ANDROID_POPULAR_SITES_H_ | 5 #ifndef CHROME_BROWSER_ANDROID_POPULAR_SITES_H_ |
| 6 #define CHROME_BROWSER_ANDROID_POPULAR_SITES_H_ | 6 #define CHROME_BROWSER_ANDROID_POPULAR_SITES_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 } | 23 } |
| 24 | 24 |
| 25 class FileDownloader; | 25 class FileDownloader; |
| 26 | 26 |
| 27 // Downloads and provides a list of suggested popular sites, for display on | 27 // Downloads and provides a list of suggested popular sites, for display on |
| 28 // the NTP when there are not enough personalized suggestions. Caches the | 28 // the NTP when there are not enough personalized suggestions. Caches the |
| 29 // downloaded file on disk to avoid re-downloading on every startup. | 29 // downloaded file on disk to avoid re-downloading on every startup. |
| 30 class PopularSites { | 30 class PopularSites { |
| 31 public: | 31 public: |
| 32 struct Site { | 32 struct Site { |
| 33 Site(const base::string16& title, const GURL& url); | 33 Site(const base::string16& title, const GURL& url, const GURL& favicon_url); |
| 34 | 34 |
| 35 base::string16 title; | 35 base::string16 title; |
| 36 GURL url; | 36 GURL url; |
| 37 GURL favicon_url; |
| 37 }; | 38 }; |
| 38 | 39 |
| 39 using FinishedCallback = base::Callback<void(bool /* success */)>; | 40 using FinishedCallback = base::Callback<void(bool /* success */)>; |
| 40 | 41 |
| 41 PopularSites(net::URLRequestContextGetter* request_context, | 42 PopularSites(net::URLRequestContextGetter* request_context, |
| 42 const FinishedCallback& callback); | 43 const FinishedCallback& callback); |
| 43 ~PopularSites(); | 44 ~PopularSites(); |
| 44 | 45 |
| 45 const std::vector<Site>& sites() const { return sites_; } | 46 const std::vector<Site>& sites() const { return sites_; } |
| 46 | 47 |
| 47 private: | 48 private: |
| 48 void OnDownloadDone(const base::FilePath& path, bool success); | 49 void OnDownloadDone(const base::FilePath& path, bool success); |
| 49 void OnJsonParsed(scoped_ptr<std::vector<Site>> sites); | 50 void OnJsonParsed(scoped_ptr<std::vector<Site>> sites); |
| 50 | 51 |
| 51 FinishedCallback callback_; | 52 FinishedCallback callback_; |
| 52 scoped_ptr<FileDownloader> downloader_; | 53 scoped_ptr<FileDownloader> downloader_; |
| 53 std::vector<Site> sites_; | 54 std::vector<Site> sites_; |
| 54 | 55 |
| 55 base::WeakPtrFactory<PopularSites> weak_ptr_factory_; | 56 base::WeakPtrFactory<PopularSites> weak_ptr_factory_; |
| 56 | 57 |
| 57 DISALLOW_COPY_AND_ASSIGN(PopularSites); | 58 DISALLOW_COPY_AND_ASSIGN(PopularSites); |
| 58 }; | 59 }; |
| 59 | 60 |
| 60 #endif // CHROME_BROWSER_ANDROID_POPULAR_SITES_H_ | 61 #endif // CHROME_BROWSER_ANDROID_POPULAR_SITES_H_ |
| OLD | NEW |