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

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

Issue 2194203002: Make ContentSuggestionsService recognize new/removed categories (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@renaming
Patch Set: Put the status-change notification back in RegisterProvider() 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_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 <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 private: 119 private:
120 friend class ContentSuggestionsServiceTest; 120 friend class ContentSuggestionsServiceTest;
121 121
122 // This is just an arbitrary ordering by ID, used by the maps in this class, 122 // This is just an arbitrary ordering by ID, used by the maps in this class,
123 // because the ordering needs to be constant for maps. 123 // because the ordering needs to be constant for maps.
124 struct CompareCategoriesByID { 124 struct CompareCategoriesByID {
125 bool operator()(const Category& left, const Category& right) const; 125 bool operator()(const Category& left, const Category& right) const;
126 }; 126 };
127 127
128 // Implementation of ContentSuggestionsProvider::Observer. 128 // Implementation of ContentSuggestionsProvider::Observer.
129 void OnNewSuggestions(Category changed_category, 129 void OnNewSuggestions(ContentSuggestionsProvider* provider,
130 Category category,
130 std::vector<ContentSuggestion> suggestions) override; 131 std::vector<ContentSuggestion> suggestions) override;
131 void OnCategoryStatusChanged(Category changed_category, 132 void OnCategoryStatusChanged(ContentSuggestionsProvider* provider,
133 Category category,
132 CategoryStatus new_status) override; 134 CategoryStatus new_status) override;
133 void OnProviderShutdown(ContentSuggestionsProvider* provider) override; 135 void OnProviderShutdown(ContentSuggestionsProvider* provider) override;
134 136
135 // Checks whether a provider for the given |category| is registered. 137 // Ensures the given |provider| is is registered for the given |category|.
136 bool IsCategoryRegistered(Category category) const; 138 // Returns true if the category was newly registered, false if it was present
139 // before.
140 bool EnsureCategoryRegistered(ContentSuggestionsProvider* provider,
Marc Treib 2016/08/01 14:23:38 EnsureCategoryIsRegistered?
Philipp Keck 2016/08/01 14:59:04 Acknowledged.
141 Category category);
137 142
138 // Fires the OnCategoryStatusChanged event for the given |category|. 143 // Fires the OnCategoryStatusChanged event for the given |category|.
139 void NotifyCategoryStatusChanged(Category category); 144 void NotifyCategoryStatusChanged(Category category);
140 145
141 // Whether the content suggestions feature is enabled. 146 // Whether the content suggestions feature is enabled.
142 State state_; 147 State state_;
143 148
144 // Provides new and existing categories and an order for them. 149 // Provides new and existing categories and an order for them.
145 CategoryFactory category_factory_; 150 CategoryFactory category_factory_;
146 151
(...skipping 23 matching lines...) Expand all
170 base::ObserverList<Observer> observers_; 175 base::ObserverList<Observer> observers_;
171 176
172 const std::vector<ContentSuggestion> no_suggestions_; 177 const std::vector<ContentSuggestion> no_suggestions_;
173 178
174 DISALLOW_COPY_AND_ASSIGN(ContentSuggestionsService); 179 DISALLOW_COPY_AND_ASSIGN(ContentSuggestionsService);
175 }; 180 };
176 181
177 } // namespace ntp_snippets 182 } // namespace ntp_snippets
178 183
179 #endif // COMPONENTS_NTP_SNIPPETS_CONTENT_SUGGESTIONS_SERVICE_H_ 184 #endif // COMPONENTS_NTP_SNIPPETS_CONTENT_SUGGESTIONS_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698