OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/service_worker/service_worker_context_client.h" | 5 #include "content/renderer/service_worker/service_worker_context_client.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 #include "content/child/service_worker/web_service_worker_provider_impl.h" | 25 #include "content/child/service_worker/web_service_worker_provider_impl.h" |
26 #include "content/child/service_worker/web_service_worker_registration_impl.h" | 26 #include "content/child/service_worker/web_service_worker_registration_impl.h" |
27 #include "content/child/thread_safe_sender.h" | 27 #include "content/child/thread_safe_sender.h" |
28 #include "content/child/webmessageportchannel_impl.h" | 28 #include "content/child/webmessageportchannel_impl.h" |
29 #include "content/common/devtools_messages.h" | 29 #include "content/common/devtools_messages.h" |
30 #include "content/common/geofencing_messages.h" | 30 #include "content/common/geofencing_messages.h" |
31 #include "content/common/message_port_messages.h" | 31 #include "content/common/message_port_messages.h" |
32 #include "content/common/mojo/service_registry_impl.h" | 32 #include "content/common/mojo/service_registry_impl.h" |
33 #include "content/common/service_worker/embedded_worker_messages.h" | 33 #include "content/common/service_worker/embedded_worker_messages.h" |
34 #include "content/common/service_worker/service_worker_messages.h" | 34 #include "content/common/service_worker/service_worker_messages.h" |
| 35 #include "content/public/common/push_event_payload.h" |
35 #include "content/public/common/referrer.h" | 36 #include "content/public/common/referrer.h" |
36 #include "content/public/renderer/content_renderer_client.h" | 37 #include "content/public/renderer/content_renderer_client.h" |
37 #include "content/public/renderer/document_state.h" | 38 #include "content/public/renderer/document_state.h" |
38 #include "content/renderer/background_sync/background_sync_client_impl.h" | 39 #include "content/renderer/background_sync/background_sync_client_impl.h" |
39 #include "content/renderer/devtools/devtools_agent.h" | 40 #include "content/renderer/devtools/devtools_agent.h" |
40 #include "content/renderer/render_thread_impl.h" | 41 #include "content/renderer/render_thread_impl.h" |
41 #include "content/renderer/service_worker/embedded_worker_dispatcher.h" | 42 #include "content/renderer/service_worker/embedded_worker_dispatcher.h" |
42 #include "content/renderer/service_worker/service_worker_type_util.h" | 43 #include "content/renderer/service_worker/service_worker_type_util.h" |
43 #include "ipc/ipc_message.h" | 44 #include "ipc/ipc_message.h" |
44 #include "ipc/ipc_message_macros.h" | 45 #include "ipc/ipc_message_macros.h" |
(...skipping 708 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
753 TRACE_EVENT0("ServiceWorker", | 754 TRACE_EVENT0("ServiceWorker", |
754 "ServiceWorkerContextClient::OnNotificationClickEvent"); | 755 "ServiceWorkerContextClient::OnNotificationClickEvent"); |
755 proxy_->dispatchNotificationClickEvent( | 756 proxy_->dispatchNotificationClickEvent( |
756 request_id, | 757 request_id, |
757 persistent_notification_id, | 758 persistent_notification_id, |
758 ToWebNotificationData(notification_data), | 759 ToWebNotificationData(notification_data), |
759 action_index); | 760 action_index); |
760 } | 761 } |
761 | 762 |
762 void ServiceWorkerContextClient::OnPushEvent(int request_id, | 763 void ServiceWorkerContextClient::OnPushEvent(int request_id, |
763 const std::string& data) { | 764 const PushEventPayload& payload) { |
764 TRACE_EVENT0("ServiceWorker", | 765 TRACE_EVENT0("ServiceWorker", |
765 "ServiceWorkerContextClient::OnPushEvent"); | 766 "ServiceWorkerContextClient::OnPushEvent"); |
766 proxy_->dispatchPushEvent(request_id, blink::WebString::fromUTF8(data)); | 767 // Only set data to be a valid string if the payload had decrypted data. |
| 768 blink::WebString data; |
| 769 if (!payload.is_null) |
| 770 data.assign(blink::WebString::fromUTF8(payload.data)); |
| 771 proxy_->dispatchPushEvent(request_id, data); |
767 } | 772 } |
768 | 773 |
769 void ServiceWorkerContextClient::OnGeofencingEvent( | 774 void ServiceWorkerContextClient::OnGeofencingEvent( |
770 int request_id, | 775 int request_id, |
771 blink::WebGeofencingEventType event_type, | 776 blink::WebGeofencingEventType event_type, |
772 const std::string& region_id, | 777 const std::string& region_id, |
773 const blink::WebCircularGeofencingRegion& region) { | 778 const blink::WebCircularGeofencingRegion& region) { |
774 TRACE_EVENT0("ServiceWorker", | 779 TRACE_EVENT0("ServiceWorker", |
775 "ServiceWorkerContextClient::OnGeofencingEvent"); | 780 "ServiceWorkerContextClient::OnGeofencingEvent"); |
776 proxy_->dispatchGeofencingEvent( | 781 proxy_->dispatchGeofencingEvent( |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
986 } | 991 } |
987 | 992 |
988 base::WeakPtr<ServiceWorkerContextClient> | 993 base::WeakPtr<ServiceWorkerContextClient> |
989 ServiceWorkerContextClient::GetWeakPtr() { | 994 ServiceWorkerContextClient::GetWeakPtr() { |
990 DCHECK(worker_task_runner_->RunsTasksOnCurrentThread()); | 995 DCHECK(worker_task_runner_->RunsTasksOnCurrentThread()); |
991 DCHECK(context_); | 996 DCHECK(context_); |
992 return context_->weak_factory.GetWeakPtr(); | 997 return context_->weak_factory.GetWeakPtr(); |
993 } | 998 } |
994 | 999 |
995 } // namespace content | 1000 } // namespace content |
OLD | NEW |