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 #include "components/ntp_snippets/breaking_news/breaking_news_suggestions_provid
er.h" |
| 6 |
| 7 #include "base/bind.h" |
| 8 #include "components/ntp_snippets/breaking_news/content_suggestions_gcm_app_hand
ler.h" |
| 9 #include "components/ntp_snippets/category.h" |
| 10 #include "components/ntp_snippets/pref_names.h" |
| 11 #include "components/strings/grit/components_strings.h" |
| 12 |
| 13 namespace ntp_snippets { |
| 14 |
| 15 BreakingNewsSuggestionsProvider::BreakingNewsSuggestionsProvider( |
| 16 ContentSuggestionsProvider::Observer* observer, |
| 17 std::unique_ptr<ContentSuggestionsGCMAppHandler> gcm_app_handler) |
| 18 : ContentSuggestionsProvider(observer), |
| 19 gcm_app_handler_(std::move(gcm_app_handler)), |
| 20 provided_category_( |
| 21 Category::FromKnownCategory(KnownCategories::BREAKING_NEWS)), |
| 22 category_status_(CategoryStatus::INITIALIZING) {} |
| 23 |
| 24 BreakingNewsSuggestionsProvider::~BreakingNewsSuggestionsProvider() { |
| 25 gcm_app_handler_->StopListening(); |
| 26 } |
| 27 |
| 28 void BreakingNewsSuggestionsProvider::Start() { |
| 29 // Unretained because |this| owns |gcm_app_handler_|. |
| 30 gcm_app_handler_->StartListening( |
| 31 base::Bind(&BreakingNewsSuggestionsProvider::OnNewContentSuggestion, |
| 32 base::Unretained(this))); |
| 33 } |
| 34 |
| 35 void BreakingNewsSuggestionsProvider::OnNewContentSuggestion( |
| 36 const base::Value& content) {} |
| 37 |
| 38 //////////////////////////////////////////////////////////////////////////////// |
| 39 // Private methods |
| 40 |
| 41 CategoryStatus BreakingNewsSuggestionsProvider::GetCategoryStatus( |
| 42 Category category) { |
| 43 DCHECK_EQ(category, provided_category_); |
| 44 return category_status_; |
| 45 } |
| 46 |
| 47 CategoryInfo BreakingNewsSuggestionsProvider::GetCategoryInfo( |
| 48 Category category) { |
| 49 // TODO(mamir): needs to be corrected, just a placeholer |
| 50 return CategoryInfo(base::string16(), |
| 51 ContentSuggestionsCardLayout::MINIMAL_CARD, |
| 52 ContentSuggestionsAdditionalAction::VIEW_ALL, |
| 53 /*show_if_empty=*/false, base::string16()); |
| 54 } |
| 55 |
| 56 void BreakingNewsSuggestionsProvider::DismissSuggestion( |
| 57 const ContentSuggestion::ID& suggestion_id) {} |
| 58 |
| 59 void BreakingNewsSuggestionsProvider::FetchSuggestionImage( |
| 60 const ContentSuggestion::ID& suggestion_id, |
| 61 const ImageFetchedCallback& callback) {} |
| 62 |
| 63 void BreakingNewsSuggestionsProvider::Fetch( |
| 64 const Category& category, |
| 65 const std::set<std::string>& known_suggestion_ids, |
| 66 const FetchDoneCallback& callback) {} |
| 67 |
| 68 void BreakingNewsSuggestionsProvider::ClearHistory( |
| 69 base::Time begin, |
| 70 base::Time end, |
| 71 const base::Callback<bool(const GURL& url)>& filter) { |
| 72 // TODO(mamir): clear the provider. |
| 73 } |
| 74 |
| 75 void BreakingNewsSuggestionsProvider::ClearCachedSuggestions( |
| 76 Category category) { |
| 77 DCHECK_EQ(category, provided_category_); |
| 78 // TODO(mamir): clear the cached suggestions. |
| 79 } |
| 80 |
| 81 void BreakingNewsSuggestionsProvider::GetDismissedSuggestionsForDebugging( |
| 82 Category category, |
| 83 const DismissedSuggestionsCallback& callback) {} |
| 84 |
| 85 void BreakingNewsSuggestionsProvider::ClearDismissedSuggestionsForDebugging( |
| 86 Category category) {} |
| 87 |
| 88 } // namespace ntp_snippets |
OLD | NEW |