| 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 namespace variations { |
| 29 class VariationsService; |
| 30 } |
| 31 |
| 28 class PrefService; | 32 class PrefService; |
| 29 class TemplateURLService; | 33 class TemplateURLService; |
| 30 | 34 |
| 31 // Downloads and provides a list of suggested popular sites, for display on | 35 // Downloads and provides a list of suggested popular sites, for display on |
| 32 // the NTP when there are not enough personalized suggestions. Caches the | 36 // the NTP when there are not enough personalized suggestions. Caches the |
| 33 // downloaded file on disk to avoid re-downloading on every startup. | 37 // downloaded file on disk to avoid re-downloading on every startup. |
| 34 class PopularSites { | 38 class PopularSites { |
| 35 public: | 39 public: |
| 36 struct Site { | 40 struct Site { |
| 37 Site(const base::string16& title, | 41 Site(const base::string16& title, |
| (...skipping 14 matching lines...) Expand all Loading... |
| 52 using FinishedCallback = base::Callback<void(bool /* success */)>; | 56 using FinishedCallback = base::Callback<void(bool /* success */)>; |
| 53 | 57 |
| 54 // Usually, the name of the file that's downloaded is based on the user's | 58 // Usually, the name of the file that's downloaded is based on the user's |
| 55 // locale. |override_country| (if non-empty) is used to override the | 59 // locale. |override_country| (if non-empty) is used to override the |
| 56 // auto-detected country. |override_version|, if non-empty, will | 60 // auto-detected country. |override_version|, if non-empty, will |
| 57 // override the baked-in default version. | 61 // override the baked-in default version. |
| 58 // Set |force_download| to enforce re-downloading the suggestions file, even | 62 // Set |force_download| to enforce re-downloading the suggestions file, even |
| 59 // if it already exists on disk. | 63 // if it already exists on disk. |
| 60 PopularSites(PrefService* prefs, | 64 PopularSites(PrefService* prefs, |
| 61 const TemplateURLService* template_url_service, | 65 const TemplateURLService* template_url_service, |
| 66 variations::VariationsService* variations_service, |
| 62 net::URLRequestContextGetter* download_context, | 67 net::URLRequestContextGetter* download_context, |
| 63 const std::string& override_country, | 68 const std::string& override_country, |
| 64 const std::string& override_version, | 69 const std::string& override_version, |
| 65 bool force_download, | 70 bool force_download, |
| 66 const FinishedCallback& callback); | 71 const FinishedCallback& callback); |
| 67 | 72 |
| 68 // This fetches the popular sites from a given url and is only used for | 73 // This fetches the popular sites from a given url and is only used for |
| 69 // debugging through the popular-sites-internals page. | 74 // debugging through the popular-sites-internals page. |
| 70 PopularSites(PrefService* prefs, | 75 PopularSites(PrefService* prefs, |
| 71 const TemplateURLService* template_url_service, | 76 const TemplateURLService* template_url_service, |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 PrefService* prefs_; | 128 PrefService* prefs_; |
| 124 const TemplateURLService* template_url_service_; | 129 const TemplateURLService* template_url_service_; |
| 125 net::URLRequestContextGetter* download_context_; | 130 net::URLRequestContextGetter* download_context_; |
| 126 | 131 |
| 127 base::WeakPtrFactory<PopularSites> weak_ptr_factory_; | 132 base::WeakPtrFactory<PopularSites> weak_ptr_factory_; |
| 128 | 133 |
| 129 DISALLOW_COPY_AND_ASSIGN(PopularSites); | 134 DISALLOW_COPY_AND_ASSIGN(PopularSites); |
| 130 }; | 135 }; |
| 131 | 136 |
| 132 #endif // CHROME_BROWSER_ANDROID_NTP_POPULAR_SITES_H_ | 137 #endif // CHROME_BROWSER_ANDROID_NTP_POPULAR_SITES_H_ |
| OLD | NEW |