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

Unified Diff: chrome/browser/push_messaging/push_messaging_service_impl.cc

Issue 2907613002: Reduce the impact of the push/notification kill switches (Closed)
Patch Set: windows fix Created 3 years, 7 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: 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..980a626760d8278500f99ef49a99d3cee42cf691 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())) {
johnme 2017/05/31 13:56:06 Optional: since you're removing the second last us
Peter Beverloo 2017/06/02 13:43:37 Done.
+
+ // 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;
« no previous file with comments | « chrome/browser/push_messaging/push_messaging_browsertest.cc ('k') | content/public/common/push_messaging_status.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698