Chromium Code Reviews| Index: chrome/browser/push_messaging/push_messaging_service_impl.cc |
| diff --git a/chrome/browser/push_messaging/push_messaging_service_impl.cc b/chrome/browser/push_messaging/push_messaging_service_impl.cc |
| index fb17878021d22470422affa12fcf86604e0f574c..c7b3fced9c809c46090ec6cb22c269400c84e5da 100644 |
| --- a/chrome/browser/push_messaging/push_messaging_service_impl.cc |
| +++ b/chrome/browser/push_messaging/push_messaging_service_impl.cc |
| @@ -217,14 +217,17 @@ void PushMessagingServiceImpl::OnMessage(const std::string& app_id, |
| g_browser_process->rappor_service(), |
| "PushMessaging.MessageReceived.Origin", app_identifier.origin()); |
| - std::string data; |
| - if (AreMessagePayloadsEnabled() && message.decrypted) |
| - data = message.raw_data; |
| + // The payload of a push message can be valid with content, valid with empty |
| + // content, or null. Only set the payload data if it is non-null. |
| + content::PushEventPayload payload; |
| + if (AreMessagePayloadsEnabled() && message.decrypted) { |
| + payload.setData(message.raw_data); |
|
Peter Beverloo
2016/01/25 17:39:06
nit: we don't use curly brackets for one-line cond
harkness
2016/01/26 12:07:19
Done.
|
| + } |
| // Dispatch the message to the appropriate Service Worker. |
| content::BrowserContext::DeliverPushMessage( |
| profile_, app_identifier.origin(), |
| - app_identifier.service_worker_registration_id(), data, |
| + app_identifier.service_worker_registration_id(), payload, |
| base::Bind(&PushMessagingServiceImpl::DeliverMessageCallback, |
| weak_factory_.GetWeakPtr(), app_identifier.app_id(), |
| app_identifier.origin(), |
| @@ -235,7 +238,7 @@ void PushMessagingServiceImpl::OnMessage(const std::string& app_id, |
| if (!message_dispatched_callback_for_testing_.is_null()) { |
| message_dispatched_callback_for_testing_.Run( |
| app_id, app_identifier.origin(), |
| - app_identifier.service_worker_registration_id(), data); |
| + app_identifier.service_worker_registration_id(), payload); |
| } |
| } |