Chromium Code Reviews| Index: components/ntp_snippets/breaking_news/breaking_news_suggestions_provider.cc |
| diff --git a/components/ntp_snippets/breaking_news/breaking_news_suggestions_provider.cc b/components/ntp_snippets/breaking_news/breaking_news_suggestions_provider.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..fc9cf76ee40da20b7614df62c5088afa492ec672 |
| --- /dev/null |
| +++ b/components/ntp_snippets/breaking_news/breaking_news_suggestions_provider.cc |
| @@ -0,0 +1,85 @@ |
| +// Copyright 2017 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "components/ntp_snippets/breaking_news/breaking_news_suggestions_provider.h" |
| + |
| +#include "base/bind.h" |
| +#include "components/ntp_snippets/breaking_news/content_suggestions_gcm_app_handler.h" |
| +#include "components/ntp_snippets/category.h" |
| +#include "components/ntp_snippets/pref_names.h" |
| +#include "components/strings/grit/components_strings.h" |
| + |
| +namespace ntp_snippets { |
| + |
| +BreakingNewsSuggestionsProvider::BreakingNewsSuggestionsProvider( |
| + ContentSuggestionsProvider::Observer* observer, |
| + std::unique_ptr<ContentSuggestionsGCMAppHandler> gcm_app_handler) |
| + : ContentSuggestionsProvider(observer), |
| + gcm_app_handler_(std::move(gcm_app_handler)), |
| + provided_category_( |
| + Category::FromKnownCategory(KnownCategories::BREAKING_NEWS)) {} |
|
sfiera
2017/06/08 13:37:15
Please initialize category_status_ here.
mamir
2017/06/08 15:20:06
Done.
|
| + |
| +BreakingNewsSuggestionsProvider::~BreakingNewsSuggestionsProvider() { |
| + gcm_app_handler_->StopListening(); |
| +} |
| + |
| +void BreakingNewsSuggestionsProvider::Start() { |
| + // TDOD(mamir): Is unretained the correct method to use? |
|
sfiera
2017/06/08 13:37:15
Yes. I would add a comment like:
// Unretained b
mamir
2017/06/08 15:20:06
Done.
|
| + gcm_app_handler_->StartListening( |
| + base::Bind(&BreakingNewsSuggestionsProvider::OnNewContentSuggestion, |
| + base::Unretained(this))); |
| +} |
| + |
| +void BreakingNewsSuggestionsProvider::OnNewContentSuggestion( |
| + const std::string& content) {} |
| + |
| +//////////////////////////////////////////////////////////////////////////////// |
| +// Private methods |
| + |
| +CategoryStatus BreakingNewsSuggestionsProvider::GetCategoryStatus( |
| + Category category) { |
| + DCHECK_EQ(category, provided_category_); |
| + return category_status_; |
| +} |
| + |
| +CategoryInfo BreakingNewsSuggestionsProvider::GetCategoryInfo( |
| + Category category) { |
| + // TODO(mamir): needs to be corrected, just a placeholer |
| + return CategoryInfo(base::string16(), |
| + ContentSuggestionsCardLayout::MINIMAL_CARD, |
| + ContentSuggestionsAdditionalAction::VIEW_ALL, |
| + /*show_if_empty=*/false, base::string16()); |
| +} |
| + |
| +void BreakingNewsSuggestionsProvider::DismissSuggestion( |
| + const ContentSuggestion::ID& suggestion_id) {} |
| + |
| +void BreakingNewsSuggestionsProvider::FetchSuggestionImage( |
| + const ContentSuggestion::ID& suggestion_id, |
| + const ImageFetchedCallback& callback) {} |
| + |
| +void BreakingNewsSuggestionsProvider::Fetch( |
| + const Category& category, |
| + const std::set<std::string>& known_suggestion_ids, |
| + const FetchDoneCallback& callback) {} |
| + |
| +void BreakingNewsSuggestionsProvider::ClearHistory( |
| + base::Time begin, |
| + base::Time end, |
| + const base::Callback<bool(const GURL& url)>& filter) {} |
|
sfiera
2017/06/08 13:37:15
Should have a TODO(mamir) to clear the provider (I
mamir
2017/06/08 15:20:06
Done.
|
| + |
| +void BreakingNewsSuggestionsProvider::ClearCachedSuggestions( |
| + Category category) { |
| + DCHECK_EQ(category, provided_category_); |
| + // Ignored. |
|
sfiera
2017/06/08 13:37:15
Likewise?
mamir
2017/06/08 15:20:06
Done.
|
| +} |
| + |
| +void BreakingNewsSuggestionsProvider::GetDismissedSuggestionsForDebugging( |
| + Category category, |
| + const DismissedSuggestionsCallback& callback) {} |
| + |
| +void BreakingNewsSuggestionsProvider::ClearDismissedSuggestionsForDebugging( |
| + Category category) {} |
| + |
| +} // namespace ntp_snippets |