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

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

Issue 1265983007: Popular sites on the NTP (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 years, 4 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
« no previous file with comments | « chrome/browser/android/most_visited_sites.cc ('k') | chrome/browser/android/popular_sites.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_ANDROID_POPULAR_SITES_H_
6 #define CHROME_BROWSER_ANDROID_POPULAR_SITES_H_
7
8 #include <vector>
9
10 #include "base/callback.h"
11 #include "base/macros.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "base/memory/weak_ptr.h"
14 #include "base/strings/string16.h"
15 #include "url/gurl.h"
16
17 namespace base {
18 class FilePath;
19 }
20
21 namespace net {
22 class URLRequestContextGetter;
23 }
24
25 class FileDownloader;
26
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
29 // downloaded file on disk to avoid re-downloading on every startup.
30 class PopularSites {
31 public:
32 struct Site {
33 Site(const base::string16& title, const GURL& url);
34
35 base::string16 title;
36 GURL url;
37 };
38
39 using FinishedCallback = base::Callback<void(bool /* success */)>;
40
41 PopularSites(net::URLRequestContextGetter* request_context,
42 const FinishedCallback& callback);
43 ~PopularSites();
44
45 const std::vector<Site>& sites() const { return sites_; }
46
47 private:
48 void OnDownloadDone(const base::FilePath& path, bool success);
49 void OnJsonParsed(scoped_ptr<std::vector<Site>> sites);
50
51 FinishedCallback callback_;
52 scoped_ptr<FileDownloader> downloader_;
53 std::vector<Site> sites_;
54
55 base::WeakPtrFactory<PopularSites> weak_ptr_factory_;
56
57 DISALLOW_COPY_AND_ASSIGN(PopularSites);
58 };
59
60 #endif // CHROME_BROWSER_ANDROID_POPULAR_SITES_H_
OLDNEW
« no previous file with comments | « chrome/browser/android/most_visited_sites.cc ('k') | chrome/browser/android/popular_sites.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698