| 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 b01f0aaf01091c9a27322bd4771c75819d559207..800a16a931f989850dc806e6226bf08109563ab5 100644
|
| --- a/chrome/browser/push_messaging/push_messaging_service_impl.cc
|
| +++ b/chrome/browser/push_messaging/push_messaging_service_impl.cc
|
| @@ -277,12 +277,34 @@ void PushMessagingServiceImpl::OnMessage(const std::string& app_id,
|
| content::PUSH_DELIVERY_STATUS_UNKNOWN_APP_ID);
|
| return;
|
| }
|
| - // Drop message and unregister if |origin| has lost push permission.
|
| - if (!IsPermissionSet(app_identifier.origin())) {
|
| +
|
| + // Drop message and unregister if |origin| has lost push permission. However,
|
| + // we should only drop the subscription if the permission was in fact denied
|
| + // rather than suspended, for example through the kill switch.
|
| + PermissionResult permission_result =
|
| + PermissionManager::Get(profile_)->GetPermissionStatus(
|
| + CONTENT_SETTINGS_TYPE_PUSH_MESSAGING, app_identifier.origin(),
|
| + app_identifier.origin());
|
| +
|
| + if (permission_result.content_setting != CONTENT_SETTING_ALLOW) {
|
| + content::PushDeliveryStatus status =
|
| + content::PUSH_DELIVERY_STATUS_PERMISSION_DENIED;
|
| +
|
| + switch (permission_result.source) {
|
| + case PermissionStatusSource::KILL_SWITCH:
|
| + status = content::PUSH_DELIVERY_STATUS_PERMISSION_SUSPENDED;
|
| + break;
|
| + case PermissionStatusSource::UNSPECIFIED:
|
| + case PermissionStatusSource::SAFE_BROWSING_BLACKLIST:
|
| + case PermissionStatusSource::MULTIPLE_DISMISSALS:
|
| + case PermissionStatusSource::MULTIPLE_IGNORES:
|
| + status = content::PUSH_DELIVERY_STATUS_PERMISSION_DENIED;
|
| + break;
|
| + }
|
| +
|
| DeliverMessageCallback(app_id, app_identifier.origin(),
|
| app_identifier.service_worker_registration_id(),
|
| - message, message_handled_closure,
|
| - content::PUSH_DELIVERY_STATUS_PERMISSION_DENIED);
|
| + message, message_handled_closure, status);
|
| return;
|
| }
|
|
|
| @@ -369,6 +391,9 @@ void PushMessagingServiceImpl::DeliverMessageCallback(
|
| unsubscribe_reason =
|
| content::PUSH_UNREGISTRATION_REASON_DELIVERY_PERMISSION_DENIED;
|
| break;
|
| + case content::PUSH_DELIVERY_STATUS_PERMISSION_SUSPENDED:
|
| + // Do nothing, the kill switch might be withdrawn at some point.
|
| + break;
|
| case content::PUSH_DELIVERY_STATUS_NO_SERVICE_WORKER:
|
| unsubscribe_reason =
|
| content::PUSH_UNREGISTRATION_REASON_DELIVERY_NO_SERVICE_WORKER;
|
| @@ -903,7 +928,8 @@ void PushMessagingServiceImpl::OnContentSettingChanged(
|
| continue;
|
| }
|
|
|
| - if (IsPermissionSet(app_identifier.origin())) {
|
| + if (GetPermissionStatus(app_identifier.origin(), true /* user_visible */) ==
|
| + blink::kWebPushPermissionStatusGranted) {
|
| barrier_closure.Run();
|
| continue;
|
| }
|
| @@ -1009,13 +1035,6 @@ std::string PushMessagingServiceImpl::NormalizeSenderInfo(
|
| return encoded_sender_info;
|
| }
|
|
|
| -// Assumes user_visible always since this is just meant to check
|
| -// if the permission was previously granted and not revoked.
|
| -bool PushMessagingServiceImpl::IsPermissionSet(const GURL& origin) {
|
| - return GetPermissionStatus(origin, true /* user_visible */) ==
|
| - blink::kWebPushPermissionStatusGranted;
|
| -}
|
| -
|
| void PushMessagingServiceImpl::GetEncryptionInfoForAppId(
|
| const std::string& app_id,
|
| const std::string& sender_id,
|
|
|