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

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

Issue 2167063003: Rename discard to dismiss for NTP snippets and content suggestions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bridgeumbiegen
Patch Set: Fix unit test Created 4 years, 5 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_SERVICE_H_ 5 #ifndef COMPONENTS_NTP_SNIPPETS_CONTENT_SUGGESTIONS_SERVICE_H_
6 #define COMPONENTS_NTP_SNIPPETS_CONTENT_SUGGESTIONS_SERVICE_H_ 6 #define COMPONENTS_NTP_SNIPPETS_CONTENT_SUGGESTIONS_SERVICE_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <map> 10 #include <map>
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 // for any reason, see |GetCategoryStatus()|. 85 // for any reason, see |GetCategoryStatus()|.
86 const std::vector<ContentSuggestion>& GetSuggestionsForCategory( 86 const std::vector<ContentSuggestion>& GetSuggestionsForCategory(
87 ContentSuggestionsCategory category) const; 87 ContentSuggestionsCategory category) const;
88 88
89 // Fetches the image for the suggestion with the given |suggestion_id| and 89 // Fetches the image for the suggestion with the given |suggestion_id| and
90 // runs the |callback|. If that suggestion doesn't exist or the fetch fails, 90 // runs the |callback|. If that suggestion doesn't exist or the fetch fails,
91 // the callback gets an empty image. 91 // the callback gets an empty image.
92 void FetchSuggestionImage(const std::string& suggestion_id, 92 void FetchSuggestionImage(const std::string& suggestion_id,
93 const ImageFetchedCallback& callback); 93 const ImageFetchedCallback& callback);
94 94
95 // Discards the suggestion with the given |suggestion_id|, if it exists. 95 // Dismisses the suggestion with the given |suggestion_id|, if it exists.
96 // This will not trigger an update through the observers. 96 // This will not trigger an update through the observers.
97 void DiscardSuggestion(const std::string& suggestion_id); 97 void DismissSuggestion(const std::string& suggestion_id);
98 98
99 // Observer accessors. 99 // Observer accessors.
100 void AddObserver(Observer* observer); 100 void AddObserver(Observer* observer);
101 void RemoveObserver(Observer* observer); 101 void RemoveObserver(Observer* observer);
102 102
103 // Registers a new ContentSuggestionsProvider. It must be ensured that at most 103 // Registers a new ContentSuggestionsProvider. It must be ensured that at most
104 // one provider is registered for every category and that this method is 104 // one provider is registered for every category and that this method is
105 // called only once per provider. 105 // called only once per provider.
106 void RegisterProvider(ContentSuggestionsProvider* provider); 106 void RegisterProvider(ContentSuggestionsProvider* provider);
107 107
108 // Only for debugging use through the internals page. 108 // Only for debugging use through the internals page.
109 // Removes all suggestions from all caches or internal stores in all 109 // Removes all suggestions from all caches or internal stores in all
110 // providers. It does, however, not remove any suggestions from the provider's 110 // providers. It does, however, not remove any suggestions from the provider's
111 // sources, so if their configuration hasn't changed, they should return the 111 // sources, so if their configuration hasn't changed, they should return the
112 // same results when they fetch the next time. In particular, calling this 112 // same results when they fetch the next time. In particular, calling this
113 // method will not mark any suggestions as discarded. 113 // method will not mark any suggestions as dismissed.
114 void ClearCachedSuggestionsForDebugging(); 114 void ClearCachedSuggestionsForDebugging();
115 115
116 // Only for debugging use through the internals page. Some providers 116 // Only for debugging use through the internals page. Some providers
117 // internally store a list of discarded suggestions to prevent them from 117 // internally store a list of dismissed suggestions to prevent them from
118 // reappearing. This function clears all such lists in all providers, making 118 // reappearing. This function clears all such lists in all providers, making
119 // discarded suggestions reappear (only for certain providers). 119 // dismissed suggestions reappear (only for certain providers).
120 void ClearDiscardedSuggestionsForDebugging(); 120 void ClearDismissedSuggestionsForDebugging();
121 121
122 private: 122 private:
123 friend class ContentSuggestionsServiceTest; 123 friend class ContentSuggestionsServiceTest;
124 124
125 // Implementation of ContentSuggestionsProvider::Observer. 125 // Implementation of ContentSuggestionsProvider::Observer.
126 void OnNewSuggestions(ContentSuggestionsCategory changed_category, 126 void OnNewSuggestions(ContentSuggestionsCategory changed_category,
127 std::vector<ContentSuggestion> suggestions) override; 127 std::vector<ContentSuggestion> suggestions) override;
128 void OnCategoryStatusChanged( 128 void OnCategoryStatusChanged(
129 ContentSuggestionsCategory changed_category, 129 ContentSuggestionsCategory changed_category,
130 ContentSuggestionsCategoryStatus new_status) override; 130 ContentSuggestionsCategoryStatus new_status) override;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 base::ObserverList<Observer> observers_; 165 base::ObserverList<Observer> observers_;
166 166
167 const std::vector<ContentSuggestion> no_suggestions_; 167 const std::vector<ContentSuggestion> no_suggestions_;
168 168
169 DISALLOW_COPY_AND_ASSIGN(ContentSuggestionsService); 169 DISALLOW_COPY_AND_ASSIGN(ContentSuggestionsService);
170 }; 170 };
171 171
172 } // namespace ntp_snippets 172 } // namespace ntp_snippets
173 173
174 #endif // COMPONENTS_NTP_SNIPPETS_CONTENT_SUGGESTIONS_SERVICE_H_ 174 #endif // COMPONENTS_NTP_SNIPPETS_CONTENT_SUGGESTIONS_SERVICE_H_
OLDNEW
« no previous file with comments | « components/ntp_snippets/content_suggestions_provider.h ('k') | components/ntp_snippets/content_suggestions_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698