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

Side by Side Diff: components/ntp_snippets/content_suggestions_provider.h

Issue 2223073002: Add per-section clearing and dismissed suggestions to snippets-internals (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix non-Debug builds 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_CONTENT_SUGGESTIONS_PROVIDER_H_ 5 #ifndef COMPONENTS_NTP_SNIPPETS_CONTENT_SUGGESTIONS_PROVIDER_H_
6 #define COMPONENTS_NTP_SNIPPETS_CONTENT_SUGGESTIONS_PROVIDER_H_ 6 #define COMPONENTS_NTP_SNIPPETS_CONTENT_SUGGESTIONS_PROVIDER_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 // removal of the dismissed suggestion is the only change. 83 // removal of the dismissed suggestion is the only change.
84 virtual void DismissSuggestion(const std::string& suggestion_id) = 0; 84 virtual void DismissSuggestion(const std::string& suggestion_id) = 0;
85 85
86 // Fetches the image for the suggestion with the given ID and returns it 86 // Fetches the image for the suggestion with the given ID and returns it
87 // through the callback. This fetch may occur locally or from the internet. 87 // through the callback. This fetch may occur locally or from the internet.
88 // If that suggestion doesn't exist, doesn't have an image or if the fetch 88 // If that suggestion doesn't exist, doesn't have an image or if the fetch
89 // fails, the callback gets a null image. 89 // fails, the callback gets a null image.
90 virtual void FetchSuggestionImage(const std::string& suggestion_id, 90 virtual void FetchSuggestionImage(const std::string& suggestion_id,
91 const ImageFetchedCallback& callback) = 0; 91 const ImageFetchedCallback& callback) = 0;
92 92
93 // Used only for debugging purposes. Clears all caches so that the next 93 // Used only for debugging purposes. Clears all caches for the given category,
94 // fetch starts from scratch. 94 // so that the next fetch starts from scratch.
95 virtual void ClearCachedSuggestionsForDebugging() = 0; 95 virtual void ClearCachedSuggestionsForDebugging(Category category) = 0;
96
97 // Used only for debugging purposes. Retrieves suggestions for the given
98 // |category| that have previously been dismissed and are still stored in the
99 // provider. If the provider doesn't store dismissed suggestions for the given
100 // |category|, it always returns an empty vector.
101 virtual std::vector<ContentSuggestion> GetDismissedSuggestionsForDebugging(
102 Category category) = 0;
96 103
97 // Used only for debugging purposes. Clears the cache of dismissed 104 // Used only for debugging purposes. Clears the cache of dismissed
98 // suggestions, if present, so that no suggestions are suppressed. This does 105 // suggestions for the given |category|, if present, so that no suggestions
99 // not necessarily make previously dismissed suggestions reappear, as they may 106 // are suppressed. This does not necessarily make previously dismissed
100 // have been permanently deleted, depending on the provider implementation. 107 // suggestions reappear, as they may have been permanently deleted, depending
101 virtual void ClearDismissedSuggestionsForDebugging() = 0; 108 // on the provider implementation.
109 virtual void ClearDismissedSuggestionsForDebugging(Category category) = 0;
102 110
103 protected: 111 protected:
104 ContentSuggestionsProvider(Observer* observer, 112 ContentSuggestionsProvider(Observer* observer,
105 CategoryFactory* category_factory); 113 CategoryFactory* category_factory);
106 114
107 // Creates a unique ID. The given |within_category_id| must be unique among 115 // Creates a unique ID. The given |within_category_id| must be unique among
108 // all suggestion IDs from this provider for the given |category|. This method 116 // all suggestion IDs from this provider for the given |category|. This method
109 // combines it with the |category| to form an ID that is unique 117 // combines it with the |category| to form an ID that is unique
110 // application-wide, because this provider is the only one that provides 118 // application-wide, because this provider is the only one that provides
111 // suggestions for that category. 119 // suggestions for that category.
112 std::string MakeUniqueID(Category category, 120 std::string MakeUniqueID(Category category,
113 const std::string& within_category_id); 121 const std::string& within_category_id);
114 122
115 // Reverse functions for MakeUniqueID() 123 // Reverse functions for MakeUniqueID()
116 Category GetCategoryFromUniqueID(const std::string& unique_id); 124 Category GetCategoryFromUniqueID(const std::string& unique_id);
117 std::string GetWithinCategoryIDFromUniqueID(const std::string& unique_id); 125 std::string GetWithinCategoryIDFromUniqueID(const std::string& unique_id);
118 126
119 Observer* observer() const { return observer_; } 127 Observer* observer() const { return observer_; }
120 CategoryFactory* category_factory() const { return category_factory_; } 128 CategoryFactory* category_factory() const { return category_factory_; }
121 129
122 private: 130 private:
123 Observer* observer_; 131 Observer* observer_;
124 CategoryFactory* category_factory_; 132 CategoryFactory* category_factory_;
125 }; 133 };
126 134
127 } // namespace ntp_snippets 135 } // namespace ntp_snippets
128 136
129 #endif // COMPONENTS_NTP_SNIPPETS_CONTENT_SUGGESTIONS_PROVIDER_H_ 137 #endif // COMPONENTS_NTP_SNIPPETS_CONTENT_SUGGESTIONS_PROVIDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698