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

Unified Diff: components/ntp_snippets/offline_pages/offline_page_suggestions_provider.h

Issue 2245583002: Split OfflinePageSuggestions into two categories (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@offlinedismissed
Patch Set: Marc's comments Created 4 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
Index: components/ntp_snippets/offline_pages/offline_page_suggestions_provider.h
diff --git a/components/ntp_snippets/offline_pages/offline_page_suggestions_provider.h b/components/ntp_snippets/offline_pages/offline_page_suggestions_provider.h
index 40ce31ad41090363421bc5dbb7ff710c2e574152..d7deca3711b0a0fe3b1770e991740020f906440e 100644
--- a/components/ntp_snippets/offline_pages/offline_page_suggestions_provider.h
+++ b/components/ntp_snippets/offline_pages/offline_page_suggestions_provider.h
@@ -35,6 +35,8 @@ class OfflinePageSuggestionsProvider
public offline_pages::OfflinePageModel::Observer {
public:
OfflinePageSuggestionsProvider(
+ bool recent_tabs_enabled,
+ bool downloads_enabled,
ContentSuggestionsProvider::Observer* observer,
CategoryFactory* category_factory,
offline_pages::OfflinePageModel* offline_page_model,
@@ -69,28 +71,44 @@ class OfflinePageSuggestionsProvider
void OnOfflinePagesLoaded(
const offline_pages::MultipleOfflinePageItemResult& result);
- // Updates the |category_status_| and notifies the |observer_|, if necessary.
- void NotifyStatusChanged(CategoryStatus new_status);
+ // Updates the |category_status_| of the |category| and notifies the
+ // |observer_|, if necessary.
+ void NotifyStatusChanged(Category category, CategoryStatus new_status);
- // Converts an OfflinePageItem to a ContentSuggestion.
+ // Converts an OfflinePageItem to a ContentSuggestion for the |category|.
ContentSuggestion ConvertOfflinePage(
+ Category category,
const offline_pages::OfflinePageItem& offline_page) const;
- // Reads |dismissed_ids_| from the prefs.
- void ReadDismissedIDsFromPrefs();
+ // Gets the |kMaxSuggestionsCount| most recently visited OfflinePageItems from
+ // the list, orders them by last visit date and converts them to
+ // ContentSuggestions for the |category|.
+ std::vector<ContentSuggestion> GetMostRecentlyVisited(
+ Category category,
+ std::vector<const offline_pages::OfflinePageItem*> offline_page_items)
+ const;
- // Writes |dismissed_ids_| to the prefs.
- void StoreDismissedIDsToPrefs();
+ // Reads dismissed IDs from the pref with name |pref_name|.
+ std::set<std::string> ReadDismissedIDsFromPrefs(
+ const std::string& pref_name) const;
- CategoryStatus category_status_;
+ // Writes |dismissed_ids| to the pref with name |pref_name|.
+ void StoreDismissedIDsToPrefs(
+ const std::string& pref_name,
+ const std::set<std::string>& dismissed_ids) const;
Marc Treib 2016/08/12 10:12:53 nit: I wouldn't make this one const, since it fund
Philipp Keck 2016/08/12 10:22:55 Done.
+
+ CategoryStatus recent_tabs_status_;
+ CategoryStatus downloads_status_;
offline_pages::OfflinePageModel* offline_page_model_;
- const Category provided_category_;
+ const Category recent_tabs_category_;
+ const Category downloads_category_;
PrefService* pref_service_;
- std::set<std::string> dismissed_ids_;
+ std::set<std::string> dismissed_recent_tab_ids_;
+ std::set<std::string> dismissed_download_ids_;
DISALLOW_COPY_AND_ASSIGN(OfflinePageSuggestionsProvider);
};

Powered by Google App Engine
This is Rietveld 408576698