| 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 709 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 754 TRACE_EVENT0("ServiceWorker", | 755 TRACE_EVENT0("ServiceWorker", |
| 755 "ServiceWorkerContextClient::OnNotificationClickEvent"); | 756 "ServiceWorkerContextClient::OnNotificationClickEvent"); |
| 756 proxy_->dispatchNotificationClickEvent( | 757 proxy_->dispatchNotificationClickEvent( |
| 757 request_id, | 758 request_id, |
| 758 persistent_notification_id, | 759 persistent_notification_id, |
| 759 ToWebNotificationData(notification_data), | 760 ToWebNotificationData(notification_data), |
| 760 action_index); | 761 action_index); |
| 761 } | 762 } |
| 762 | 763 |
| 763 void ServiceWorkerContextClient::OnPushEvent(int request_id, | 764 void ServiceWorkerContextClient::OnPushEvent(int request_id, |
| 764 const std::string& data) { | 765 const PushEventPayload& payload) { |
| 765 TRACE_EVENT0("ServiceWorker", | 766 TRACE_EVENT0("ServiceWorker", |
| 766 "ServiceWorkerContextClient::OnPushEvent"); | 767 "ServiceWorkerContextClient::OnPushEvent"); |
| 767 proxy_->dispatchPushEvent(request_id, blink::WebString::fromUTF8(data)); | 768 // Only set data to be a valid string if the payload had decrypted data. |
| 769 blink::WebString data; |
| 770 if (!payload.is_null) |
| 771 data.assign(blink::WebString::fromUTF8(payload.data)); |
| 772 proxy_->dispatchPushEvent(request_id, data); |
| 768 } | 773 } |
| 769 | 774 |
| 770 void ServiceWorkerContextClient::OnGeofencingEvent( | 775 void ServiceWorkerContextClient::OnGeofencingEvent( |
| 771 int request_id, | 776 int request_id, |
| 772 blink::WebGeofencingEventType event_type, | 777 blink::WebGeofencingEventType event_type, |
| 773 const std::string& region_id, | 778 const std::string& region_id, |
| 774 const blink::WebCircularGeofencingRegion& region) { | 779 const blink::WebCircularGeofencingRegion& region) { |
| 775 TRACE_EVENT0("ServiceWorker", | 780 TRACE_EVENT0("ServiceWorker", |
| 776 "ServiceWorkerContextClient::OnGeofencingEvent"); | 781 "ServiceWorkerContextClient::OnGeofencingEvent"); |
| 777 proxy_->dispatchGeofencingEvent( | 782 proxy_->dispatchGeofencingEvent( |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 987 } | 992 } |
| 988 | 993 |
| 989 base::WeakPtr<ServiceWorkerContextClient> | 994 base::WeakPtr<ServiceWorkerContextClient> |
| 990 ServiceWorkerContextClient::GetWeakPtr() { | 995 ServiceWorkerContextClient::GetWeakPtr() { |
| 991 DCHECK(worker_task_runner_->RunsTasksOnCurrentThread()); | 996 DCHECK(worker_task_runner_->RunsTasksOnCurrentThread()); |
| 992 DCHECK(context_); | 997 DCHECK(context_); |
| 993 return context_->weak_factory.GetWeakPtr(); | 998 return context_->weak_factory.GetWeakPtr(); |
| 994 } | 999 } |
| 995 | 1000 |
| 996 } // namespace content | 1001 } // namespace content |
| OLD | NEW |