| 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/base64url.h" | 10 #include "base/base64url.h" |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 "result in user-visible messages. You can indicate this by calling " | 62 "result in user-visible messages. You can indicate this by calling " |
| 63 "pushManager.subscribe({userVisibleOnly: true}) instead. See " | 63 "pushManager.subscribe({userVisibleOnly: true}) instead. See " |
| 64 "https://goo.gl/yqv4Q4 for more details."; | 64 "https://goo.gl/yqv4Q4 for more details."; |
| 65 | 65 |
| 66 void RecordDeliveryStatus(content::PushDeliveryStatus status) { | 66 void RecordDeliveryStatus(content::PushDeliveryStatus status) { |
| 67 UMA_HISTOGRAM_ENUMERATION("PushMessaging.DeliveryStatus", status, | 67 UMA_HISTOGRAM_ENUMERATION("PushMessaging.DeliveryStatus", status, |
| 68 content::PUSH_DELIVERY_STATUS_LAST + 1); | 68 content::PUSH_DELIVERY_STATUS_LAST + 1); |
| 69 } | 69 } |
| 70 | 70 |
| 71 blink::WebPushPermissionStatus ToPushPermission( | 71 blink::WebPushPermissionStatus ToPushPermission( |
| 72 blink::mojom::PermissionStatus permission_status) { | 72 permission::mojom::PermissionStatus permission_status) { |
| 73 switch (permission_status) { | 73 switch (permission_status) { |
| 74 case blink::mojom::PermissionStatus::GRANTED: | 74 case permission::mojom::PermissionStatus::GRANTED: |
| 75 return blink::WebPushPermissionStatusGranted; | 75 return blink::WebPushPermissionStatusGranted; |
| 76 case blink::mojom::PermissionStatus::DENIED: | 76 case permission::mojom::PermissionStatus::DENIED: |
| 77 return blink::WebPushPermissionStatusDenied; | 77 return blink::WebPushPermissionStatusDenied; |
| 78 case blink::mojom::PermissionStatus::ASK: | 78 case permission::mojom::PermissionStatus::ASK: |
| 79 return blink::WebPushPermissionStatusPrompt; | 79 return blink::WebPushPermissionStatusPrompt; |
| 80 default: | 80 default: |
| 81 NOTREACHED(); | 81 NOTREACHED(); |
| 82 return blink::WebPushPermissionStatusDenied; | 82 return blink::WebPushPermissionStatusDenied; |
| 83 } | 83 } |
| 84 } | 84 } |
| 85 | 85 |
| 86 void UnregisterCallbackToClosure(const base::Closure& closure, | 86 void UnregisterCallbackToClosure(const base::Closure& closure, |
| 87 content::PushUnregistrationStatus status) { | 87 content::PushUnregistrationStatus status) { |
| 88 closure.Run(); | 88 closure.Run(); |
| (...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 512 SubscribeEnd(callback, subscription_id, | 512 SubscribeEnd(callback, subscription_id, |
| 513 std::vector<uint8_t>(p256dh.begin(), p256dh.end()), | 513 std::vector<uint8_t>(p256dh.begin(), p256dh.end()), |
| 514 std::vector<uint8_t>(auth_secret.begin(), auth_secret.end()), | 514 std::vector<uint8_t>(auth_secret.begin(), auth_secret.end()), |
| 515 content::PUSH_REGISTRATION_STATUS_SUCCESS_FROM_PUSH_SERVICE); | 515 content::PUSH_REGISTRATION_STATUS_SUCCESS_FROM_PUSH_SERVICE); |
| 516 } | 516 } |
| 517 | 517 |
| 518 void PushMessagingServiceImpl::DidRequestPermission( | 518 void PushMessagingServiceImpl::DidRequestPermission( |
| 519 const PushMessagingAppIdentifier& app_identifier, | 519 const PushMessagingAppIdentifier& app_identifier, |
| 520 const content::PushSubscriptionOptions& options, | 520 const content::PushSubscriptionOptions& options, |
| 521 const content::PushMessagingService::RegisterCallback& register_callback, | 521 const content::PushMessagingService::RegisterCallback& register_callback, |
| 522 blink::mojom::PermissionStatus permission_status) { | 522 permission::mojom::PermissionStatus permission_status) { |
| 523 if (permission_status != blink::mojom::PermissionStatus::GRANTED) { | 523 if (permission_status != permission::mojom::PermissionStatus::GRANTED) { |
| 524 SubscribeEndWithError(register_callback, | 524 SubscribeEndWithError(register_callback, |
| 525 content::PUSH_REGISTRATION_STATUS_PERMISSION_DENIED); | 525 content::PUSH_REGISTRATION_STATUS_PERMISSION_DENIED); |
| 526 return; | 526 return; |
| 527 } | 527 } |
| 528 | 528 |
| 529 IncreasePushSubscriptionCount(1, true /* is_pending */); | 529 IncreasePushSubscriptionCount(1, true /* is_pending */); |
| 530 std::vector<std::string> sender_ids(1, | 530 std::vector<std::string> sender_ids(1, |
| 531 NormalizeSenderInfo(options.sender_info)); | 531 NormalizeSenderInfo(options.sender_info)); |
| 532 | 532 |
| 533 GetGCMDriver()->Register(app_identifier.app_id(), sender_ids, | 533 GetGCMDriver()->Register(app_identifier.app_id(), sender_ids, |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 773 blink::WebPushPermissionStatusGranted; | 773 blink::WebPushPermissionStatusGranted; |
| 774 } | 774 } |
| 775 | 775 |
| 776 gcm::GCMDriver* PushMessagingServiceImpl::GetGCMDriver() const { | 776 gcm::GCMDriver* PushMessagingServiceImpl::GetGCMDriver() const { |
| 777 gcm::GCMProfileService* gcm_profile_service = | 777 gcm::GCMProfileService* gcm_profile_service = |
| 778 gcm::GCMProfileServiceFactory::GetForProfile(profile_); | 778 gcm::GCMProfileServiceFactory::GetForProfile(profile_); |
| 779 CHECK(gcm_profile_service); | 779 CHECK(gcm_profile_service); |
| 780 CHECK(gcm_profile_service->driver()); | 780 CHECK(gcm_profile_service->driver()); |
| 781 return gcm_profile_service->driver(); | 781 return gcm_profile_service->driver(); |
| 782 } | 782 } |
| OLD | NEW |