Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(122)

Unified Diff: components/ntp_snippets/breaking_news/content_suggestions_gcm_app_handler.cc

Issue 2925053003: [NTP::Push] Adding BreakingNewsSuggestionsProvider (Closed)
Patch Set: sfiera@ comments. Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: components/ntp_snippets/breaking_news/content_suggestions_gcm_app_handler.cc
diff --git a/components/ntp_snippets/breaking_news/content_suggestions_gcm_app_handler.cc b/components/ntp_snippets/breaking_news/content_suggestions_gcm_app_handler.cc
index 77b55a0bba2df514fcdc293700e2026333383c1d..41fafec37bf36ab19f55ec521f7aace3584b7f2f 100644
--- a/components/ntp_snippets/breaking_news/content_suggestions_gcm_app_handler.cc
+++ b/components/ntp_snippets/breaking_news/content_suggestions_gcm_app_handler.cc
@@ -40,18 +40,21 @@ ContentSuggestionsGCMAppHandler::~ContentSuggestionsGCMAppHandler() {
StopListening();
}
-void ContentSuggestionsGCMAppHandler::StartListening() {
+void ContentSuggestionsGCMAppHandler::StartListening(
+ OnNewContentCallback on_new_content_callback) {
#if !defined(OS_ANDROID)
NOTREACHED()
<< "The ContentSuggestionsGCMAppHandler should only be used on Android.";
#endif
Subscribe();
+ on_new_content_callback_ = std::move(on_new_content_callback);
gcm_driver_->AddAppHandler(kContentSuggestionsGCMAppID, this);
}
void ContentSuggestionsGCMAppHandler::StopListening() {
DCHECK_EQ(gcm_driver_->GetAppHandler(kContentSuggestionsGCMAppID), this);
gcm_driver_->RemoveAppHandler(kContentSuggestionsGCMAppID);
+ on_new_content_callback_ = OnNewContentCallback();
std::string token = pref_service_->GetString(
ntp_snippets::prefs::kContentSuggestionsGCMSubscriptionTokenCache);
subscription_manager_->Unsubscribe(token);
@@ -105,7 +108,8 @@ void ContentSuggestionsGCMAppHandler::OnStoreReset() {
void ContentSuggestionsGCMAppHandler::OnMessage(
const std::string& app_id,
const gcm::IncomingMessage& message) {
- // TODO(mamir): Implement Show notification and update the feed.
+ // TODO(mamir): Build the message.
+ on_new_content_callback_.Run(base::Value());
jkrcal 2017/06/09 11:32:59 Are you sure this will never get called after Stop
mamir 2017/06/09 14:41:01 Yes, this won't be called after StopListening beca
}
void ContentSuggestionsGCMAppHandler::OnMessagesDeleted(

Powered by Google App Engine
This is Rietveld 408576698