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

Side by Side 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, 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/push_messaging/push_messaging_service_impl.h" 5 #include "chrome/browser/push_messaging/push_messaging_service_impl.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/barrier_closure.h" 9 #include "base/barrier_closure.h"
10 #include "base/base64url.h" 10 #include "base/base64url.h"
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 PushMessagingAppIdentifier app_identifier = 270 PushMessagingAppIdentifier app_identifier =
271 PushMessagingAppIdentifier::FindByAppId(profile_, app_id); 271 PushMessagingAppIdentifier::FindByAppId(profile_, app_id);
272 // Drop message and unregister if app_id was unknown (maybe recently deleted). 272 // Drop message and unregister if app_id was unknown (maybe recently deleted).
273 if (app_identifier.is_null()) { 273 if (app_identifier.is_null()) {
274 DeliverMessageCallback(app_id, GURL::EmptyGURL(), 274 DeliverMessageCallback(app_id, GURL::EmptyGURL(),
275 -1 /* kInvalidServiceWorkerRegistrationId */, 275 -1 /* kInvalidServiceWorkerRegistrationId */,
276 message, message_handled_closure, 276 message, message_handled_closure,
277 content::PUSH_DELIVERY_STATUS_UNKNOWN_APP_ID); 277 content::PUSH_DELIVERY_STATUS_UNKNOWN_APP_ID);
278 return; 278 return;
279 } 279 }
280 // Drop message and unregister if |origin| has lost push permission. 280
281 if (!IsPermissionSet(app_identifier.origin())) { 281 // Drop message and unregister if |origin| has lost push permission. However,
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.
282 // we should only drop the subscription if the permission was in fact denied
283 // rather than suspended, for example through the kill switch.
284 PermissionResult permission_result =
285 PermissionManager::Get(profile_)->GetPermissionStatus(
286 CONTENT_SETTINGS_TYPE_PUSH_MESSAGING, app_identifier.origin(),
287 app_identifier.origin());
288
289 if (permission_result.content_setting != CONTENT_SETTING_ALLOW) {
290 content::PushDeliveryStatus status =
291 content::PUSH_DELIVERY_STATUS_PERMISSION_DENIED;
292
293 switch (permission_result.source) {
294 case PermissionStatusSource::KILL_SWITCH:
295 status = content::PUSH_DELIVERY_STATUS_PERMISSION_SUSPENDED;
296 break;
297 case PermissionStatusSource::UNSPECIFIED:
298 case PermissionStatusSource::SAFE_BROWSING_BLACKLIST:
299 case PermissionStatusSource::MULTIPLE_DISMISSALS:
300 case PermissionStatusSource::MULTIPLE_IGNORES:
301 status = content::PUSH_DELIVERY_STATUS_PERMISSION_DENIED;
302 break;
303 }
304
282 DeliverMessageCallback(app_id, app_identifier.origin(), 305 DeliverMessageCallback(app_id, app_identifier.origin(),
283 app_identifier.service_worker_registration_id(), 306 app_identifier.service_worker_registration_id(),
284 message, message_handled_closure, 307 message, message_handled_closure, status);
285 content::PUSH_DELIVERY_STATUS_PERMISSION_DENIED);
286 return; 308 return;
287 } 309 }
288 310
289 rappor::SampleDomainAndRegistryFromGURL( 311 rappor::SampleDomainAndRegistryFromGURL(
290 g_browser_process->rappor_service(), 312 g_browser_process->rappor_service(),
291 "PushMessaging.MessageReceived.Origin", app_identifier.origin()); 313 "PushMessaging.MessageReceived.Origin", app_identifier.origin());
292 314
293 // The payload of a push message can be valid with content, valid with empty 315 // The payload of a push message can be valid with content, valid with empty
294 // content, or null. Only set the payload data if it is non-null. 316 // content, or null. Only set the payload data if it is non-null.
295 content::PushEventPayload payload; 317 content::PushEventPayload payload;
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 // Do nothing, and hope the error is transient. 384 // Do nothing, and hope the error is transient.
363 break; 385 break;
364 case content::PUSH_DELIVERY_STATUS_UNKNOWN_APP_ID: 386 case content::PUSH_DELIVERY_STATUS_UNKNOWN_APP_ID:
365 unsubscribe_reason = 387 unsubscribe_reason =
366 content::PUSH_UNREGISTRATION_REASON_DELIVERY_UNKNOWN_APP_ID; 388 content::PUSH_UNREGISTRATION_REASON_DELIVERY_UNKNOWN_APP_ID;
367 break; 389 break;
368 case content::PUSH_DELIVERY_STATUS_PERMISSION_DENIED: 390 case content::PUSH_DELIVERY_STATUS_PERMISSION_DENIED:
369 unsubscribe_reason = 391 unsubscribe_reason =
370 content::PUSH_UNREGISTRATION_REASON_DELIVERY_PERMISSION_DENIED; 392 content::PUSH_UNREGISTRATION_REASON_DELIVERY_PERMISSION_DENIED;
371 break; 393 break;
394 case content::PUSH_DELIVERY_STATUS_PERMISSION_SUSPENDED:
395 // Do nothing, the kill switch might be withdrawn at some point.
396 break;
372 case content::PUSH_DELIVERY_STATUS_NO_SERVICE_WORKER: 397 case content::PUSH_DELIVERY_STATUS_NO_SERVICE_WORKER:
373 unsubscribe_reason = 398 unsubscribe_reason =
374 content::PUSH_UNREGISTRATION_REASON_DELIVERY_NO_SERVICE_WORKER; 399 content::PUSH_UNREGISTRATION_REASON_DELIVERY_NO_SERVICE_WORKER;
375 break; 400 break;
376 } 401 }
377 402
378 if (unsubscribe_reason != content::PUSH_UNREGISTRATION_REASON_UNKNOWN) { 403 if (unsubscribe_reason != content::PUSH_UNREGISTRATION_REASON_UNKNOWN) {
379 PushMessagingAppIdentifier app_identifier = 404 PushMessagingAppIdentifier app_identifier =
380 PushMessagingAppIdentifier::FindByAppId(profile_, app_id); 405 PushMessagingAppIdentifier::FindByAppId(profile_, app_id);
381 UnsubscribeInternal( 406 UnsubscribeInternal(
(...skipping 655 matching lines...) Expand 10 before | Expand all | Expand 10 after
1037 } 1062 }
1038 1063
1039 instance_id::InstanceIDDriver* PushMessagingServiceImpl::GetInstanceIDDriver() 1064 instance_id::InstanceIDDriver* PushMessagingServiceImpl::GetInstanceIDDriver()
1040 const { 1065 const {
1041 instance_id::InstanceIDProfileService* instance_id_profile_service = 1066 instance_id::InstanceIDProfileService* instance_id_profile_service =
1042 instance_id::InstanceIDProfileServiceFactory::GetForProfile(profile_); 1067 instance_id::InstanceIDProfileServiceFactory::GetForProfile(profile_);
1043 CHECK(instance_id_profile_service); 1068 CHECK(instance_id_profile_service);
1044 CHECK(instance_id_profile_service->driver()); 1069 CHECK(instance_id_profile_service->driver());
1045 return instance_id_profile_service->driver(); 1070 return instance_id_profile_service->driver();
1046 } 1071 }
OLDNEW
« 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