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

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

Issue 2925053003: [NTP::Push] Adding BreakingNewsSuggestionsProvider (Closed)
Patch Set: Fixing the build. 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 4ea1acc6dc57e9d54fd7c4be42369da963800646..f19a5010dc37969de6c4a6f1f0ee1e0adf07a51a 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,23 @@ 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();
+ // TODO(mamir): Check which token should be used for unsubscription when
+ // handling change in the token.
std::string token = pref_service_->GetString(
ntp_snippets::prefs::kContentSuggestionsGCMSubscriptionTokenCache);
subscription_manager_->Unsubscribe(token);
@@ -110,7 +115,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());
}
void ContentSuggestionsGCMAppHandler::OnMessagesDeleted(

Powered by Google App Engine
This is Rietveld 408576698