| 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 }; | 44 }; |
| 45 | 45 |
| 46 using FinishedCallback = base::Callback<void(bool /* success */)>; | 46 using FinishedCallback = base::Callback<void(bool /* success */)>; |
| 47 | 47 |
| 48 // Usually, the name of the file that's downloaded is based on the user's | 48 // Usually, the name of the file that's downloaded is based on the user's |
| 49 // locale. |override_country| (if non-empty) is used to override the | 49 // locale. |override_country| (if non-empty) is used to override the |
| 50 // auto-detected country. |override_version|, if non-empty, will | 50 // auto-detected country. |override_version|, if non-empty, will |
| 51 // override the baked-in default version. | 51 // override the baked-in default version. |
| 52 // |override_filename|, if non-empty, will override the full filename | 52 // |override_filename|, if non-empty, will override the full filename |
| 53 // (so |override_country| and |override_version| are ignored in this case). | 53 // (so |override_country| and |override_version| are ignored in this case). |
| 54 // Set |force_download| to enfore re-downloading the suggestions file, even if |
| 55 // it already exists on disk. |
| 54 // TODO(treib): Get rid of |override_filename|. | 56 // TODO(treib): Get rid of |override_filename|. |
| 55 PopularSites(Profile* profile, | 57 PopularSites(Profile* profile, |
| 56 const std::string& override_country, | 58 const std::string& override_country, |
| 57 const std::string& override_version, | 59 const std::string& override_version, |
| 58 const std::string& override_filename, | 60 const std::string& override_filename, |
| 61 bool force_download, |
| 59 const FinishedCallback& callback); | 62 const FinishedCallback& callback); |
| 60 ~PopularSites(); | 63 ~PopularSites(); |
| 61 | 64 |
| 62 const std::vector<Site>& sites() const { return sites_; } | 65 const std::vector<Site>& sites() const { return sites_; } |
| 63 | 66 |
| 64 private: | 67 private: |
| 65 void OnDownloadDone(const base::FilePath& path, bool success); | 68 void OnDownloadDone(const base::FilePath& path, bool success); |
| 66 void OnJsonParsed(scoped_ptr<std::vector<Site>> sites); | 69 void OnJsonParsed(scoped_ptr<std::vector<Site>> sites); |
| 67 | 70 |
| 68 FinishedCallback callback_; | 71 FinishedCallback callback_; |
| 69 scoped_ptr<FileDownloader> downloader_; | 72 scoped_ptr<FileDownloader> downloader_; |
| 70 std::vector<Site> sites_; | 73 std::vector<Site> sites_; |
| 71 | 74 |
| 72 base::WeakPtrFactory<PopularSites> weak_ptr_factory_; | 75 base::WeakPtrFactory<PopularSites> weak_ptr_factory_; |
| 73 | 76 |
| 74 DISALLOW_COPY_AND_ASSIGN(PopularSites); | 77 DISALLOW_COPY_AND_ASSIGN(PopularSites); |
| 75 }; | 78 }; |
| 76 | 79 |
| 77 #endif // CHROME_BROWSER_ANDROID_POPULAR_SITES_H_ | 80 #endif // CHROME_BROWSER_ANDROID_POPULAR_SITES_H_ |
| OLD | NEW |