| OLD | NEW |
| 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/bind.h" | 10 #include "base/bind.h" |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 "pushManager.subscribe({userVisibleOnly: true}) instead. See " | 57 "pushManager.subscribe({userVisibleOnly: true}) instead. See " |
| 58 "https://goo.gl/yqv4Q4 for more details."; | 58 "https://goo.gl/yqv4Q4 for more details."; |
| 59 | 59 |
| 60 void RecordDeliveryStatus(content::PushDeliveryStatus status) { | 60 void RecordDeliveryStatus(content::PushDeliveryStatus status) { |
| 61 UMA_HISTOGRAM_ENUMERATION("PushMessaging.DeliveryStatus", | 61 UMA_HISTOGRAM_ENUMERATION("PushMessaging.DeliveryStatus", |
| 62 status, | 62 status, |
| 63 content::PUSH_DELIVERY_STATUS_LAST + 1); | 63 content::PUSH_DELIVERY_STATUS_LAST + 1); |
| 64 } | 64 } |
| 65 | 65 |
| 66 blink::WebPushPermissionStatus ToPushPermission( | 66 blink::WebPushPermissionStatus ToPushPermission( |
| 67 content::PermissionStatus permission_status) { | 67 permission::Status permission_status) { |
| 68 switch (permission_status) { | 68 switch (permission_status) { |
| 69 case content::PERMISSION_STATUS_GRANTED: | 69 case permission::STATUS_GRANTED: |
| 70 return blink::WebPushPermissionStatusGranted; | 70 return blink::WebPushPermissionStatusGranted; |
| 71 case content::PERMISSION_STATUS_DENIED: | 71 case permission::STATUS_DENIED: |
| 72 return blink::WebPushPermissionStatusDenied; | 72 return blink::WebPushPermissionStatusDenied; |
| 73 case content::PERMISSION_STATUS_ASK: | 73 case permission::STATUS_ASK: |
| 74 return blink::WebPushPermissionStatusPrompt; | 74 return blink::WebPushPermissionStatusPrompt; |
| 75 default: | 75 default: |
| 76 NOTREACHED(); | 76 NOTREACHED(); |
| 77 return blink::WebPushPermissionStatusDenied; | 77 return blink::WebPushPermissionStatusDenied; |
| 78 } | 78 } |
| 79 } | 79 } |
| 80 | 80 |
| 81 void UnregisterCallbackToClosure( | 81 void UnregisterCallbackToClosure( |
| 82 const base::Closure& closure, content::PushUnregistrationStatus status) { | 82 const base::Closure& closure, content::PushUnregistrationStatus status) { |
| 83 closure.Run(); | 83 closure.Run(); |
| (...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 510 | 510 |
| 511 SubscribeEnd(callback, subscription_id, | 511 SubscribeEnd(callback, subscription_id, |
| 512 std::vector<uint8_t>(public_key.begin(), public_key.end()), | 512 std::vector<uint8_t>(public_key.begin(), public_key.end()), |
| 513 content::PUSH_REGISTRATION_STATUS_SUCCESS_FROM_PUSH_SERVICE); | 513 content::PUSH_REGISTRATION_STATUS_SUCCESS_FROM_PUSH_SERVICE); |
| 514 } | 514 } |
| 515 | 515 |
| 516 void PushMessagingServiceImpl::DidRequestPermission( | 516 void PushMessagingServiceImpl::DidRequestPermission( |
| 517 const PushMessagingAppIdentifier& app_identifier, | 517 const PushMessagingAppIdentifier& app_identifier, |
| 518 const std::string& sender_id, | 518 const std::string& sender_id, |
| 519 const content::PushMessagingService::RegisterCallback& register_callback, | 519 const content::PushMessagingService::RegisterCallback& register_callback, |
| 520 content::PermissionStatus permission_status) { | 520 permission::Status permission_status) { |
| 521 if (permission_status != content::PERMISSION_STATUS_GRANTED) { | 521 if (permission_status != permission::STATUS_GRANTED) { |
| 522 SubscribeEndWithError(register_callback, | 522 SubscribeEndWithError(register_callback, |
| 523 content::PUSH_REGISTRATION_STATUS_PERMISSION_DENIED); | 523 content::PUSH_REGISTRATION_STATUS_PERMISSION_DENIED); |
| 524 return; | 524 return; |
| 525 } | 525 } |
| 526 | 526 |
| 527 IncreasePushSubscriptionCount(1, true /* is_pending */); | 527 IncreasePushSubscriptionCount(1, true /* is_pending */); |
| 528 std::vector<std::string> sender_ids(1, sender_id); | 528 std::vector<std::string> sender_ids(1, sender_id); |
| 529 GetGCMDriver()->Register(app_identifier.app_id(), sender_ids, | 529 GetGCMDriver()->Register(app_identifier.app_id(), sender_ids, |
| 530 base::Bind(&PushMessagingServiceImpl::DidSubscribe, | 530 base::Bind(&PushMessagingServiceImpl::DidSubscribe, |
| 531 weak_factory_.GetWeakPtr(), | 531 weak_factory_.GetWeakPtr(), |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 764 switches::kEnablePushMessagePayload); | 764 switches::kEnablePushMessagePayload); |
| 765 } | 765 } |
| 766 | 766 |
| 767 gcm::GCMDriver* PushMessagingServiceImpl::GetGCMDriver() const { | 767 gcm::GCMDriver* PushMessagingServiceImpl::GetGCMDriver() const { |
| 768 gcm::GCMProfileService* gcm_profile_service = | 768 gcm::GCMProfileService* gcm_profile_service = |
| 769 gcm::GCMProfileServiceFactory::GetForProfile(profile_); | 769 gcm::GCMProfileServiceFactory::GetForProfile(profile_); |
| 770 CHECK(gcm_profile_service); | 770 CHECK(gcm_profile_service); |
| 771 CHECK(gcm_profile_service->driver()); | 771 CHECK(gcm_profile_service->driver()); |
| 772 return gcm_profile_service->driver(); | 772 return gcm_profile_service->driver(); |
| 773 } | 773 } |
| OLD | NEW |