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> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/callback_forward.h" | 13 #include "base/callback_forward.h" |
14 #include "base/observer_list.h" | 14 #include "base/observer_list.h" |
15 #include "base/optional.h" | |
15 #include "components/keyed_service/core/keyed_service.h" | 16 #include "components/keyed_service/core/keyed_service.h" |
16 #include "components/ntp_snippets/category_factory.h" | 17 #include "components/ntp_snippets/category_factory.h" |
17 #include "components/ntp_snippets/category_status.h" | 18 #include "components/ntp_snippets/category_status.h" |
18 #include "components/ntp_snippets/content_suggestions_provider.h" | 19 #include "components/ntp_snippets/content_suggestions_provider.h" |
19 | 20 |
20 namespace gfx { | 21 namespace gfx { |
21 class Image; | 22 class Image; |
22 } | 23 } |
23 | 24 |
24 namespace ntp_snippets { | 25 namespace ntp_snippets { |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
71 | 72 |
72 State state() { return state_; } | 73 State state() { return state_; } |
73 | 74 |
74 // Gets all categories for which a provider is registered. The categories | 75 // Gets all categories for which a provider is registered. The categories |
75 // may or may not be available, see |GetCategoryStatus()|. | 76 // may or may not be available, see |GetCategoryStatus()|. |
76 const std::vector<Category>& GetCategories() const { return categories_; } | 77 const std::vector<Category>& GetCategories() const { return categories_; } |
77 | 78 |
78 // Gets the status of a category. | 79 // Gets the status of a category. |
79 CategoryStatus GetCategoryStatus(Category category) const; | 80 CategoryStatus GetCategoryStatus(Category category) const; |
80 | 81 |
82 // Gets the meta information of a category. | |
83 base::Optional<CategoryInfo> GetCategoryInfo(Category category) const; | |
Bernhard Bauer
2016/08/09 09:18:33
Hum. You go to all these lengths to implement a mo
Marc Treib
2016/08/09 09:45:12
CategoryInfo doesn't have a copy ctor, so it can't
Philipp Keck
2016/08/09 10:03:06
Indeed, the only relevant call we have (https://co
Bernhard Bauer
2016/08/09 10:25:41
If you are saying that over time Optional<> will r
Philipp Keck
2016/08/09 11:24:27
The callsites will change soon:
https://codereview
| |
84 | |
81 // Gets the available suggestions for a category. The result is empty if the | 85 // Gets the available suggestions for a category. The result is empty if the |
82 // category is available and empty, but also if the category is unavailable | 86 // category is available and empty, but also if the category is unavailable |
83 // for any reason, see |GetCategoryStatus()|. | 87 // for any reason, see |GetCategoryStatus()|. |
84 const std::vector<ContentSuggestion>& GetSuggestionsForCategory( | 88 const std::vector<ContentSuggestion>& GetSuggestionsForCategory( |
85 Category category) const; | 89 Category category) const; |
86 | 90 |
87 // Fetches the image for the suggestion with the given |suggestion_id| and | 91 // Fetches the image for the suggestion with the given |suggestion_id| and |
88 // runs the |callback|. If that suggestion doesn't exist or the fetch fails, | 92 // runs the |callback|. If that suggestion doesn't exist or the fetch fails, |
89 // the callback gets an empty image. | 93 // the callback gets an empty image. |
90 void FetchSuggestionImage(const std::string& suggestion_id, | 94 void FetchSuggestionImage(const std::string& suggestion_id, |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
193 // background fetching and debugging calls to it. If the NTPSnippetsService is | 197 // background fetching and debugging calls to it. If the NTPSnippetsService is |
194 // loaded, it is also present in |providers_|, otherwise this is a nullptr. | 198 // loaded, it is also present in |providers_|, otherwise this is a nullptr. |
195 NTPSnippetsService* ntp_snippets_service_; | 199 NTPSnippetsService* ntp_snippets_service_; |
196 | 200 |
197 DISALLOW_COPY_AND_ASSIGN(ContentSuggestionsService); | 201 DISALLOW_COPY_AND_ASSIGN(ContentSuggestionsService); |
198 }; | 202 }; |
199 | 203 |
200 } // namespace ntp_snippets | 204 } // namespace ntp_snippets |
201 | 205 |
202 #endif // COMPONENTS_NTP_SNIPPETS_CONTENT_SUGGESTIONS_SERVICE_H_ | 206 #endif // COMPONENTS_NTP_SNIPPETS_CONTENT_SUGGESTIONS_SERVICE_H_ |
OLD | NEW |