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

Unified Diff: chrome/browser/ntp_snippets/download_suggestions_provider.h

Issue 2673633002: [NTP::Downloads] Do not show old downloads. (Closed)
Patch Set: comments + clean rebase (sorry). Created 3 years, 10 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
Index: chrome/browser/ntp_snippets/download_suggestions_provider.h
diff --git a/chrome/browser/ntp_snippets/download_suggestions_provider.h b/chrome/browser/ntp_snippets/download_suggestions_provider.h
index 59bf356f557328a90abd3ced220aa8b826f48c8b..9cac825d2e4a652f04f5e5fe81fd32d855c7c055 100644
--- a/chrome/browser/ntp_snippets/download_suggestions_provider.h
+++ b/chrome/browser/ntp_snippets/download_suggestions_provider.h
@@ -28,6 +28,10 @@ namespace offline_pages {
struct OfflinePageItem;
}
+namespace base {
+class Clock;
+}
+
// Provides download content suggestions from the offline pages model and the
// download manager (obtaining the data through DownloadManager and each
// DownloadItem). Offline page related downloads are referred to as offline page
@@ -46,7 +50,8 @@ class DownloadSuggestionsProvider
offline_pages::OfflinePageModel* offline_page_model,
content::DownloadManager* download_manager,
DownloadHistory* download_history,
- PrefService* pref_service);
+ PrefService* pref_service,
+ std::unique_ptr<base::Clock> clock);
~DownloadSuggestionsProvider() override;
// ContentSuggestionsProvider implementation.
@@ -136,6 +141,10 @@ class DownloadSuggestionsProvider
ntp_snippets::ContentSuggestion ConvertDownloadItem(
const content::DownloadItem& download_item) const;
+ // Returns true if a download published time is considered too old for the
+ // download to be shown.
+ bool IsDownloadOutdated(const base::Time& published_time);
+
// Adds |item| to the internal asset download cache if all of the following
// holds:
// - the download is completed;
@@ -205,8 +214,8 @@ class DownloadSuggestionsProvider
offline_pages::OfflinePageModel* offline_page_model_;
content::DownloadManager* download_manager_;
DownloadHistory* download_history_;
-
PrefService* pref_service_;
+ std::unique_ptr<base::Clock> clock_;
// Cached offline page downloads. If there are not enough asset downloads, all
// of these could be shown (they are the most recently visited, not dismissed

Powered by Google App Engine
This is Rietveld 408576698