Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 CHROME_BROWSER_NTP_SNIPPETS_DOWNLOAD_SUGGESTIONS_PROVIDER_H_ | 5 #ifndef CHROME_BROWSER_NTP_SNIPPETS_DOWNLOAD_SUGGESTIONS_PROVIDER_H_ |
| 6 #define CHROME_BROWSER_NTP_SNIPPETS_DOWNLOAD_SUGGESTIONS_PROVIDER_H_ | 6 #define CHROME_BROWSER_NTP_SNIPPETS_DOWNLOAD_SUGGESTIONS_PROVIDER_H_ |
| 7 | 7 |
| 8 #include <list> | |
| 8 #include <set> | 9 #include <set> |
| 9 #include <string> | 10 #include <string> |
| 10 #include <vector> | 11 #include <vector> |
| 11 | 12 |
| 12 #include "base/callback_forward.h" | 13 #include "base/callback_forward.h" |
| 13 #include "base/memory/ptr_util.h" | 14 #include "base/memory/ptr_util.h" |
| 14 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
| 15 #include "components/ntp_snippets/callbacks.h" | 16 #include "components/ntp_snippets/callbacks.h" |
| 16 #include "components/ntp_snippets/category.h" | 17 #include "components/ntp_snippets/category.h" |
| 17 #include "components/ntp_snippets/category_factory.h" | 18 #include "components/ntp_snippets/category_factory.h" |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 164 bool notify, | 165 bool notify, |
| 165 const std::vector<offline_pages::OfflinePageItem>& | 166 const std::vector<offline_pages::OfflinePageItem>& |
| 166 all_download_offline_pages); | 167 all_download_offline_pages); |
| 167 | 168 |
| 168 // Fires the |OnSuggestionInvalidated| event for the suggestion corresponding | 169 // Fires the |OnSuggestionInvalidated| event for the suggestion corresponding |
| 169 // to the given |id_within_category| and clears it from the dismissed IDs | 170 // to the given |id_within_category| and clears it from the dismissed IDs |
| 170 // list, if necessary. | 171 // list, if necessary. |
| 171 void InvalidateSuggestion(const std::string& id_within_category); | 172 void InvalidateSuggestion(const std::string& id_within_category); |
| 172 | 173 |
| 173 // Reads dismissed IDs related to asset downloads from prefs. | 174 // Reads dismissed IDs related to asset downloads from prefs. |
| 174 std::set<std::string> ReadAssetDismissedIDsFromPrefs() const; | 175 std::list<std::string> ReadAssetDismissedIDsFromPrefs() const; |
|
Marc Treib
2016/12/09 16:37:26
vector?
No need to be super inefficient and use li
vitaliii
2016/12/09 17:30:36
Done.
| |
| 175 | 176 |
| 176 // Writes |dismissed_ids| into prefs for asset downloads. | 177 // Writes |dismissed_ids| into prefs for asset downloads. |
| 177 void StoreAssetDismissedIDsToPrefs( | 178 void StoreAssetDismissedIDsToPrefs( |
| 178 const std::set<std::string>& dismissed_ids); | 179 const std::list<std::string>& dismissed_ids); |
| 179 | 180 |
| 180 // Reads dismissed IDs related to offline page downloads from prefs. | 181 // Reads dismissed IDs related to offline page downloads from prefs. |
| 181 std::set<std::string> ReadOfflinePageDismissedIDsFromPrefs() const; | 182 std::set<std::string> ReadOfflinePageDismissedIDsFromPrefs() const; |
| 182 | 183 |
| 183 // Writes |dismissed_ids| into prefs for offline page downloads. | 184 // Writes |dismissed_ids| into prefs for offline page downloads. |
| 184 void StoreOfflinePageDismissedIDsToPrefs( | 185 void StoreOfflinePageDismissedIDsToPrefs( |
| 185 const std::set<std::string>& dismissed_ids); | 186 const std::set<std::string>& dismissed_ids); |
| 186 | 187 |
| 187 // Reads from prefs dismissed IDs related to either offline page or asset | 188 // Adds a suggestion ID to the dismissed list in prefs, if it is not there. |
| 188 // downloads (given by |for_offline_page_downloads|). | 189 // Works for both Offline Page and Asset downloads. |
| 189 std::set<std::string> ReadDismissedIDsFromPrefs( | 190 void AddToDismissedStorageIfNeeded( |
| 190 bool for_offline_page_downloads) const; | 191 const ntp_snippets::ContentSuggestion::ID& suggestion_id); |
| 191 | 192 |
| 192 // Writes |dismissed_ids| into prefs for either offline page or asset | 193 // Removes a suggestion ID from the dismissed list in prefs, if it is there. |
| 193 // downloads (given by |for_offline_page_downloads|). | 194 // Works for both Offline Page and Asset downloads. |
| 194 void StoreDismissedIDsToPrefs(bool for_offline_page_downloads, | 195 void RemoveFromDismissedStorageIfNeeded( |
| 195 const std::set<std::string>& dismissed_ids); | 196 const ntp_snippets::ContentSuggestion::ID& suggestion_id); |
| 196 | 197 |
| 197 void UnregisterDownloadItemObservers(); | 198 void UnregisterDownloadItemObservers(); |
| 198 | 199 |
| 199 ntp_snippets::CategoryStatus category_status_; | 200 ntp_snippets::CategoryStatus category_status_; |
| 200 const ntp_snippets::Category provided_category_; | 201 const ntp_snippets::Category provided_category_; |
| 201 offline_pages::OfflinePageModel* offline_page_model_; | 202 offline_pages::OfflinePageModel* offline_page_model_; |
| 202 content::DownloadManager* download_manager_; | 203 content::DownloadManager* download_manager_; |
| 203 | 204 |
| 204 PrefService* pref_service_; | 205 PrefService* pref_service_; |
| 205 | 206 |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 219 // Whether the Download Manager UI is enabled, in which case the More button | 220 // Whether the Download Manager UI is enabled, in which case the More button |
| 220 // for the Downloads section can redirect there. | 221 // for the Downloads section can redirect there. |
| 221 const bool download_manager_ui_enabled_; | 222 const bool download_manager_ui_enabled_; |
| 222 | 223 |
| 223 base::WeakPtrFactory<DownloadSuggestionsProvider> weak_ptr_factory_; | 224 base::WeakPtrFactory<DownloadSuggestionsProvider> weak_ptr_factory_; |
| 224 | 225 |
| 225 DISALLOW_COPY_AND_ASSIGN(DownloadSuggestionsProvider); | 226 DISALLOW_COPY_AND_ASSIGN(DownloadSuggestionsProvider); |
| 226 }; | 227 }; |
| 227 | 228 |
| 228 #endif // CHROME_BROWSER_NTP_SNIPPETS_DOWNLOAD_SUGGESTIONS_PROVIDER_H_ | 229 #endif // CHROME_BROWSER_NTP_SNIPPETS_DOWNLOAD_SUGGESTIONS_PROVIDER_H_ |
| OLD | NEW |