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/child/push_messaging/push_provider.h" | 5 #include "content/child/push_messaging/push_provider.h" |
6 | 6 |
7 #include "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
10 #include "base/threading/thread_local.h" | 10 #include "base/threading/thread_local.h" |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 subscription_callbacks_.Remove(request_id); | 161 subscription_callbacks_.Remove(request_id); |
162 } | 162 } |
163 | 163 |
164 void PushProvider::OnSubscribeFromWorkerError(int request_id, | 164 void PushProvider::OnSubscribeFromWorkerError(int request_id, |
165 PushRegistrationStatus status) { | 165 PushRegistrationStatus status) { |
166 blink::WebPushSubscriptionCallbacks* callbacks = | 166 blink::WebPushSubscriptionCallbacks* callbacks = |
167 subscription_callbacks_.Lookup(request_id); | 167 subscription_callbacks_.Lookup(request_id); |
168 if (!callbacks) | 168 if (!callbacks) |
169 return; | 169 return; |
170 | 170 |
| 171 blink::WebPushError::ErrorType error_type = |
| 172 status == PUSH_REGISTRATION_STATUS_PERMISSION_DENIED |
| 173 ? blink::WebPushError::ErrorTypePermissionDenied |
| 174 : blink::WebPushError::ErrorTypeAbort; |
| 175 |
171 callbacks->onError(blink::WebPushError( | 176 callbacks->onError(blink::WebPushError( |
172 blink::WebPushError::ErrorTypeAbort, | 177 error_type, |
173 blink::WebString::fromUTF8(PushRegistrationStatusToString(status)))); | 178 blink::WebString::fromUTF8(PushRegistrationStatusToString(status)))); |
174 | 179 |
175 subscription_callbacks_.Remove(request_id); | 180 subscription_callbacks_.Remove(request_id); |
176 } | 181 } |
177 | 182 |
178 void PushProvider::OnUnsubscribeSuccess(int request_id, bool did_unsubscribe) { | 183 void PushProvider::OnUnsubscribeSuccess(int request_id, bool did_unsubscribe) { |
179 blink::WebPushUnsubscribeCallbacks* callbacks = | 184 blink::WebPushUnsubscribeCallbacks* callbacks = |
180 unsubscribe_callbacks_.Lookup(request_id); | 185 unsubscribe_callbacks_.Lookup(request_id); |
181 if (!callbacks) | 186 if (!callbacks) |
182 return; | 187 return; |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 "supported."; | 263 "supported."; |
259 } | 264 } |
260 | 265 |
261 callbacks->onError(blink::WebPushError( | 266 callbacks->onError(blink::WebPushError( |
262 error, blink::WebString::fromUTF8(error_message))); | 267 error, blink::WebString::fromUTF8(error_message))); |
263 | 268 |
264 permission_status_callbacks_.Remove(request_id); | 269 permission_status_callbacks_.Remove(request_id); |
265 } | 270 } |
266 | 271 |
267 } // namespace content | 272 } // namespace content |
OLD | NEW |