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/browser/devtools/protocol/service_worker_handler.h" | 5 #include "content/browser/devtools/protocol/service_worker_handler.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/containers/scoped_ptr_hash_map.h" | 8 #include "base/containers/scoped_ptr_hash_map.h" |
9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
11 #include "content/browser/devtools/service_worker_devtools_agent_host.h" | 11 #include "content/browser/devtools/service_worker_devtools_agent_host.h" |
12 #include "content/browser/devtools/service_worker_devtools_manager.h" | 12 #include "content/browser/devtools/service_worker_devtools_manager.h" |
13 #include "content/browser/frame_host/frame_tree.h" | 13 #include "content/browser/frame_host/frame_tree.h" |
14 #include "content/browser/frame_host/frame_tree_node.h" | 14 #include "content/browser/frame_host/frame_tree_node.h" |
15 #include "content/browser/frame_host/render_frame_host_impl.h" | 15 #include "content/browser/frame_host/render_frame_host_impl.h" |
16 #include "content/browser/service_worker/service_worker_context_watcher.h" | 16 #include "content/browser/service_worker/service_worker_context_watcher.h" |
17 #include "content/browser/service_worker/service_worker_context_wrapper.h" | 17 #include "content/browser/service_worker/service_worker_context_wrapper.h" |
18 #include "content/browser/service_worker/service_worker_version.h" | 18 #include "content/browser/service_worker/service_worker_version.h" |
19 #include "content/public/browser/browser_context.h" | 19 #include "content/public/browser/browser_context.h" |
20 #include "content/public/browser/browser_thread.h" | 20 #include "content/public/browser/browser_thread.h" |
21 #include "content/public/browser/devtools_agent_host.h" | 21 #include "content/public/browser/devtools_agent_host.h" |
22 #include "content/public/browser/render_frame_host.h" | 22 #include "content/public/browser/render_frame_host.h" |
23 #include "content/public/browser/render_process_host.h" | 23 #include "content/public/browser/render_process_host.h" |
24 #include "content/public/browser/storage_partition.h" | 24 #include "content/public/browser/storage_partition.h" |
25 #include "content/public/browser/web_contents.h" | 25 #include "content/public/browser/web_contents.h" |
26 #include "content/public/common/push_event_payload.h" | |
26 #include "content/public/common/push_messaging_status.h" | 27 #include "content/public/common/push_messaging_status.h" |
27 #include "url/gurl.h" | 28 #include "url/gurl.h" |
28 | 29 |
29 // Windows headers will redefine SendMessage. | 30 // Windows headers will redefine SendMessage. |
30 #ifdef SendMessage | 31 #ifdef SendMessage |
31 #undef SendMessage | 32 #undef SendMessage |
32 #endif | 33 #endif |
33 | 34 |
34 namespace content { | 35 namespace content { |
35 namespace devtools { | 36 namespace devtools { |
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
433 const std::string& origin, | 434 const std::string& origin, |
434 const std::string& registration_id, | 435 const std::string& registration_id, |
435 const std::string& data) { | 436 const std::string& data) { |
436 if (!enabled_) | 437 if (!enabled_) |
437 return Response::OK(); | 438 return Response::OK(); |
438 if (!render_frame_host_) | 439 if (!render_frame_host_) |
439 return CreateContextErrorResponse(); | 440 return CreateContextErrorResponse(); |
440 int64_t id = 0; | 441 int64_t id = 0; |
441 if (!base::StringToInt64(registration_id, &id)) | 442 if (!base::StringToInt64(registration_id, &id)) |
442 return CreateInvalidVersionIdErrorResponse(); | 443 return CreateInvalidVersionIdErrorResponse(); |
444 PushEventPayload payload; | |
445 payload.setData(data); | |
Peter Beverloo
2016/01/26 12:35:18
Perhaps only setData() if |data.size() > 0|? (The
harkness
2016/01/26 14:49:20
Done.
| |
443 BrowserContext::DeliverPushMessage( | 446 BrowserContext::DeliverPushMessage( |
444 render_frame_host_->GetProcess()->GetBrowserContext(), GURL(origin), id, | 447 render_frame_host_->GetProcess()->GetBrowserContext(), GURL(origin), id, |
445 data, base::Bind(&PushDeliveryNoOp)); | 448 payload, base::Bind(&PushDeliveryNoOp)); |
446 return Response::OK(); | 449 return Response::OK(); |
447 } | 450 } |
448 | 451 |
449 Response ServiceWorkerHandler::GetTargetInfo( | 452 Response ServiceWorkerHandler::GetTargetInfo( |
450 const std::string& target_id, | 453 const std::string& target_id, |
451 scoped_refptr<TargetInfo>* target_info) { | 454 scoped_refptr<TargetInfo>* target_info) { |
452 scoped_refptr<DevToolsAgentHost> agent_host( | 455 scoped_refptr<DevToolsAgentHost> agent_host( |
453 DevToolsAgentHost::GetForId(target_id)); | 456 DevToolsAgentHost::GetForId(target_id)); |
454 if (!agent_host) | 457 if (!agent_host) |
455 return Response::InvalidParams("targetId"); | 458 return Response::InvalidParams("targetId"); |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
593 return; | 596 return; |
594 host->DetachClient(); | 597 host->DetachClient(); |
595 client_->WorkerTerminated(WorkerTerminatedParams::Create()-> | 598 client_->WorkerTerminated(WorkerTerminatedParams::Create()-> |
596 set_worker_id(host->GetId())); | 599 set_worker_id(host->GetId())); |
597 attached_hosts_.erase(it); | 600 attached_hosts_.erase(it); |
598 } | 601 } |
599 | 602 |
600 } // namespace service_worker | 603 } // namespace service_worker |
601 } // namespace devtools | 604 } // namespace devtools |
602 } // namespace content | 605 } // namespace content |
OLD | NEW |