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

Side by Side Diff: chrome/browser/services/gcm/push_messaging_service_impl.cc

Issue 914693002: Push API: Fix unsubscribing from GCM on Android (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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/services/gcm/push_messaging_service_impl.h" 5 #include "chrome/browser/services/gcm/push_messaging_service_impl.h"
6 6
7 #include <bitset> 7 #include <bitset>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 562 matching lines...) Expand 10 before | Expand all | Expand 10 after
573 application_id.ToString(), 573 application_id.ToString(),
574 sender_ids, 574 sender_ids,
575 base::Bind(&PushMessagingServiceImpl::DidRegister, 575 base::Bind(&PushMessagingServiceImpl::DidRegister,
576 weak_factory_.GetWeakPtr(), 576 weak_factory_.GetWeakPtr(),
577 register_callback)); 577 register_callback));
578 } 578 }
579 579
580 void PushMessagingServiceImpl::Unregister( 580 void PushMessagingServiceImpl::Unregister(
581 const GURL& requesting_origin, 581 const GURL& requesting_origin,
582 int64 service_worker_registration_id, 582 int64 service_worker_registration_id,
583 const std::string& sender_id,
583 const content::PushMessagingService::UnregisterCallback& callback) { 584 const content::PushMessagingService::UnregisterCallback& callback) {
584 DCHECK(gcm_profile_service_->driver()); 585 DCHECK(gcm_profile_service_->driver());
585 586
586 PushMessagingApplicationId application_id = PushMessagingApplicationId( 587 PushMessagingApplicationId application_id = PushMessagingApplicationId(
587 requesting_origin, service_worker_registration_id); 588 requesting_origin, service_worker_registration_id);
588 DCHECK(application_id.IsValid()); 589 DCHECK(application_id.IsValid());
589 590
590 Unregister(application_id, callback); 591 Unregister(application_id, sender_id, callback);
591 } 592 }
592 593
593 void PushMessagingServiceImpl::Unregister( 594 void PushMessagingServiceImpl::Unregister(
594 const PushMessagingApplicationId& application_id, 595 const PushMessagingApplicationId& application_id,
596 const std::string& sender_id,
595 const content::PushMessagingService::UnregisterCallback& callback) { 597 const content::PushMessagingService::UnregisterCallback& callback) {
596 DCHECK(gcm_profile_service_->driver()); 598 DCHECK(gcm_profile_service_->driver());
597 599
598 gcm_profile_service_->driver()->Unregister( 600 gcm_profile_service_->driver()->Unregister(
599 application_id.ToString(), 601 application_id.ToString(),
602 sender_id,
600 base::Bind(&PushMessagingServiceImpl::DidUnregister, 603 base::Bind(&PushMessagingServiceImpl::DidUnregister,
601 weak_factory_.GetWeakPtr(), callback)); 604 weak_factory_.GetWeakPtr(), callback));
602 } 605 }
603 606
604 void PushMessagingServiceImpl::DidUnregister( 607 void PushMessagingServiceImpl::DidUnregister(
605 const content::PushMessagingService::UnregisterCallback& callback, 608 const content::PushMessagingService::UnregisterCallback& callback,
606 GCMClient::Result result) { 609 GCMClient::Result result) {
607 // Internal calls pass a null callback. 610 // Internal calls pass a null callback.
608 if (!callback.is_null()) { 611 if (!callback.is_null()) {
609 switch (result) { 612 switch (result) {
(...skipping 25 matching lines...) Expand all
635 bool PushMessagingServiceImpl::HasPermission(const GURL& origin) { 638 bool PushMessagingServiceImpl::HasPermission(const GURL& origin) {
636 gcm::PushMessagingPermissionContext* permission_context = 639 gcm::PushMessagingPermissionContext* permission_context =
637 gcm::PushMessagingPermissionContextFactory::GetForProfile(profile_); 640 gcm::PushMessagingPermissionContextFactory::GetForProfile(profile_);
638 DCHECK(permission_context); 641 DCHECK(permission_context);
639 642
640 return permission_context->GetPermissionStatus(origin, origin) == 643 return permission_context->GetPermissionStatus(origin, origin) ==
641 CONTENT_SETTING_ALLOW; 644 CONTENT_SETTING_ALLOW;
642 } 645 }
643 646
644 } // namespace gcm 647 } // namespace gcm
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698