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

Side by Side Diff: components/ntp_snippets/offline_pages/offline_page_suggestions_provider.h

Issue 2251743002: Refactor OfflinePageSuggestionsProvider dismissed ID handling (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@offlinedelete
Patch Set: Fire OnSuggestionInvalidated even if previously dismissed 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef COMPONENTS_NTP_SNIPPETS_OFFLINE_PAGES_OFFLINE_PAGE_SUGGESTIONS_PROVIDER_ H_ 5 #ifndef COMPONENTS_NTP_SNIPPETS_OFFLINE_PAGES_OFFLINE_PAGE_SUGGESTIONS_PROVIDER_ H_
6 #define COMPONENTS_NTP_SNIPPETS_OFFLINE_PAGES_OFFLINE_PAGE_SUGGESTIONS_PROVIDER_ H_ 6 #define COMPONENTS_NTP_SNIPPETS_OFFLINE_PAGES_OFFLINE_PAGE_SUGGESTIONS_PROVIDER_ H_
7 7
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 const offline_pages::OfflinePageItem& offline_page) const; 82 const offline_pages::OfflinePageItem& offline_page) const;
83 83
84 // Gets the |kMaxSuggestionsCount| most recently visited OfflinePageItems from 84 // Gets the |kMaxSuggestionsCount| most recently visited OfflinePageItems from
85 // the list, orders them by last visit date and converts them to 85 // the list, orders them by last visit date and converts them to
86 // ContentSuggestions for the |category|. 86 // ContentSuggestions for the |category|.
87 std::vector<ContentSuggestion> GetMostRecentlyVisited( 87 std::vector<ContentSuggestion> GetMostRecentlyVisited(
88 Category category, 88 Category category,
89 std::vector<const offline_pages::OfflinePageItem*> offline_page_items) 89 std::vector<const offline_pages::OfflinePageItem*> offline_page_items)
90 const; 90 const;
91 91
92 // Reads dismissed IDs from the pref with name |pref_name|. 92 // If the suggestion for the offline page with the given |offline_id| is
93 std::set<std::string> ReadDismissedIDsFromPrefs( 93 // already dismissed, its dismissed flag is removed (as the offline page
94 const std::string& pref_name) const; 94 // doesn't exist anymore), otherwise the |OnSuggestionInvalidated| event is
Marc Treib 2016/08/16 11:45:17 "otherwise", really? Shouldn't it be fired in any
Philipp Keck 2016/08/16 12:04:01 Done.
95 // fired.
96 void InvalidateSuggestion(Category category, int64_t offline_id);
95 97
96 // Writes |dismissed_ids| to the pref with name |pref_name|. 98 // Gets the preference name for storing the list of dismissed suggestion IDs
97 void StoreDismissedIDsToPrefs(const std::string& pref_name, 99 // for the given |category|.
100 std::string GetDismissedPref(Category category) const;
101
102 // Reads dismissed IDs for the given |category|.
103 std::set<std::string> ReadDismissedIDsFromPrefs(Category category) const;
104
105 // Writes |dismissed_ids| for the given |category|.
106 void StoreDismissedIDsToPrefs(Category category,
98 const std::set<std::string>& dismissed_ids); 107 const std::set<std::string>& dismissed_ids);
99 108
100 CategoryStatus recent_tabs_status_; 109 CategoryStatus recent_tabs_status_;
101 CategoryStatus downloads_status_; 110 CategoryStatus downloads_status_;
102 111
103 offline_pages::OfflinePageModel* offline_page_model_; 112 offline_pages::OfflinePageModel* offline_page_model_;
104 113
105 const Category recent_tabs_category_; 114 const Category recent_tabs_category_;
106 const Category downloads_category_; 115 const Category downloads_category_;
107 116
108 PrefService* pref_service_; 117 PrefService* pref_service_;
109 118
110 std::set<std::string> dismissed_recent_tab_ids_;
111 std::set<std::string> dismissed_download_ids_;
112
113 // Whether the Download Manager UI is enabled, in which case the More button 119 // Whether the Download Manager UI is enabled, in which case the More button
114 // for the Downloads section can redirect there. 120 // for the Downloads section can redirect there.
115 const bool download_manager_ui_enabled_; 121 const bool download_manager_ui_enabled_;
116 122
117 DISALLOW_COPY_AND_ASSIGN(OfflinePageSuggestionsProvider); 123 DISALLOW_COPY_AND_ASSIGN(OfflinePageSuggestionsProvider);
118 }; 124 };
119 125
120 } // namespace ntp_snippets 126 } // namespace ntp_snippets
121 127
122 #endif // COMPONENTS_NTP_SNIPPETS_OFFLINE_PAGES_OFFLINE_PAGE_SUGGESTIONS_PROVID ER_H_ 128 #endif // COMPONENTS_NTP_SNIPPETS_OFFLINE_PAGES_OFFLINE_PAGE_SUGGESTIONS_PROVID ER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698