| 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 11 matching lines...) Expand all Loading... |
| 22 #include "content/browser/devtools/protocol/emulation_handler.h" | 22 #include "content/browser/devtools/protocol/emulation_handler.h" |
| 23 #include "content/browser/devtools/protocol/input_handler.h" | 23 #include "content/browser/devtools/protocol/input_handler.h" |
| 24 #include "content/browser/devtools/protocol/inspector_handler.h" | 24 #include "content/browser/devtools/protocol/inspector_handler.h" |
| 25 #include "content/browser/devtools/protocol/io_handler.h" | 25 #include "content/browser/devtools/protocol/io_handler.h" |
| 26 #include "content/browser/devtools/protocol/network_handler.h" | 26 #include "content/browser/devtools/protocol/network_handler.h" |
| 27 #include "content/browser/devtools/protocol/page_handler.h" | 27 #include "content/browser/devtools/protocol/page_handler.h" |
| 28 #include "content/browser/devtools/protocol/schema_handler.h" | 28 #include "content/browser/devtools/protocol/schema_handler.h" |
| 29 #include "content/browser/devtools/protocol/security_handler.h" | 29 #include "content/browser/devtools/protocol/security_handler.h" |
| 30 #include "content/browser/devtools/protocol/service_worker_handler.h" | 30 #include "content/browser/devtools/protocol/service_worker_handler.h" |
| 31 #include "content/browser/devtools/protocol/storage_handler.h" | 31 #include "content/browser/devtools/protocol/storage_handler.h" |
| 32 #include "content/browser/devtools/protocol/target_handler.h" |
| 32 #include "content/browser/devtools/protocol/tracing_handler.h" | 33 #include "content/browser/devtools/protocol/tracing_handler.h" |
| 33 #include "content/browser/frame_host/navigation_handle_impl.h" | 34 #include "content/browser/frame_host/navigation_handle_impl.h" |
| 34 #include "content/browser/frame_host/render_frame_host_impl.h" | 35 #include "content/browser/frame_host/render_frame_host_impl.h" |
| 35 #include "content/browser/renderer_host/input/input_router_impl.h" | 36 #include "content/browser/renderer_host/input/input_router_impl.h" |
| 36 #include "content/browser/renderer_host/render_process_host_impl.h" | 37 #include "content/browser/renderer_host/render_process_host_impl.h" |
| 37 #include "content/browser/renderer_host/render_view_host_impl.h" | 38 #include "content/browser/renderer_host/render_view_host_impl.h" |
| 38 #include "content/browser/site_instance_impl.h" | 39 #include "content/browser/site_instance_impl.h" |
| 39 #include "content/browser/web_contents/web_contents_impl.h" | 40 #include "content/browser/web_contents/web_contents_impl.h" |
| 40 #include "content/common/view_messages.h" | 41 #include "content/common/view_messages.h" |
| 41 #include "content/public/browser/browser_context.h" | 42 #include "content/public/browser/browser_context.h" |
| (...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 378 input_handler_(new devtools::input::InputHandler()), | 379 input_handler_(new devtools::input::InputHandler()), |
| 379 inspector_handler_(new devtools::inspector::InspectorHandler()), | 380 inspector_handler_(new devtools::inspector::InspectorHandler()), |
| 380 io_handler_(new devtools::io::IOHandler(GetIOContext())), | 381 io_handler_(new devtools::io::IOHandler(GetIOContext())), |
| 381 network_handler_(new devtools::network::NetworkHandler()), | 382 network_handler_(new devtools::network::NetworkHandler()), |
| 382 page_handler_(nullptr), | 383 page_handler_(nullptr), |
| 383 schema_handler_(new devtools::schema::SchemaHandler()), | 384 schema_handler_(new devtools::schema::SchemaHandler()), |
| 384 security_handler_(nullptr), | 385 security_handler_(nullptr), |
| 385 service_worker_handler_( | 386 service_worker_handler_( |
| 386 new devtools::service_worker::ServiceWorkerHandler()), | 387 new devtools::service_worker::ServiceWorkerHandler()), |
| 387 storage_handler_(new devtools::storage::StorageHandler()), | 388 storage_handler_(new devtools::storage::StorageHandler()), |
| 389 target_handler_(new devtools::target::TargetHandler()), |
| 388 tracing_handler_(new devtools::tracing::TracingHandler( | 390 tracing_handler_(new devtools::tracing::TracingHandler( |
| 389 devtools::tracing::TracingHandler::Renderer, | 391 devtools::tracing::TracingHandler::Renderer, |
| 390 host->GetFrameTreeNodeId(), | 392 host->GetFrameTreeNodeId(), |
| 391 GetIOContext())), | 393 GetIOContext())), |
| 392 emulation_handler_(nullptr), | 394 emulation_handler_(nullptr), |
| 393 frame_trace_recorder_(nullptr), | 395 frame_trace_recorder_(nullptr), |
| 394 protocol_handler_(new DevToolsProtocolHandler(this)), | 396 protocol_handler_(new DevToolsProtocolHandler(this)), |
| 395 current_frame_crashed_(false), | 397 current_frame_crashed_(false), |
| 396 pending_handle_(nullptr), | 398 pending_handle_(nullptr), |
| 397 frame_tree_node_(host->frame_tree_node()) { | 399 frame_tree_node_(host->frame_tree_node()) { |
| 398 DevToolsProtocolDispatcher* dispatcher = protocol_handler_->dispatcher(); | 400 DevToolsProtocolDispatcher* dispatcher = protocol_handler_->dispatcher(); |
| 399 dispatcher->SetBrowserHandler(browser_handler_.get()); | 401 dispatcher->SetBrowserHandler(browser_handler_.get()); |
| 400 dispatcher->SetDOMHandler(dom_handler_.get()); | 402 dispatcher->SetDOMHandler(dom_handler_.get()); |
| 401 dispatcher->SetInputHandler(input_handler_.get()); | 403 dispatcher->SetInputHandler(input_handler_.get()); |
| 402 dispatcher->SetInspectorHandler(inspector_handler_.get()); | 404 dispatcher->SetInspectorHandler(inspector_handler_.get()); |
| 403 dispatcher->SetIOHandler(io_handler_.get()); | 405 dispatcher->SetIOHandler(io_handler_.get()); |
| 404 dispatcher->SetNetworkHandler(network_handler_.get()); | 406 dispatcher->SetNetworkHandler(network_handler_.get()); |
| 405 dispatcher->SetSchemaHandler(schema_handler_.get()); | 407 dispatcher->SetSchemaHandler(schema_handler_.get()); |
| 406 dispatcher->SetServiceWorkerHandler(service_worker_handler_.get()); | 408 dispatcher->SetServiceWorkerHandler(service_worker_handler_.get()); |
| 407 dispatcher->SetStorageHandler(storage_handler_.get()); | 409 dispatcher->SetStorageHandler(storage_handler_.get()); |
| 410 dispatcher->SetTargetHandler(target_handler_.get()); |
| 408 dispatcher->SetTracingHandler(tracing_handler_.get()); | 411 dispatcher->SetTracingHandler(tracing_handler_.get()); |
| 409 | 412 |
| 410 if (!host->GetParent()) { | 413 if (!host->GetParent()) { |
| 411 security_handler_.reset(new devtools::security::SecurityHandler()); | 414 security_handler_.reset(new devtools::security::SecurityHandler()); |
| 412 page_handler_.reset(new devtools::page::PageHandler()); | 415 page_handler_.reset(new devtools::page::PageHandler()); |
| 413 emulation_handler_.reset( | 416 emulation_handler_.reset( |
| 414 new devtools::emulation::EmulationHandler()); | 417 new devtools::emulation::EmulationHandler()); |
| 415 dispatcher->SetSecurityHandler(security_handler_.get()); | 418 dispatcher->SetSecurityHandler(security_handler_.get()); |
| 416 dispatcher->SetPageHandler(page_handler_.get()); | 419 dispatcher->SetPageHandler(page_handler_.get()); |
| 417 dispatcher->SetEmulationHandler(emulation_handler_.get()); | 420 dispatcher->SetEmulationHandler(emulation_handler_.get()); |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 537 void RenderFrameDevToolsAgentHost::OnClientDetached() { | 540 void RenderFrameDevToolsAgentHost::OnClientDetached() { |
| 538 #if defined(OS_ANDROID) | 541 #if defined(OS_ANDROID) |
| 539 power_save_blocker_.reset(); | 542 power_save_blocker_.reset(); |
| 540 #endif | 543 #endif |
| 541 browser_handler_->Detached(); | 544 browser_handler_->Detached(); |
| 542 if (emulation_handler_) | 545 if (emulation_handler_) |
| 543 emulation_handler_->Detached(); | 546 emulation_handler_->Detached(); |
| 544 if (page_handler_) | 547 if (page_handler_) |
| 545 page_handler_->Detached(); | 548 page_handler_->Detached(); |
| 546 service_worker_handler_->Detached(); | 549 service_worker_handler_->Detached(); |
| 550 target_handler_->Detached(); |
| 547 tracing_handler_->Detached(); | 551 tracing_handler_->Detached(); |
| 548 frame_trace_recorder_.reset(); | 552 frame_trace_recorder_.reset(); |
| 549 in_navigation_protocol_message_buffer_.clear(); | 553 in_navigation_protocol_message_buffer_.clear(); |
| 550 | 554 |
| 551 // TODO(kaznacheev): Move this call back to DevToolsManager when | 555 // TODO(kaznacheev): Move this call back to DevToolsManager when |
| 552 // extensions::ProcessManager no longer relies on this notification. | 556 // extensions::ProcessManager no longer relies on this notification. |
| 553 DevToolsAgentHostImpl::NotifyCallbacks(this, false); | 557 DevToolsAgentHostImpl::NotifyCallbacks(this, false); |
| 554 } | 558 } |
| 555 | 559 |
| 556 RenderFrameDevToolsAgentHost::~RenderFrameDevToolsAgentHost() { | 560 RenderFrameDevToolsAgentHost::~RenderFrameDevToolsAgentHost() { |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 602 DCHECK(pending_->host() == navigation_handle->GetRenderFrameHost()); | 606 DCHECK(pending_->host() == navigation_handle->GetRenderFrameHost()); |
| 603 CommitPending(); | 607 CommitPending(); |
| 604 } else { | 608 } else { |
| 605 DiscardPending(); | 609 DiscardPending(); |
| 606 } | 610 } |
| 607 pending_handle_ = nullptr; | 611 pending_handle_ = nullptr; |
| 608 } | 612 } |
| 609 DispatchBufferedProtocolMessagesIfNecessary(); | 613 DispatchBufferedProtocolMessagesIfNecessary(); |
| 610 | 614 |
| 611 if (navigation_handle->HasCommitted()) | 615 if (navigation_handle->HasCommitted()) |
| 612 service_worker_handler_->UpdateHosts(); | 616 target_handler_->UpdateServiceWorkers(); |
| 613 } | 617 } |
| 614 | 618 |
| 615 void RenderFrameDevToolsAgentHost::AboutToNavigateRenderFrame( | 619 void RenderFrameDevToolsAgentHost::AboutToNavigateRenderFrame( |
| 616 RenderFrameHost* old_host, | 620 RenderFrameHost* old_host, |
| 617 RenderFrameHost* new_host) { | 621 RenderFrameHost* new_host) { |
| 618 if (IsBrowserSideNavigationEnabled()) | 622 if (IsBrowserSideNavigationEnabled()) |
| 619 return; | 623 return; |
| 620 | 624 |
| 621 DCHECK(!pending_ || pending_->host() != old_host); | 625 DCHECK(!pending_ || pending_->host() != old_host); |
| 622 if (!current_ || current_->host() != old_host) | 626 if (!current_ || current_->host() != old_host) |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 769 } | 773 } |
| 770 | 774 |
| 771 void RenderFrameDevToolsAgentHost::DidCommitProvisionalLoadForFrame( | 775 void RenderFrameDevToolsAgentHost::DidCommitProvisionalLoadForFrame( |
| 772 RenderFrameHost* render_frame_host, | 776 RenderFrameHost* render_frame_host, |
| 773 const GURL& url, | 777 const GURL& url, |
| 774 ui::PageTransition transition_type) { | 778 ui::PageTransition transition_type) { |
| 775 if (IsBrowserSideNavigationEnabled()) | 779 if (IsBrowserSideNavigationEnabled()) |
| 776 return; | 780 return; |
| 777 if (pending_ && pending_->host() == render_frame_host) | 781 if (pending_ && pending_->host() == render_frame_host) |
| 778 CommitPending(); | 782 CommitPending(); |
| 779 service_worker_handler_->UpdateHosts(); | 783 target_handler_->UpdateServiceWorkers(); |
| 780 } | 784 } |
| 781 | 785 |
| 782 void RenderFrameDevToolsAgentHost::DidFailProvisionalLoad( | 786 void RenderFrameDevToolsAgentHost::DidFailProvisionalLoad( |
| 783 RenderFrameHost* render_frame_host, | 787 RenderFrameHost* render_frame_host, |
| 784 const GURL& validated_url, | 788 const GURL& validated_url, |
| 785 int error_code, | 789 int error_code, |
| 786 const base::string16& error_description, | 790 const base::string16& error_description, |
| 787 bool was_ignored_by_handler) { | 791 bool was_ignored_by_handler) { |
| 788 if (IsBrowserSideNavigationEnabled()) | 792 if (IsBrowserSideNavigationEnabled()) |
| 789 return; | 793 return; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 824 host ? host->GetRenderWidgetHost() : nullptr); | 828 host ? host->GetRenderWidgetHost() : nullptr); |
| 825 inspector_handler_->SetRenderFrameHost(host); | 829 inspector_handler_->SetRenderFrameHost(host); |
| 826 network_handler_->SetRenderFrameHost(host); | 830 network_handler_->SetRenderFrameHost(host); |
| 827 if (page_handler_) | 831 if (page_handler_) |
| 828 page_handler_->SetRenderFrameHost(host); | 832 page_handler_->SetRenderFrameHost(host); |
| 829 service_worker_handler_->SetRenderFrameHost(host); | 833 service_worker_handler_->SetRenderFrameHost(host); |
| 830 if (security_handler_) | 834 if (security_handler_) |
| 831 security_handler_->SetRenderFrameHost(host); | 835 security_handler_->SetRenderFrameHost(host); |
| 832 if (storage_handler_) | 836 if (storage_handler_) |
| 833 storage_handler_->SetRenderFrameHost(host); | 837 storage_handler_->SetRenderFrameHost(host); |
| 838 target_handler_->SetRenderFrameHost(host); |
| 834 } | 839 } |
| 835 | 840 |
| 836 void RenderFrameDevToolsAgentHost::DisconnectWebContents() { | 841 void RenderFrameDevToolsAgentHost::DisconnectWebContents() { |
| 837 if (pending_) | 842 if (pending_) |
| 838 DiscardPending(); | 843 DiscardPending(); |
| 839 UpdateProtocolHandlers(nullptr); | 844 UpdateProtocolHandlers(nullptr); |
| 840 disconnected_ = std::move(current_); | 845 disconnected_ = std::move(current_); |
| 841 disconnected_->Detach(); | 846 disconnected_->Detach(); |
| 842 frame_tree_node_ = nullptr; | 847 frame_tree_node_ = nullptr; |
| 843 in_navigation_protocol_message_buffer_.clear(); | 848 in_navigation_protocol_message_buffer_.clear(); |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1022 RenderFrameHost* host) { | 1027 RenderFrameHost* host) { |
| 1023 return (current_ && current_->host() == host) || | 1028 return (current_ && current_->host() == host) || |
| 1024 (pending_ && pending_->host() == host); | 1029 (pending_ && pending_->host() == host); |
| 1025 } | 1030 } |
| 1026 | 1031 |
| 1027 bool RenderFrameDevToolsAgentHost::IsChildFrame() { | 1032 bool RenderFrameDevToolsAgentHost::IsChildFrame() { |
| 1028 return current_ && current_->host()->GetParent(); | 1033 return current_ && current_->host()->GetParent(); |
| 1029 } | 1034 } |
| 1030 | 1035 |
| 1031 } // namespace content | 1036 } // namespace content |
| OLD | NEW |