Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(807)

Side by Side Diff: chrome/browser/android/popular_sites.h

Issue 1314493013: Popular sites on the NTP: add thumbnails! (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comment Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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, const GURL& favicon_url); 33 Site(const base::string16& title,
34 const GURL& url,
35 const GURL& favicon_url,
36 const GURL& thumbnail_url);
34 37
35 base::string16 title; 38 base::string16 title;
36 GURL url; 39 GURL url;
37 GURL favicon_url; 40 GURL favicon_url;
41 GURL thumbnail_url;
38 }; 42 };
39 43
40 using FinishedCallback = base::Callback<void(bool /* success */)>; 44 using FinishedCallback = base::Callback<void(bool /* success */)>;
41 45
42 PopularSites(const std::string& filename, 46 PopularSites(const std::string& filename,
43 net::URLRequestContextGetter* request_context, 47 net::URLRequestContextGetter* request_context,
44 const FinishedCallback& callback); 48 const FinishedCallback& callback);
45 ~PopularSites(); 49 ~PopularSites();
46 50
47 const std::vector<Site>& sites() const { return sites_; } 51 const std::vector<Site>& sites() const { return sites_; }
48 52
49 private: 53 private:
50 void OnDownloadDone(const base::FilePath& path, bool success); 54 void OnDownloadDone(const base::FilePath& path, bool success);
51 void OnJsonParsed(scoped_ptr<std::vector<Site>> sites); 55 void OnJsonParsed(scoped_ptr<std::vector<Site>> sites);
52 56
53 FinishedCallback callback_; 57 FinishedCallback callback_;
54 scoped_ptr<FileDownloader> downloader_; 58 scoped_ptr<FileDownloader> downloader_;
55 std::vector<Site> sites_; 59 std::vector<Site> sites_;
56 60
57 base::WeakPtrFactory<PopularSites> weak_ptr_factory_; 61 base::WeakPtrFactory<PopularSites> weak_ptr_factory_;
58 62
59 DISALLOW_COPY_AND_ASSIGN(PopularSites); 63 DISALLOW_COPY_AND_ASSIGN(PopularSites);
60 }; 64 };
61 65
62 #endif // CHROME_BROWSER_ANDROID_POPULAR_SITES_H_ 66 #endif // CHROME_BROWSER_ANDROID_POPULAR_SITES_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698