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_NTP_POPULAR_SITES_H_ | 5 #ifndef CHROME_BROWSER_ANDROID_NTP_POPULAR_SITES_H_ |
6 #define CHROME_BROWSER_ANDROID_NTP_POPULAR_SITES_H_ | 6 #define CHROME_BROWSER_ANDROID_NTP_POPULAR_SITES_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/callback.h" | 12 #include "base/callback.h" |
13 #include "base/files/file_path.h" | 13 #include "base/files/file_path.h" |
14 #include "base/macros.h" | 14 #include "base/macros.h" |
15 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
16 #include "base/strings/string16.h" | 16 #include "base/strings/string16.h" |
17 #include "chrome/browser/net/file_downloader.h" | 17 #include "chrome/browser/net/file_downloader.h" |
18 #include "url/gurl.h" | 18 #include "url/gurl.h" |
19 | 19 |
20 namespace net { | 20 namespace net { |
21 class URLRequestContextGetter; | 21 class URLRequestContextGetter; |
22 } | 22 } |
23 | 23 |
24 namespace user_prefs { | 24 namespace user_prefs { |
25 class PrefRegistrySyncable; | 25 class PrefRegistrySyncable; |
26 } | 26 } |
27 | 27 |
28 class Profile; | 28 class Profile; |
29 | 29 |
| 30 struct PopularSites_Site { |
| 31 PopularSites_Site(const base::string16& title, |
| 32 const GURL& url, |
| 33 const GURL& favicon_url, |
| 34 const GURL& large_icon_url, |
| 35 const GURL& thumbnail_url); |
| 36 PopularSites_Site(const PopularSites_Site& other); |
| 37 ~PopularSites_Site(); |
| 38 |
| 39 base::string16 title; |
| 40 GURL url; |
| 41 GURL favicon_url; |
| 42 GURL large_icon_url; |
| 43 GURL thumbnail_url; |
| 44 }; |
| 45 |
30 // Downloads and provides a list of suggested popular sites, for display on | 46 // Downloads and provides a list of suggested popular sites, for display on |
31 // the NTP when there are not enough personalized suggestions. Caches the | 47 // the NTP when there are not enough personalized suggestions. Caches the |
32 // downloaded file on disk to avoid re-downloading on every startup. | 48 // downloaded file on disk to avoid re-downloading on every startup. |
33 class PopularSites { | 49 class PopularSites { |
34 public: | 50 public: |
35 struct Site { | 51 using Site = PopularSites_Site; |
36 Site(const base::string16& title, | |
37 const GURL& url, | |
38 const GURL& favicon_url, | |
39 const GURL& large_icon_url, | |
40 const GURL& thumbnail_url); | |
41 Site(const Site& other); | |
42 ~Site(); | |
43 | |
44 base::string16 title; | |
45 GURL url; | |
46 GURL favicon_url; | |
47 GURL large_icon_url; | |
48 GURL thumbnail_url; | |
49 }; | |
50 | |
51 using FinishedCallback = base::Callback<void(bool /* success */)>; | 52 using FinishedCallback = base::Callback<void(bool /* success */)>; |
52 | 53 |
53 // Usually, the name of the file that's downloaded is based on the user's | 54 // Usually, the name of the file that's downloaded is based on the user's |
54 // locale. |override_country| (if non-empty) is used to override the | 55 // locale. |override_country| (if non-empty) is used to override the |
55 // auto-detected country. |override_version|, if non-empty, will | 56 // auto-detected country. |override_version|, if non-empty, will |
56 // override the baked-in default version. | 57 // override the baked-in default version. |
57 // Set |force_download| to enforce re-downloading the suggestions file, even | 58 // Set |force_download| to enforce re-downloading the suggestions file, even |
58 // if it already exists on disk. | 59 // if it already exists on disk. |
59 PopularSites(Profile* profile, | 60 PopularSites(Profile* profile, |
60 const std::string& override_country, | 61 const std::string& override_country, |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 base::FilePath local_path_; | 115 base::FilePath local_path_; |
115 | 116 |
116 Profile* profile_; | 117 Profile* profile_; |
117 | 118 |
118 base::WeakPtrFactory<PopularSites> weak_ptr_factory_; | 119 base::WeakPtrFactory<PopularSites> weak_ptr_factory_; |
119 | 120 |
120 DISALLOW_COPY_AND_ASSIGN(PopularSites); | 121 DISALLOW_COPY_AND_ASSIGN(PopularSites); |
121 }; | 122 }; |
122 | 123 |
123 #endif // CHROME_BROWSER_ANDROID_NTP_POPULAR_SITES_H_ | 124 #endif // CHROME_BROWSER_ANDROID_NTP_POPULAR_SITES_H_ |
OLD | NEW |