| 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 virtual void OnCategoryStatusChanged( | 55 virtual void OnCategoryStatusChanged( |
| 56 ContentSuggestionsCategory changed_category, | 56 ContentSuggestionsCategory changed_category, |
| 57 ContentSuggestionsCategoryStatus new_status) = 0; | 57 ContentSuggestionsCategoryStatus new_status) = 0; |
| 58 | 58 |
| 59 // Called when the provider needs to shut down and will not deliver any | 59 // Called when the provider needs to shut down and will not deliver any |
| 60 // suggestions anymore. | 60 // suggestions anymore. |
| 61 virtual void OnProviderShutdown(ContentSuggestionsProvider* provider) = 0; | 61 virtual void OnProviderShutdown(ContentSuggestionsProvider* provider) = 0; |
| 62 }; | 62 }; |
| 63 | 63 |
| 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. | 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 virtual void SetObserver(Observer* observer) = 0; | 67 virtual void SetObserver(Observer* observer) = 0; |
| 67 | 68 |
| 68 // Determines the status of the given |category|, see | 69 // Determines the status of the given |category|, see |
| 69 // ContentSuggestionsCategoryStatus. | 70 // ContentSuggestionsCategoryStatus. |
| 70 virtual ContentSuggestionsCategoryStatus GetCategoryStatus( | 71 virtual ContentSuggestionsCategoryStatus GetCategoryStatus( |
| 71 ContentSuggestionsCategory category) = 0; | 72 ContentSuggestionsCategory category) = 0; |
| 72 | 73 |
| 73 // Discards the suggestion with the given ID. A provider needs to ensure that | 74 // Discards the suggestion with the given ID. A provider needs to ensure that |
| 74 // a once-discarded suggestion is never delivered again (through the | 75 // a once-discarded suggestion is never delivered again (through the |
| 75 // Observer). The provider must not call Observer::OnSuggestionsChanged if the | 76 // Observer). The provider must not call Observer::OnSuggestionsChanged if the |
| 76 // removal of the discarded suggestion is the only change. | 77 // removal of the discarded suggestion is the only change. |
| 77 virtual void DiscardSuggestion(const std::string& suggestion_id) = 0; | 78 virtual void DiscardSuggestion(const std::string& suggestion_id) = 0; |
| 78 | 79 |
| 79 // 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 |
| 80 // 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 |
| 83 // fails, the callback gets a null image. |
| 81 virtual void FetchSuggestionImage(const std::string& suggestion_id, | 84 virtual void FetchSuggestionImage(const std::string& suggestion_id, |
| 82 const ImageFetchedCallback& callback) = 0; | 85 const ImageFetchedCallback& callback) = 0; |
| 83 | 86 |
| 84 // 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 |
| 85 // fetch starts from scratch. | 88 // fetch starts from scratch. |
| 86 virtual void ClearCachedSuggestionsForDebugging() = 0; | 89 virtual void ClearCachedSuggestionsForDebugging() = 0; |
| 87 | 90 |
| 88 // Used only for debugging purposes. Clears the cache of discarded | 91 // Used only for debugging purposes. Clears the cache of discarded |
| 89 // suggestions, if present, so that no suggestions are suppressed. This does | 92 // suggestions, if present, so that no suggestions are suppressed. This does |
| 90 // not necessarily make previously discarded suggestions reappear, as they may | 93 // not necessarily make previously discarded suggestions reappear, as they may |
| (...skipping 17 matching lines...) Expand all Loading... |
| 108 static std::string MakeUniqueID(ContentSuggestionsCategory category, | 111 static std::string MakeUniqueID(ContentSuggestionsCategory category, |
| 109 const std::string& within_category_id); | 112 const std::string& within_category_id); |
| 110 | 113 |
| 111 private: | 114 private: |
| 112 const std::vector<ContentSuggestionsCategory> provided_categories_; | 115 const std::vector<ContentSuggestionsCategory> provided_categories_; |
| 113 }; | 116 }; |
| 114 | 117 |
| 115 } // namespace ntp_snippets | 118 } // namespace ntp_snippets |
| 116 | 119 |
| 117 #endif // COMPONENTS_NTP_SNIPPETS_CONTENT_SUGGESTIONS_PROVIDER_H_ | 120 #endif // COMPONENTS_NTP_SNIPPETS_CONTENT_SUGGESTIONS_PROVIDER_H_ |
| OLD | NEW |