OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/render_frame_devtools_agent_host.h" | 5 #include "content/browser/devtools/render_frame_devtools_agent_host.h" |
6 | 6 |
7 #include <tuple> | 7 #include <tuple> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/guid.h" | 10 #include "base/guid.h" |
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
388 if (ShouldForceCreation()) { | 388 if (ShouldForceCreation()) { |
389 // Force agent host. | 389 // Force agent host. |
390 DevToolsAgentHost::GetOrCreateFor(web_contents); | 390 DevToolsAgentHost::GetOrCreateFor(web_contents); |
391 } | 391 } |
392 } | 392 } |
393 | 393 |
394 RenderFrameDevToolsAgentHost::RenderFrameDevToolsAgentHost( | 394 RenderFrameDevToolsAgentHost::RenderFrameDevToolsAgentHost( |
395 RenderFrameHostImpl* host) | 395 RenderFrameHostImpl* host) |
396 : DevToolsAgentHostImpl(base::GenerateGUID()), | 396 : DevToolsAgentHostImpl(base::GenerateGUID()), |
397 input_handler_(new devtools::input::InputHandler()), | 397 input_handler_(new devtools::input::InputHandler()), |
398 service_worker_handler_( | |
399 new devtools::service_worker::ServiceWorkerHandler()), | |
400 target_handler_(new devtools::target::TargetHandler()), | 398 target_handler_(new devtools::target::TargetHandler()), |
401 frame_trace_recorder_(nullptr), | 399 frame_trace_recorder_(nullptr), |
402 protocol_handler_(new DevToolsProtocolHandler(this)), | 400 protocol_handler_(new DevToolsProtocolHandler(this)), |
403 handlers_frame_host_(nullptr), | 401 handlers_frame_host_(nullptr), |
404 current_frame_crashed_(false), | 402 current_frame_crashed_(false), |
405 pending_handle_(nullptr), | 403 pending_handle_(nullptr), |
406 frame_tree_node_(host->frame_tree_node()) { | 404 frame_tree_node_(host->frame_tree_node()) { |
407 DevToolsProtocolDispatcher* dispatcher = protocol_handler_->dispatcher(); | 405 DevToolsProtocolDispatcher* dispatcher = protocol_handler_->dispatcher(); |
408 dispatcher->SetInputHandler(input_handler_.get()); | 406 dispatcher->SetInputHandler(input_handler_.get()); |
409 dispatcher->SetServiceWorkerHandler(service_worker_handler_.get()); | |
410 dispatcher->SetTargetHandler(target_handler_.get()); | 407 dispatcher->SetTargetHandler(target_handler_.get()); |
411 | 408 |
412 SetPending(host); | 409 SetPending(host); |
413 CommitPending(); | 410 CommitPending(); |
414 WebContentsObserver::Observe(WebContents::FromRenderFrameHost(host)); | 411 WebContentsObserver::Observe(WebContents::FromRenderFrameHost(host)); |
415 | 412 |
416 if (web_contents() && web_contents()->GetCrashedStatus() != | 413 if (web_contents() && web_contents()->GetCrashedStatus() != |
417 base::TERMINATION_STATUS_STILL_RUNNING) { | 414 base::TERMINATION_STATUS_STILL_RUNNING) { |
418 current_frame_crashed_ = true; | 415 current_frame_crashed_ = true; |
419 } | 416 } |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
502 | 499 |
503 schema_handler_.reset(new protocol::SchemaHandler()); | 500 schema_handler_.reset(new protocol::SchemaHandler()); |
504 schema_handler_->Wire(session()->dispatcher()); | 501 schema_handler_->Wire(session()->dispatcher()); |
505 | 502 |
506 if (!frame_tree_node_->parent()) { | 503 if (!frame_tree_node_->parent()) { |
507 security_handler_.reset(new protocol::SecurityHandler()); | 504 security_handler_.reset(new protocol::SecurityHandler()); |
508 security_handler_->Wire(session()->dispatcher()); | 505 security_handler_->Wire(session()->dispatcher()); |
509 security_handler_->SetRenderFrameHost(handlers_frame_host_); | 506 security_handler_->SetRenderFrameHost(handlers_frame_host_); |
510 } | 507 } |
511 | 508 |
| 509 service_worker_handler_.reset(new protocol::ServiceWorkerHandler()); |
| 510 service_worker_handler_->Wire(session()->dispatcher()); |
| 511 service_worker_handler_->SetRenderFrameHost(handlers_frame_host_); |
| 512 |
512 storage_handler_.reset(new protocol::StorageHandler()); | 513 storage_handler_.reset(new protocol::StorageHandler()); |
513 storage_handler_->Wire(session()->dispatcher()); | 514 storage_handler_->Wire(session()->dispatcher()); |
514 storage_handler_->SetRenderFrameHost(handlers_frame_host_); | 515 storage_handler_->SetRenderFrameHost(handlers_frame_host_); |
515 | 516 |
516 tracing_handler_.reset(new protocol::TracingHandler( | 517 tracing_handler_.reset(new protocol::TracingHandler( |
517 protocol::TracingHandler::Renderer, | 518 protocol::TracingHandler::Renderer, |
518 frame_tree_node_->frame_tree_node_id(), | 519 frame_tree_node_->frame_tree_node_id(), |
519 GetIOContext())); | 520 GetIOContext())); |
520 tracing_handler_->Wire(session()->dispatcher()); | 521 tracing_handler_->Wire(session()->dispatcher()); |
521 | 522 |
(...skipping 20 matching lines...) Expand all Loading... |
542 if (page_handler_) { | 543 if (page_handler_) { |
543 page_handler_->Disable(); | 544 page_handler_->Disable(); |
544 page_handler_.reset(); | 545 page_handler_.reset(); |
545 } | 546 } |
546 schema_handler_->Disable(); | 547 schema_handler_->Disable(); |
547 schema_handler_.reset(); | 548 schema_handler_.reset(); |
548 if (security_handler_) { | 549 if (security_handler_) { |
549 security_handler_->Disable(); | 550 security_handler_->Disable(); |
550 security_handler_.reset(); | 551 security_handler_.reset(); |
551 } | 552 } |
| 553 service_worker_handler_->Disable(); |
| 554 service_worker_handler_.reset(); |
552 storage_handler_->Disable(); | 555 storage_handler_->Disable(); |
553 storage_handler_.reset(); | 556 storage_handler_.reset(); |
554 tracing_handler_->Disable(); | 557 tracing_handler_->Disable(); |
555 tracing_handler_.reset(); | 558 tracing_handler_.reset(); |
556 | 559 |
557 if (current_) | 560 if (current_) |
558 current_->Detach(); | 561 current_->Detach(); |
559 if (pending_) | 562 if (pending_) |
560 pending_->Detach(); | 563 pending_->Detach(); |
561 OnClientDetached(); | 564 OnClientDetached(); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
608 return; | 611 return; |
609 | 612 |
610 frame_trace_recorder_.reset(new DevToolsFrameTraceRecorder()); | 613 frame_trace_recorder_.reset(new DevToolsFrameTraceRecorder()); |
611 CreatePowerSaveBlocker(); | 614 CreatePowerSaveBlocker(); |
612 } | 615 } |
613 | 616 |
614 void RenderFrameDevToolsAgentHost::OnClientDetached() { | 617 void RenderFrameDevToolsAgentHost::OnClientDetached() { |
615 #if defined(OS_ANDROID) | 618 #if defined(OS_ANDROID) |
616 power_save_blocker_.reset(); | 619 power_save_blocker_.reset(); |
617 #endif | 620 #endif |
618 service_worker_handler_->Detached(); | |
619 target_handler_->Detached(); | 621 target_handler_->Detached(); |
620 frame_trace_recorder_.reset(); | 622 frame_trace_recorder_.reset(); |
621 in_navigation_protocol_message_buffer_.clear(); | 623 in_navigation_protocol_message_buffer_.clear(); |
622 } | 624 } |
623 | 625 |
624 RenderFrameDevToolsAgentHost::~RenderFrameDevToolsAgentHost() { | 626 RenderFrameDevToolsAgentHost::~RenderFrameDevToolsAgentHost() { |
625 Instances::iterator it = std::find(g_instances.Get().begin(), | 627 Instances::iterator it = std::find(g_instances.Get().begin(), |
626 g_instances.Get().end(), | 628 g_instances.Get().end(), |
627 this); | 629 this); |
628 if (it != g_instances.Get().end()) | 630 if (it != g_instances.Get().end()) |
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
957 if (emulation_handler_) | 959 if (emulation_handler_) |
958 emulation_handler_->SetRenderFrameHost(host); | 960 emulation_handler_->SetRenderFrameHost(host); |
959 input_handler_->SetRenderWidgetHost( | 961 input_handler_->SetRenderWidgetHost( |
960 host ? host->GetRenderWidgetHost() : nullptr); | 962 host ? host->GetRenderWidgetHost() : nullptr); |
961 if (inspector_handler_) | 963 if (inspector_handler_) |
962 inspector_handler_->SetRenderFrameHost(host); | 964 inspector_handler_->SetRenderFrameHost(host); |
963 if (network_handler_) | 965 if (network_handler_) |
964 network_handler_->SetRenderFrameHost(host); | 966 network_handler_->SetRenderFrameHost(host); |
965 if (page_handler_) | 967 if (page_handler_) |
966 page_handler_->SetRenderFrameHost(host); | 968 page_handler_->SetRenderFrameHost(host); |
967 service_worker_handler_->SetRenderFrameHost(host); | 969 if (service_worker_handler_) |
| 970 service_worker_handler_->SetRenderFrameHost(host); |
968 if (security_handler_) | 971 if (security_handler_) |
969 security_handler_->SetRenderFrameHost(host); | 972 security_handler_->SetRenderFrameHost(host); |
970 if (storage_handler_) | 973 if (storage_handler_) |
971 storage_handler_->SetRenderFrameHost(host); | 974 storage_handler_->SetRenderFrameHost(host); |
972 target_handler_->SetRenderFrameHost(host); | 975 target_handler_->SetRenderFrameHost(host); |
973 } | 976 } |
974 | 977 |
975 void RenderFrameDevToolsAgentHost::DisconnectWebContents() { | 978 void RenderFrameDevToolsAgentHost::DisconnectWebContents() { |
976 if (pending_) | 979 if (pending_) |
977 DiscardPending(); | 980 DiscardPending(); |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1183 RenderFrameHost* host) { | 1186 RenderFrameHost* host) { |
1184 return (current_ && current_->host() == host) || | 1187 return (current_ && current_->host() == host) || |
1185 (pending_ && pending_->host() == host); | 1188 (pending_ && pending_->host() == host); |
1186 } | 1189 } |
1187 | 1190 |
1188 bool RenderFrameDevToolsAgentHost::IsChildFrame() { | 1191 bool RenderFrameDevToolsAgentHost::IsChildFrame() { |
1189 return current_ && current_->host()->GetParent(); | 1192 return current_ && current_->host()->GetParent(); |
1190 } | 1193 } |
1191 | 1194 |
1192 } // namespace content | 1195 } // namespace content |
OLD | NEW |