| 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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 const blink::WebPushSubscriptionOptions& options, | 70 const blink::WebPushSubscriptionOptions& options, |
| 71 blink::WebPushSubscriptionCallbacks* callbacks) { | 71 blink::WebPushSubscriptionCallbacks* callbacks) { |
| 72 DCHECK(service_worker_registration); | 72 DCHECK(service_worker_registration); |
| 73 DCHECK(callbacks); | 73 DCHECK(callbacks); |
| 74 int request_id = push_dispatcher_->GenerateRequestId(CurrentWorkerId()); | 74 int request_id = push_dispatcher_->GenerateRequestId(CurrentWorkerId()); |
| 75 subscription_callbacks_.AddWithID(callbacks, request_id); | 75 subscription_callbacks_.AddWithID(callbacks, request_id); |
| 76 int64_t service_worker_registration_id = | 76 int64_t service_worker_registration_id = |
| 77 GetServiceWorkerRegistrationId(service_worker_registration); | 77 GetServiceWorkerRegistrationId(service_worker_registration); |
| 78 PushSubscriptionOptions content_options; | 78 PushSubscriptionOptions content_options; |
| 79 content_options.user_visible_only = options.userVisibleOnly; | 79 content_options.user_visible_only = options.userVisibleOnly; |
| 80 content_options.sender_info = options.applicationServerKey.utf8(); | 80 |
| 81 // Just treat the server key as a string of bytes and pass it to the push |
| 82 // service. |
| 83 content_options.sender_info = options.applicationServerKey.latin1(); |
| 81 thread_safe_sender_->Send(new PushMessagingHostMsg_SubscribeFromWorker( | 84 thread_safe_sender_->Send(new PushMessagingHostMsg_SubscribeFromWorker( |
| 82 request_id, service_worker_registration_id, content_options)); | 85 request_id, service_worker_registration_id, content_options)); |
| 83 } | 86 } |
| 84 | 87 |
| 85 void PushProvider::unsubscribe( | 88 void PushProvider::unsubscribe( |
| 86 blink::WebServiceWorkerRegistration* service_worker_registration, | 89 blink::WebServiceWorkerRegistration* service_worker_registration, |
| 87 blink::WebPushUnsubscribeCallbacks* callbacks) { | 90 blink::WebPushUnsubscribeCallbacks* callbacks) { |
| 88 DCHECK(service_worker_registration); | 91 DCHECK(service_worker_registration); |
| 89 DCHECK(callbacks); | 92 DCHECK(callbacks); |
| 90 | 93 |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 "supported."; | 268 "supported."; |
| 266 } | 269 } |
| 267 | 270 |
| 268 callbacks->onError( | 271 callbacks->onError( |
| 269 blink::WebPushError(error, blink::WebString::fromUTF8(error_message))); | 272 blink::WebPushError(error, blink::WebString::fromUTF8(error_message))); |
| 270 | 273 |
| 271 permission_status_callbacks_.Remove(request_id); | 274 permission_status_callbacks_.Remove(request_id); |
| 272 } | 275 } |
| 273 | 276 |
| 274 } // namespace content | 277 } // namespace content |
| OLD | NEW |