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_
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"
22 class URLRequestContextGetter
;
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.
34 Site(const base::string16
& title
,
36 const GURL
& favicon_url
,
37 const 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
);
54 const std::vector
<Site
>& sites() const { return sites_
; }
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_