OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef COMPONENTS_NTP_SNIPPETS_BREAKING_NEWS_BREAKING_NEWS_SUGGESTIONS_PROVIDER
_H_ |
| 6 #define COMPONENTS_NTP_SNIPPETS_BREAKING_NEWS_BREAKING_NEWS_SUGGESTIONS_PROVIDER
_H_ |
| 7 |
| 8 #include "components/ntp_snippets/category.h" |
| 9 #include "components/ntp_snippets/content_suggestions_provider.h" |
| 10 #include "components/prefs/pref_registry_simple.h" |
| 11 |
| 12 namespace ntp_snippets { |
| 13 class ContentSuggestionsGCMAppHandler; |
| 14 } |
| 15 |
| 16 namespace ntp_snippets { |
| 17 |
| 18 // Receives breaking news suggestions via GCM push messages, stores them and |
| 19 // provides them as content suggestions. |
| 20 class BreakingNewsSuggestionsProvider : public ContentSuggestionsProvider { |
| 21 public: |
| 22 BreakingNewsSuggestionsProvider( |
| 23 ContentSuggestionsProvider::Observer* observer, |
| 24 std::unique_ptr<ContentSuggestionsGCMAppHandler> gcm_app_handler); |
| 25 ~BreakingNewsSuggestionsProvider() override; |
| 26 |
| 27 // Starts the underlying GCM handler and registers the callback when GCM |
| 28 // receives a message. |
| 29 void Start(); |
| 30 |
| 31 private: |
| 32 // ContentSuggestionsProvider implementation. |
| 33 CategoryStatus GetCategoryStatus(Category category) override; |
| 34 CategoryInfo GetCategoryInfo(Category category) override; |
| 35 void DismissSuggestion(const ContentSuggestion::ID& suggestion_id) override; |
| 36 void FetchSuggestionImage(const ContentSuggestion::ID& suggestion_id, |
| 37 const ImageFetchedCallback& callback) override; |
| 38 void Fetch(const Category& category, |
| 39 const std::set<std::string>& known_suggestion_ids, |
| 40 const FetchDoneCallback& callback) override; |
| 41 void ClearHistory( |
| 42 base::Time begin, |
| 43 base::Time end, |
| 44 const base::Callback<bool(const GURL& url)>& filter) override; |
| 45 void ClearCachedSuggestions(Category category) override; |
| 46 void GetDismissedSuggestionsForDebugging( |
| 47 Category category, |
| 48 const DismissedSuggestionsCallback& callback) override; |
| 49 void ClearDismissedSuggestionsForDebugging(Category category) override; |
| 50 |
| 51 // Callback called from the GCM handler when new content has been pushed from |
| 52 // the server. |
| 53 void OnNewContentSuggestion(const base::Value& content); |
| 54 |
| 55 std::unique_ptr<ContentSuggestionsGCMAppHandler> gcm_app_handler_; |
| 56 const Category provided_category_; |
| 57 CategoryStatus category_status_; |
| 58 |
| 59 DISALLOW_COPY_AND_ASSIGN(BreakingNewsSuggestionsProvider); |
| 60 }; |
| 61 |
| 62 } // namespace ntp_snippets |
| 63 |
| 64 #endif // COMPONENTS_NTP_SNIPPETS_BREAKING_NEWS_BREAKING_NEWS_SUGGESTIONS_PROVI
DER_H_ |
OLD | NEW |