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

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: More-buttons for the Recent Tabs and Downloads sections 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..862ea5df5bf032c8acad706891b47ddd29395e71 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,9 @@ class OfflinePageSuggestionsProvider
public offline_pages::OfflinePageModel::Observer {
public:
OfflinePageSuggestionsProvider(
+ bool recent_tabs_enabled,
+ bool downloads_enabled,
+ bool download_manager_ui_enabled,
ContentSuggestionsProvider::Observer* observer,
CategoryFactory* category_factory,
offline_pages::OfflinePageModel* offline_page_model,
@@ -69,28 +72,47 @@ 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);
+
+ 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_;
+
+ // Whether the Download Manager UI is enabled, in which case the More button
+ // for the Downloads section can redirect there.
+ const bool download_manager_ui_enabled_;
DISALLOW_COPY_AND_ASSIGN(OfflinePageSuggestionsProvider);
};

Powered by Google App Engine
This is Rietveld 408576698