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