| 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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 // removal of the dismissed suggestion is the only change. | 83 // removal of the dismissed suggestion is the only change. |
| 84 virtual void DismissSuggestion(const std::string& suggestion_id) = 0; | 84 virtual void DismissSuggestion(const std::string& suggestion_id) = 0; |
| 85 | 85 |
| 86 // Fetches the image for the suggestion with the given ID and returns it | 86 // Fetches the image for the suggestion with the given ID and returns it |
| 87 // through the callback. This fetch may occur locally or from the internet. | 87 // through the callback. This fetch may occur locally or from the internet. |
| 88 // If that suggestion doesn't exist, doesn't have an image or if the fetch | 88 // If that suggestion doesn't exist, doesn't have an image or if the fetch |
| 89 // fails, the callback gets a null image. | 89 // fails, the callback gets a null image. |
| 90 virtual void FetchSuggestionImage(const std::string& suggestion_id, | 90 virtual void FetchSuggestionImage(const std::string& suggestion_id, |
| 91 const ImageFetchedCallback& callback) = 0; | 91 const ImageFetchedCallback& callback) = 0; |
| 92 | 92 |
| 93 // Used only for debugging purposes. Clears all caches for the given category, | 93 // Used only for debugging purposes. Clears all caches so that the next |
| 94 // so that the next fetch starts from scratch. | 94 // fetch starts from scratch. |
| 95 virtual void ClearCachedSuggestionsForDebugging(Category category) = 0; | 95 virtual void ClearCachedSuggestionsForDebugging() = 0; |
| 96 | |
| 97 // Used only for debugging purposes. Retrieves suggestions for the given | |
| 98 // |category| that have previously been dismissed and are still stored in the | |
| 99 // provider. If the provider doesn't store dismissed suggestions for the given | |
| 100 // |category|, it always returns an empty vector. | |
| 101 virtual std::vector<ContentSuggestion> GetDismissedSuggestionsForDebugging( | |
| 102 Category category) = 0; | |
| 103 | 96 |
| 104 // Used only for debugging purposes. Clears the cache of dismissed | 97 // Used only for debugging purposes. Clears the cache of dismissed |
| 105 // suggestions for the given |category|, if present, so that no suggestions | 98 // suggestions, if present, so that no suggestions are suppressed. This does |
| 106 // are suppressed. This does not necessarily make previously dismissed | 99 // not necessarily make previously dismissed suggestions reappear, as they may |
| 107 // suggestions reappear, as they may have been permanently deleted, depending | 100 // have been permanently deleted, depending on the provider implementation. |
| 108 // on the provider implementation. | 101 virtual void ClearDismissedSuggestionsForDebugging() = 0; |
| 109 virtual void ClearDismissedSuggestionsForDebugging(Category category) = 0; | |
| 110 | 102 |
| 111 protected: | 103 protected: |
| 112 ContentSuggestionsProvider(Observer* observer, | 104 ContentSuggestionsProvider(Observer* observer, |
| 113 CategoryFactory* category_factory); | 105 CategoryFactory* category_factory); |
| 114 | 106 |
| 115 // Creates a unique ID. The given |within_category_id| must be unique among | 107 // Creates a unique ID. The given |within_category_id| must be unique among |
| 116 // all suggestion IDs from this provider for the given |category|. This method | 108 // all suggestion IDs from this provider for the given |category|. This method |
| 117 // combines it with the |category| to form an ID that is unique | 109 // combines it with the |category| to form an ID that is unique |
| 118 // application-wide, because this provider is the only one that provides | 110 // application-wide, because this provider is the only one that provides |
| 119 // suggestions for that category. | 111 // suggestions for that category. |
| 120 std::string MakeUniqueID(Category category, | 112 std::string MakeUniqueID(Category category, |
| 121 const std::string& within_category_id); | 113 const std::string& within_category_id); |
| 122 | 114 |
| 123 // Reverse functions for MakeUniqueID() | 115 // Reverse functions for MakeUniqueID() |
| 124 Category GetCategoryFromUniqueID(const std::string& unique_id); | 116 Category GetCategoryFromUniqueID(const std::string& unique_id); |
| 125 std::string GetWithinCategoryIDFromUniqueID(const std::string& unique_id); | 117 std::string GetWithinCategoryIDFromUniqueID(const std::string& unique_id); |
| 126 | 118 |
| 127 Observer* observer() const { return observer_; } | 119 Observer* observer() const { return observer_; } |
| 128 CategoryFactory* category_factory() const { return category_factory_; } | 120 CategoryFactory* category_factory() const { return category_factory_; } |
| 129 | 121 |
| 130 private: | 122 private: |
| 131 Observer* observer_; | 123 Observer* observer_; |
| 132 CategoryFactory* category_factory_; | 124 CategoryFactory* category_factory_; |
| 133 }; | 125 }; |
| 134 | 126 |
| 135 } // namespace ntp_snippets | 127 } // namespace ntp_snippets |
| 136 | 128 |
| 137 #endif // COMPONENTS_NTP_SNIPPETS_CONTENT_SUGGESTIONS_PROVIDER_H_ | 129 #endif // COMPONENTS_NTP_SNIPPETS_CONTENT_SUGGESTIONS_PROVIDER_H_ |
| OLD | NEW |