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 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
387 WebContents* web_contents) { | 387 WebContents* web_contents) { |
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()), | |
398 frame_trace_recorder_(nullptr), | 397 frame_trace_recorder_(nullptr), |
399 protocol_handler_(new DevToolsProtocolHandler(this)), | 398 protocol_handler_(new DevToolsProtocolHandler(this)), |
400 handlers_frame_host_(nullptr), | 399 handlers_frame_host_(nullptr), |
401 current_frame_crashed_(false), | 400 current_frame_crashed_(false), |
402 pending_handle_(nullptr), | 401 pending_handle_(nullptr), |
403 frame_tree_node_(host->frame_tree_node()) { | 402 frame_tree_node_(host->frame_tree_node()) { |
404 DevToolsProtocolDispatcher* dispatcher = protocol_handler_->dispatcher(); | |
405 dispatcher->SetInputHandler(input_handler_.get()); | |
406 | |
407 SetPending(host); | 403 SetPending(host); |
408 CommitPending(); | 404 CommitPending(); |
409 WebContentsObserver::Observe(WebContents::FromRenderFrameHost(host)); | 405 WebContentsObserver::Observe(WebContents::FromRenderFrameHost(host)); |
410 | 406 |
411 if (web_contents() && web_contents()->GetCrashedStatus() != | 407 if (web_contents() && web_contents()->GetCrashedStatus() != |
412 base::TERMINATION_STATUS_STILL_RUNNING) { | 408 base::TERMINATION_STATUS_STILL_RUNNING) { |
413 current_frame_crashed_ = true; | 409 current_frame_crashed_ = true; |
414 } | 410 } |
415 | 411 |
416 g_instances.Get().push_back(this); | 412 g_instances.Get().push_back(this); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
471 if (!frame_tree_node_->parent()) { | 467 if (!frame_tree_node_->parent()) { |
472 emulation_handler_.reset(new protocol::EmulationHandler()); | 468 emulation_handler_.reset(new protocol::EmulationHandler()); |
473 emulation_handler_->Wire(session()->dispatcher()); | 469 emulation_handler_->Wire(session()->dispatcher()); |
474 emulation_handler_->SetRenderFrameHost(handlers_frame_host_); | 470 emulation_handler_->SetRenderFrameHost(handlers_frame_host_); |
475 } | 471 } |
476 | 472 |
477 dom_handler_.reset(new protocol::DOMHandler()); | 473 dom_handler_.reset(new protocol::DOMHandler()); |
478 dom_handler_->Wire(session()->dispatcher()); | 474 dom_handler_->Wire(session()->dispatcher()); |
479 dom_handler_->SetRenderFrameHost(handlers_frame_host_); | 475 dom_handler_->SetRenderFrameHost(handlers_frame_host_); |
480 | 476 |
| 477 input_handler_.reset(new protocol::InputHandler()); |
| 478 input_handler_->Wire(session()->dispatcher()); |
| 479 input_handler_->SetRenderFrameHost(handlers_frame_host_); |
| 480 |
481 inspector_handler_.reset(new protocol::InspectorHandler()); | 481 inspector_handler_.reset(new protocol::InspectorHandler()); |
482 inspector_handler_->Wire(session()->dispatcher()); | 482 inspector_handler_->Wire(session()->dispatcher()); |
483 inspector_handler_->SetRenderFrameHost(handlers_frame_host_); | 483 inspector_handler_->SetRenderFrameHost(handlers_frame_host_); |
484 | 484 |
485 io_handler_.reset(new protocol::IOHandler(GetIOContext())); | 485 io_handler_.reset(new protocol::IOHandler(GetIOContext())); |
486 io_handler_->Wire(session()->dispatcher()); | 486 io_handler_->Wire(session()->dispatcher()); |
487 | 487 |
488 network_handler_.reset(new protocol::NetworkHandler()); | 488 network_handler_.reset(new protocol::NetworkHandler()); |
489 network_handler_->Wire(session()->dispatcher()); | 489 network_handler_->Wire(session()->dispatcher()); |
490 network_handler_->SetRenderFrameHost(handlers_frame_host_); | 490 network_handler_->SetRenderFrameHost(handlers_frame_host_); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
528 OnClientAttached(); | 528 OnClientAttached(); |
529 } | 529 } |
530 | 530 |
531 void RenderFrameDevToolsAgentHost::Detach() { | 531 void RenderFrameDevToolsAgentHost::Detach() { |
532 dom_handler_->Disable(); | 532 dom_handler_->Disable(); |
533 dom_handler_.reset(); | 533 dom_handler_.reset(); |
534 if (emulation_handler_) { | 534 if (emulation_handler_) { |
535 emulation_handler_->Disable(); | 535 emulation_handler_->Disable(); |
536 emulation_handler_.reset(); | 536 emulation_handler_.reset(); |
537 } | 537 } |
| 538 input_handler_->Disable(); |
| 539 input_handler_.reset(); |
538 inspector_handler_->Disable(); | 540 inspector_handler_->Disable(); |
539 inspector_handler_.reset(); | 541 inspector_handler_.reset(); |
540 io_handler_->Disable(); | 542 io_handler_->Disable(); |
541 io_handler_.reset(); | 543 io_handler_.reset(); |
542 network_handler_->Disable(); | 544 network_handler_->Disable(); |
543 network_handler_.reset(); | 545 network_handler_.reset(); |
544 if (page_handler_) { | 546 if (page_handler_) { |
545 page_handler_->Disable(); | 547 page_handler_->Disable(); |
546 page_handler_.reset(); | 548 page_handler_.reset(); |
547 } | 549 } |
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
955 // Check that we don't have stale host object here by accessing some random | 957 // Check that we don't have stale host object here by accessing some random |
956 // properties inside. | 958 // properties inside. |
957 if (handlers_frame_host_ && handlers_frame_host_->GetRenderWidgetHost()) | 959 if (handlers_frame_host_ && handlers_frame_host_->GetRenderWidgetHost()) |
958 handlers_frame_host_->GetRenderWidgetHost()->GetRoutingID(); | 960 handlers_frame_host_->GetRenderWidgetHost()->GetRoutingID(); |
959 #endif | 961 #endif |
960 handlers_frame_host_ = host; | 962 handlers_frame_host_ = host; |
961 if (dom_handler_) | 963 if (dom_handler_) |
962 dom_handler_->SetRenderFrameHost(host); | 964 dom_handler_->SetRenderFrameHost(host); |
963 if (emulation_handler_) | 965 if (emulation_handler_) |
964 emulation_handler_->SetRenderFrameHost(host); | 966 emulation_handler_->SetRenderFrameHost(host); |
965 input_handler_->SetRenderWidgetHost( | 967 if (input_handler_) |
966 host ? host->GetRenderWidgetHost() : nullptr); | 968 input_handler_->SetRenderFrameHost(host); |
967 if (inspector_handler_) | 969 if (inspector_handler_) |
968 inspector_handler_->SetRenderFrameHost(host); | 970 inspector_handler_->SetRenderFrameHost(host); |
969 if (network_handler_) | 971 if (network_handler_) |
970 network_handler_->SetRenderFrameHost(host); | 972 network_handler_->SetRenderFrameHost(host); |
971 if (page_handler_) | 973 if (page_handler_) |
972 page_handler_->SetRenderFrameHost(host); | 974 page_handler_->SetRenderFrameHost(host); |
973 if (service_worker_handler_) | 975 if (service_worker_handler_) |
974 service_worker_handler_->SetRenderFrameHost(host); | 976 service_worker_handler_->SetRenderFrameHost(host); |
975 if (security_handler_) | 977 if (security_handler_) |
976 security_handler_->SetRenderFrameHost(host); | 978 security_handler_->SetRenderFrameHost(host); |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1191 RenderFrameHost* host) { | 1193 RenderFrameHost* host) { |
1192 return (current_ && current_->host() == host) || | 1194 return (current_ && current_->host() == host) || |
1193 (pending_ && pending_->host() == host); | 1195 (pending_ && pending_->host() == host); |
1194 } | 1196 } |
1195 | 1197 |
1196 bool RenderFrameDevToolsAgentHost::IsChildFrame() { | 1198 bool RenderFrameDevToolsAgentHost::IsChildFrame() { |
1197 return current_ && current_->host()->GetParent(); | 1199 return current_ && current_->host()->GetParent(); |
1198 } | 1200 } |
1199 | 1201 |
1200 } // namespace content | 1202 } // namespace content |
OLD | NEW |