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_PROVIDER_H_ | 5 #ifndef COMPONENTS_NTP_SNIPPETS_CONTENT_SUGGESTIONS_PROVIDER_H_ |
6 #define COMPONENTS_NTP_SNIPPETS_CONTENT_SUGGESTIONS_PROVIDER_H_ | 6 #define COMPONENTS_NTP_SNIPPETS_CONTENT_SUGGESTIONS_PROVIDER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 // Sets an observer which is notified about changes to the available | 64 // Sets an observer which is notified about changes to the available |
65 // suggestions, or removes it by passing a nullptr. The provider does not take | 65 // suggestions, or removes it by passing a nullptr. The provider does not take |
66 // ownership of the observer and the observer must outlive this provider. | 66 // ownership of the observer and the observer must outlive this provider. |
67 virtual void SetObserver(Observer* observer) = 0; | 67 virtual void SetObserver(Observer* observer) = 0; |
68 | 68 |
69 // Determines the status of the given |category|, see | 69 // Determines the status of the given |category|, see |
70 // ContentSuggestionsCategoryStatus. | 70 // ContentSuggestionsCategoryStatus. |
71 virtual ContentSuggestionsCategoryStatus GetCategoryStatus( | 71 virtual ContentSuggestionsCategoryStatus GetCategoryStatus( |
72 ContentSuggestionsCategory category) = 0; | 72 ContentSuggestionsCategory category) = 0; |
73 | 73 |
74 // Discards the suggestion with the given ID. A provider needs to ensure that | 74 // Dismisses the suggestion with the given ID. A provider needs to ensure that |
75 // a once-discarded suggestion is never delivered again (through the | 75 // a once-dismissed suggestion is never delivered again (through the |
76 // Observer). The provider must not call Observer::OnSuggestionsChanged if the | 76 // Observer). The provider must not call Observer::OnSuggestionsChanged if the |
77 // removal of the discarded suggestion is the only change. | 77 // removal of the dismissed suggestion is the only change. |
78 virtual void DiscardSuggestion(const std::string& suggestion_id) = 0; | 78 virtual void DismissSuggestion(const std::string& suggestion_id) = 0; |
79 | 79 |
80 // Fetches the image for the suggestion with the given ID and returns it | 80 // Fetches the image for the suggestion with the given ID and returns it |
81 // through the callback. This fetch may occur locally or from the internet. | 81 // through the callback. This fetch may occur locally or from the internet. |
82 // If that suggestion doesn't exist, doesn't have an image or if the fetch | 82 // If that suggestion doesn't exist, doesn't have an image or if the fetch |
83 // fails, the callback gets a null image. | 83 // fails, the callback gets a null image. |
84 virtual void FetchSuggestionImage(const std::string& suggestion_id, | 84 virtual void FetchSuggestionImage(const std::string& suggestion_id, |
85 const ImageFetchedCallback& callback) = 0; | 85 const ImageFetchedCallback& callback) = 0; |
86 | 86 |
87 // Used only for debugging purposes. Clears all caches so that the next | 87 // Used only for debugging purposes. Clears all caches so that the next |
88 // fetch starts from scratch. | 88 // fetch starts from scratch. |
89 virtual void ClearCachedSuggestionsForDebugging() = 0; | 89 virtual void ClearCachedSuggestionsForDebugging() = 0; |
90 | 90 |
91 // Used only for debugging purposes. Clears the cache of discarded | 91 // Used only for debugging purposes. Clears the cache of dismissed |
92 // suggestions, if present, so that no suggestions are suppressed. This does | 92 // suggestions, if present, so that no suggestions are suppressed. This does |
93 // not necessarily make previously discarded suggestions reappear, as they may | 93 // not necessarily make previously dismissed suggestions reappear, as they may |
94 // have been permanently deleted, depending on the provider implementation. | 94 // have been permanently deleted, depending on the provider implementation. |
95 virtual void ClearDiscardedSuggestionsForDebugging() = 0; | 95 virtual void ClearDismissedSuggestionsForDebugging() = 0; |
96 | 96 |
97 const std::vector<ContentSuggestionsCategory>& provided_categories() const { | 97 const std::vector<ContentSuggestionsCategory>& provided_categories() const { |
98 return provided_categories_; | 98 return provided_categories_; |
99 } | 99 } |
100 | 100 |
101 protected: | 101 protected: |
102 ContentSuggestionsProvider( | 102 ContentSuggestionsProvider( |
103 const std::vector<ContentSuggestionsCategory>& provided_categories); | 103 const std::vector<ContentSuggestionsCategory>& provided_categories); |
104 virtual ~ContentSuggestionsProvider(); | 104 virtual ~ContentSuggestionsProvider(); |
105 | 105 |
(...skipping 10 matching lines...) Expand all Loading... |
116 static std::string GetWithinCategoryIDFromUniqueID( | 116 static std::string GetWithinCategoryIDFromUniqueID( |
117 const std::string& unique_id); | 117 const std::string& unique_id); |
118 | 118 |
119 private: | 119 private: |
120 const std::vector<ContentSuggestionsCategory> provided_categories_; | 120 const std::vector<ContentSuggestionsCategory> provided_categories_; |
121 }; | 121 }; |
122 | 122 |
123 } // namespace ntp_snippets | 123 } // namespace ntp_snippets |
124 | 124 |
125 #endif // COMPONENTS_NTP_SNIPPETS_CONTENT_SUGGESTIONS_PROVIDER_H_ | 125 #endif // COMPONENTS_NTP_SNIPPETS_CONTENT_SUGGESTIONS_PROVIDER_H_ |
OLD | NEW |