| 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; |
| 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 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 // background fetching and debugging calls to it. If the NTPSnippetsService is | 211 // background fetching and debugging calls to it. If the NTPSnippetsService is |
| 208 // loaded, it is also present in |providers_|, otherwise this is a nullptr. | 212 // loaded, it is also present in |providers_|, otherwise this is a nullptr. |
| 209 NTPSnippetsService* ntp_snippets_service_; | 213 NTPSnippetsService* ntp_snippets_service_; |
| 210 | 214 |
| 211 DISALLOW_COPY_AND_ASSIGN(ContentSuggestionsService); | 215 DISALLOW_COPY_AND_ASSIGN(ContentSuggestionsService); |
| 212 }; | 216 }; |
| 213 | 217 |
| 214 } // namespace ntp_snippets | 218 } // namespace ntp_snippets |
| 215 | 219 |
| 216 #endif // COMPONENTS_NTP_SNIPPETS_CONTENT_SUGGESTIONS_SERVICE_H_ | 220 #endif // COMPONENTS_NTP_SNIPPETS_CONTENT_SUGGESTIONS_SERVICE_H_ |
| OLD | NEW |