Add new certificateProvider extension API.
[chromium-blink-merge.git] / chrome / browser / android / popular_sites.h
bloba8170627b04ea74acd735afc1997a245d895b177
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.
5 #ifndef CHROME_BROWSER_ANDROID_POPULAR_SITES_H_
6 #define CHROME_BROWSER_ANDROID_POPULAR_SITES_H_
8 #include <vector>
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"
17 namespace base {
18 class FilePath;
21 namespace net {
22 class URLRequestContextGetter;
25 class FileDownloader;
26 class Profile;
28 // Downloads and provides a list of suggested popular sites, for display on
29 // the NTP when there are not enough personalized suggestions. Caches the
30 // downloaded file on disk to avoid re-downloading on every startup.
31 class PopularSites {
32 public:
33 struct Site {
34 Site(const base::string16& title,
35 const GURL& url,
36 const GURL& favicon_url,
37 const GURL& thumbnail_url);
38 ~Site();
40 base::string16 title;
41 GURL url;
42 GURL favicon_url;
43 GURL thumbnail_url;
46 using FinishedCallback = base::Callback<void(bool /* success */)>;
48 PopularSites(Profile* profile,
49 const std::string& filename,
50 net::URLRequestContextGetter* request_context,
51 const FinishedCallback& callback);
52 ~PopularSites();
54 const std::vector<Site>& sites() const { return sites_; }
56 private:
57 void OnDownloadDone(const base::FilePath& path, bool success);
58 void OnJsonParsed(scoped_ptr<std::vector<Site>> sites);
60 FinishedCallback callback_;
61 scoped_ptr<FileDownloader> downloader_;
62 std::vector<Site> sites_;
64 base::WeakPtrFactory<PopularSites> weak_ptr_factory_;
66 DISALLOW_COPY_AND_ASSIGN(PopularSites);
69 #endif // CHROME_BROWSER_ANDROID_POPULAR_SITES_H_