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 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 <memory> | 9 #include <memory> |
10 #include <string> | 10 #include <string> |
(...skipping 13 matching lines...) Expand all Loading... |
24 | 24 |
25 namespace ntp_snippets { | 25 namespace ntp_snippets { |
26 | 26 |
27 class NTPSnippetsService; | 27 class NTPSnippetsService; |
28 | 28 |
29 // Retrieves suggestions from a number of ContentSuggestionsProviders and serves | 29 // Retrieves suggestions from a number of ContentSuggestionsProviders and serves |
30 // them grouped into categories. There can be at most one provider per category. | 30 // them grouped into categories. There can be at most one provider per category. |
31 class ContentSuggestionsService : public KeyedService, | 31 class ContentSuggestionsService : public KeyedService, |
32 public ContentSuggestionsProvider::Observer { | 32 public ContentSuggestionsProvider::Observer { |
33 public: | 33 public: |
34 using ImageFetchedCallback = | 34 using ImageFetchedCallback = base::Callback<void(const gfx::Image&)>; |
35 base::Callback<void(const std::string& suggestion_id, const gfx::Image&)>; | |
36 using DismissedSuggestionsCallback = base::Callback<void( | 35 using DismissedSuggestionsCallback = base::Callback<void( |
37 std::vector<ContentSuggestion> dismissed_suggestions)>; | 36 std::vector<ContentSuggestion> dismissed_suggestions)>; |
38 | 37 |
39 class Observer { | 38 class Observer { |
40 public: | 39 public: |
41 // Fired every time the service receives a new set of data for the given | 40 // Fired every time the service receives a new set of data for the given |
42 // |category|, replacing any previously available data (though in most cases | 41 // |category|, replacing any previously available data (though in most cases |
43 // there will be an overlap and only a few changes within the data). The new | 42 // there will be an overlap and only a few changes within the data). The new |
44 // data is then available through |GetSuggestionsForCategory(category)|. | 43 // data is then available through |GetSuggestionsForCategory(category)|. |
45 virtual void OnNewSuggestions(Category category) = 0; | 44 virtual void OnNewSuggestions(Category category) = 0; |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 // background fetching and debugging calls to it. If the NTPSnippetsService is | 226 // background fetching and debugging calls to it. If the NTPSnippetsService is |
228 // loaded, it is also present in |providers_|, otherwise this is a nullptr. | 227 // loaded, it is also present in |providers_|, otherwise this is a nullptr. |
229 NTPSnippetsService* ntp_snippets_service_; | 228 NTPSnippetsService* ntp_snippets_service_; |
230 | 229 |
231 DISALLOW_COPY_AND_ASSIGN(ContentSuggestionsService); | 230 DISALLOW_COPY_AND_ASSIGN(ContentSuggestionsService); |
232 }; | 231 }; |
233 | 232 |
234 } // namespace ntp_snippets | 233 } // namespace ntp_snippets |
235 | 234 |
236 #endif // COMPONENTS_NTP_SNIPPETS_CONTENT_SUGGESTIONS_SERVICE_H_ | 235 #endif // COMPONENTS_NTP_SNIPPETS_CONTENT_SUGGESTIONS_SERVICE_H_ |
OLD | NEW |