| 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 // If |new_status| is any other value, it must match the value that is | 57 // If |new_status| is any other value, it must match the value that is |
| 58 // currently returned from the provider's |GetCategoryStatus(category)|. In | 58 // currently returned from the provider's |GetCategoryStatus(category)|. In |
| 59 // case the given |category| is not known yet, the calling |provider| will | 59 // case the given |category| is not known yet, the calling |provider| will |
| 60 // be registered as its provider. Whenever the status changes to an | 60 // be registered as its provider. Whenever the status changes to an |
| 61 // unavailable status, all suggestions in that category must immediately be | 61 // unavailable status, all suggestions in that category must immediately be |
| 62 // removed from all caches and from the UI, but the provider remains | 62 // removed from all caches and from the UI, but the provider remains |
| 63 // registered. | 63 // registered. |
| 64 virtual void OnCategoryStatusChanged(ContentSuggestionsProvider* provider, | 64 virtual void OnCategoryStatusChanged(ContentSuggestionsProvider* provider, |
| 65 Category category, | 65 Category category, |
| 66 CategoryStatus new_status) = 0; | 66 CategoryStatus new_status) = 0; |
| 67 |
| 68 // Called when a suggestion has been invalidated. It will not be provided |
| 69 // through |OnNewSuggestions| anymore, is not supported by |
| 70 // |FetchSuggestionImage| or |DismissSuggestion| anymore, and should |
| 71 // immediately be cleared from the UI and caches. This happens, for example, |
| 72 // when the content that the suggestion refers to is gone. |
| 73 // Note that this event may be fired even if the corresponding |category| is |
| 74 // not currently AVAILABLE, because open UIs may still be showing the |
| 75 // suggestion that is to be removed. This event may also be fired for |
| 76 // |suggestion_id|s that never existed and should be ignored in that case. |
| 77 virtual void OnSuggestionInvalidated(ContentSuggestionsProvider* provider, |
| 78 Category category, |
| 79 const std::string& suggestion_id) = 0; |
| 67 }; | 80 }; |
| 68 | 81 |
| 69 virtual ~ContentSuggestionsProvider(); | 82 virtual ~ContentSuggestionsProvider(); |
| 70 | 83 |
| 71 // Returns the categories provided by this provider. | 84 // Returns the categories provided by this provider. |
| 72 // When the set of provided categories changes, the Observer is notified | 85 // When the set of provided categories changes, the Observer is notified |
| 73 // through |OnNewSuggestions| or |OnCategoryStatusChanged| for added | 86 // through |OnNewSuggestions| or |OnCategoryStatusChanged| for added |
| 74 // categories, and through |OnCategoryStatusChanged| with parameter | 87 // categories, and through |OnCategoryStatusChanged| with parameter |
| 75 // NOT_PROVIDED for removed categories. | 88 // NOT_PROVIDED for removed categories. |
| 76 virtual std::vector<Category> GetProvidedCategories() = 0; | 89 virtual std::vector<Category> GetProvidedCategories() = 0; |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 CategoryFactory* category_factory() const { return category_factory_; } | 147 CategoryFactory* category_factory() const { return category_factory_; } |
| 135 | 148 |
| 136 private: | 149 private: |
| 137 Observer* observer_; | 150 Observer* observer_; |
| 138 CategoryFactory* category_factory_; | 151 CategoryFactory* category_factory_; |
| 139 }; | 152 }; |
| 140 | 153 |
| 141 } // namespace ntp_snippets | 154 } // namespace ntp_snippets |
| 142 | 155 |
| 143 #endif // COMPONENTS_NTP_SNIPPETS_CONTENT_SUGGESTIONS_PROVIDER_H_ | 156 #endif // COMPONENTS_NTP_SNIPPETS_CONTENT_SUGGESTIONS_PROVIDER_H_ |
| OLD | NEW |