Chromium Code Reviews| 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 13 matching lines...) Expand all Loading... | |
| 24 // A provider can provide suggestions for multiple ContentSuggestionCategories, | 24 // A provider can provide suggestions for multiple ContentSuggestionCategories, |
| 25 // but for every category that it provides, it will be the only provider in the | 25 // but for every category that it provides, it will be the only provider in the |
| 26 // system which provides suggestions for that category. | 26 // system which provides suggestions for that category. |
| 27 // Providers are created by the ContentSuggestionsServiceFactory and owned and | 27 // Providers are created by the ContentSuggestionsServiceFactory and owned and |
| 28 // shut down by the ContentSuggestionsService. | 28 // shut down by the ContentSuggestionsService. |
| 29 class ContentSuggestionsProvider { | 29 class ContentSuggestionsProvider { |
| 30 public: | 30 public: |
| 31 using ImageFetchedCallback = base::Callback<void(const gfx::Image&)>; | 31 using ImageFetchedCallback = base::Callback<void(const gfx::Image&)>; |
| 32 using DismissedSuggestionsCallback = base::Callback<void( | 32 using DismissedSuggestionsCallback = base::Callback<void( |
| 33 std::vector<ContentSuggestion> dismissed_suggestions)>; | 33 std::vector<ContentSuggestion> dismissed_suggestions)>; |
| 34 using FetchedMoreCallback = | |
|
vitaliii
2016/11/01 23:29:57
nit: FetchMoreCallback or MultipleContentSuggestio
fhorschig
2016/11/02 05:05:27
Renamed (but shorter) in CL 2466863003.
| |
| 35 base::Callback<void(std::vector<ContentSuggestion> suggestions)>; | |
| 34 | 36 |
| 35 // The observer of a provider is notified when new data is available. | 37 // The observer of a provider is notified when new data is available. |
| 36 class Observer { | 38 class Observer { |
| 37 public: | 39 public: |
| 38 // Called when the available content changed. | 40 // Called when the available content changed. |
| 39 // If a provider provides suggestions for multiple categories, this callback | 41 // If a provider provides suggestions for multiple categories, this callback |
| 40 // is called once per category. The |suggestions| parameter always contains | 42 // is called once per category. The |suggestions| parameter always contains |
| 41 // the full list of currently available suggestions for that category, i.e., | 43 // the full list of currently available suggestions for that category, i.e., |
| 42 // an empty list will remove all suggestions from the given category. Note | 44 // an empty list will remove all suggestions from the given category. Note |
| 43 // that to clear them from the UI immediately, the provider needs to change | 45 // that to clear them from the UI immediately, the provider needs to change |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 93 const ContentSuggestion::ID& suggestion_id) = 0; | 95 const ContentSuggestion::ID& suggestion_id) = 0; |
| 94 | 96 |
| 95 // Fetches the image for the suggestion with the given ID and returns it | 97 // Fetches the image for the suggestion with the given ID and returns it |
| 96 // through the callback. This fetch may occur locally or from the internet. | 98 // through the callback. This fetch may occur locally or from the internet. |
| 97 // If that suggestion doesn't exist, doesn't have an image or if the fetch | 99 // If that suggestion doesn't exist, doesn't have an image or if the fetch |
| 98 // fails, the callback gets a null image. The callback will not be called | 100 // fails, the callback gets a null image. The callback will not be called |
| 99 // synchronously. | 101 // synchronously. |
| 100 virtual void FetchSuggestionImage(const ContentSuggestion::ID& suggestion_id, | 102 virtual void FetchSuggestionImage(const ContentSuggestion::ID& suggestion_id, |
| 101 const ImageFetchedCallback& callback) = 0; | 103 const ImageFetchedCallback& callback) = 0; |
| 102 | 104 |
| 105 // A user-triggered request to fetch more content for the given category. | |
|
vitaliii
2016/11/01 23:29:57
"User-triggered" seems to be not relevant here, th
fhorschig
2016/11/02 05:05:27
Done. (in CL 2466863003)
| |
| 106 // Provides only suggestions that have not been provided. The given |callback| | |
|
vitaliii
2016/11/01 23:29:57
This sentence looks contradicting to the next line
fhorschig
2016/11/02 05:05:27
Done. (in CL 2466863003)
| |
| 107 // is called with these suggestion, along with all existing suggestions. | |
|
vitaliii
2016/11/01 23:29:57
s/suggestion/suggestionS
fhorschig
2016/11/02 05:05:27
Done. (in CL 2466863003)
| |
| 108 virtual void FetchMore(const Category& category, | |
| 109 const FetchedMoreCallback& callback) = 0; | |
| 110 | |
| 103 // Removes history from the specified time range where the URL matches the | 111 // Removes history from the specified time range where the URL matches the |
| 104 // |filter|. The data removed depends on the provider. Note that the | 112 // |filter|. The data removed depends on the provider. Note that the |
| 105 // data outside the time range may be deleted, for example suggestions, which | 113 // data outside the time range may be deleted, for example suggestions, which |
| 106 // are based on history from that time range. Providers should immediately | 114 // are based on history from that time range. Providers should immediately |
| 107 // clear any data related to history from the specified time range where the | 115 // clear any data related to history from the specified time range where the |
| 108 // URL matches the |filter|. | 116 // URL matches the |filter|. |
| 109 virtual void ClearHistory( | 117 virtual void ClearHistory( |
| 110 base::Time begin, | 118 base::Time begin, |
| 111 base::Time end, | 119 base::Time end, |
| 112 const base::Callback<bool(const GURL& url)>& filter) = 0; | 120 const base::Callback<bool(const GURL& url)>& filter) = 0; |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 139 CategoryFactory* category_factory() const { return category_factory_; } | 147 CategoryFactory* category_factory() const { return category_factory_; } |
| 140 | 148 |
| 141 private: | 149 private: |
| 142 Observer* observer_; | 150 Observer* observer_; |
| 143 CategoryFactory* category_factory_; | 151 CategoryFactory* category_factory_; |
| 144 }; | 152 }; |
| 145 | 153 |
| 146 } // namespace ntp_snippets | 154 } // namespace ntp_snippets |
| 147 | 155 |
| 148 #endif // COMPONENTS_NTP_SNIPPETS_CONTENT_SUGGESTIONS_PROVIDER_H_ | 156 #endif // COMPONENTS_NTP_SNIPPETS_CONTENT_SUGGESTIONS_PROVIDER_H_ |
| OLD | NEW |