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 "content/renderer/push_messaging/push_messaging_dispatcher.h" | 5 #include "content/renderer/push_messaging/push_messaging_dispatcher.h" |
6 | 6 |
| 7 #include "base/memory/ptr_util.h" |
7 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
8 #include "content/child/service_worker/web_service_worker_registration_impl.h" | 9 #include "content/child/service_worker/web_service_worker_registration_impl.h" |
9 #include "content/common/push_messaging_messages.h" | 10 #include "content/common/push_messaging_messages.h" |
10 #include "content/renderer/manifest/manifest_manager.h" | 11 #include "content/renderer/manifest/manifest_manager.h" |
11 #include "content/renderer/render_frame_impl.h" | 12 #include "content/renderer/render_frame_impl.h" |
12 #include "ipc/ipc_message.h" | 13 #include "ipc/ipc_message.h" |
13 #include "third_party/WebKit/public/platform/WebString.h" | 14 #include "third_party/WebKit/public/platform/WebString.h" |
14 #include "third_party/WebKit/public/platform/modules/push_messaging/WebPushError
.h" | 15 #include "third_party/WebKit/public/platform/modules/push_messaging/WebPushError
.h" |
15 #include "third_party/WebKit/public/platform/modules/push_messaging/WebPushSubsc
ription.h" | 16 #include "third_party/WebKit/public/platform/modules/push_messaging/WebPushSubsc
ription.h" |
16 #include "third_party/WebKit/public/platform/modules/push_messaging/WebPushSubsc
riptionOptions.h" | 17 #include "third_party/WebKit/public/platform/modules/push_messaging/WebPushSubsc
riptionOptions.h" |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 | 108 |
108 void PushMessagingDispatcher::OnSubscribeFromDocumentSuccess( | 109 void PushMessagingDispatcher::OnSubscribeFromDocumentSuccess( |
109 int32_t request_id, | 110 int32_t request_id, |
110 const GURL& endpoint, | 111 const GURL& endpoint, |
111 const std::vector<uint8_t>& p256dh, | 112 const std::vector<uint8_t>& p256dh, |
112 const std::vector<uint8_t>& auth) { | 113 const std::vector<uint8_t>& auth) { |
113 blink::WebPushSubscriptionCallbacks* callbacks = | 114 blink::WebPushSubscriptionCallbacks* callbacks = |
114 subscription_callbacks_.Lookup(request_id); | 115 subscription_callbacks_.Lookup(request_id); |
115 DCHECK(callbacks); | 116 DCHECK(callbacks); |
116 | 117 |
117 callbacks->onSuccess(blink::adoptWebPtr( | 118 callbacks->onSuccess( |
118 new blink::WebPushSubscription(endpoint, p256dh, auth))); | 119 base::WrapUnique(new blink::WebPushSubscription(endpoint, p256dh, auth))); |
119 | 120 |
120 subscription_callbacks_.Remove(request_id); | 121 subscription_callbacks_.Remove(request_id); |
121 } | 122 } |
122 | 123 |
123 void PushMessagingDispatcher::OnSubscribeFromDocumentError( | 124 void PushMessagingDispatcher::OnSubscribeFromDocumentError( |
124 int32_t request_id, | 125 int32_t request_id, |
125 PushRegistrationStatus status) { | 126 PushRegistrationStatus status) { |
126 blink::WebPushSubscriptionCallbacks* callbacks = | 127 blink::WebPushSubscriptionCallbacks* callbacks = |
127 subscription_callbacks_.Lookup(request_id); | 128 subscription_callbacks_.Lookup(request_id); |
128 DCHECK(callbacks); | 129 DCHECK(callbacks); |
129 | 130 |
130 blink::WebPushError::ErrorType error_type = | 131 blink::WebPushError::ErrorType error_type = |
131 status == PUSH_REGISTRATION_STATUS_PERMISSION_DENIED | 132 status == PUSH_REGISTRATION_STATUS_PERMISSION_DENIED |
132 ? blink::WebPushError::ErrorTypePermissionDenied | 133 ? blink::WebPushError::ErrorTypePermissionDenied |
133 : blink::WebPushError::ErrorTypeAbort; | 134 : blink::WebPushError::ErrorTypeAbort; |
134 | 135 |
135 callbacks->onError(blink::WebPushError( | 136 callbacks->onError(blink::WebPushError( |
136 error_type, | 137 error_type, |
137 blink::WebString::fromUTF8(PushRegistrationStatusToString(status)))); | 138 blink::WebString::fromUTF8(PushRegistrationStatusToString(status)))); |
138 | 139 |
139 subscription_callbacks_.Remove(request_id); | 140 subscription_callbacks_.Remove(request_id); |
140 } | 141 } |
141 | 142 |
142 } // namespace content | 143 } // namespace content |
OLD | NEW |