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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/android/popular_sites.h
diff --git a/chrome/browser/android/popular_sites.h b/chrome/browser/android/popular_sites.h
new file mode 100644
index 0000000000000000000000000000000000000000..64f66ce6005e7da5230a5cf187fff58ad8df3346
--- /dev/null
+++ b/chrome/browser/android/popular_sites.h
@@ -0,0 +1,60 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_ANDROID_POPULAR_SITES_H_
+#define CHROME_BROWSER_ANDROID_POPULAR_SITES_H_
+
+#include <vector>
+
+#include "base/callback.h"
+#include "base/macros.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/memory/weak_ptr.h"
+#include "base/strings/string16.h"
+#include "url/gurl.h"
+
+namespace base {
+class FilePath;
+}
+
+namespace net {
+class URLRequestContextGetter;
+}
+
+class FileDownloader;
+
+// Downloads and provides a list of suggested popular sites, for display on
+// the NTP when there are not enough personalized suggestions. Caches the
+// downloaded file on disk to avoid re-downloading on every startup.
+class PopularSites {
+ public:
+ struct Site {
+ Site(const base::string16& title, const GURL& url);
+
+ base::string16 title;
+ GURL url;
+ };
+
+ using FinishedCallback = base::Callback<void(bool /* success */)>;
+
+ PopularSites(net::URLRequestContextGetter* request_context,
+ const FinishedCallback& callback);
+ ~PopularSites();
+
+ const std::vector<Site>& sites() const { return sites_; }
+
+ private:
+ void OnDownloadDone(const base::FilePath& path, bool success);
+ void OnJsonParsed(scoped_ptr<std::vector<Site>> sites);
+
+ FinishedCallback callback_;
+ scoped_ptr<FileDownloader> downloader_;
+ std::vector<Site> sites_;
+
+ base::WeakPtrFactory<PopularSites> weak_ptr_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(PopularSites);
+};
+
+#endif // CHROME_BROWSER_ANDROID_POPULAR_SITES_H_
« 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