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/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
12 #include "build/build_config.h" | 12 #include "build/build_config.h" |
13 #include "content/browser/child_process_security_policy_impl.h" | 13 #include "content/browser/child_process_security_policy_impl.h" |
14 #include "content/browser/devtools/devtools_frame_trace_recorder.h" | 14 #include "content/browser/devtools/devtools_frame_trace_recorder.h" |
15 #include "content/browser/devtools/devtools_protocol_handler.h" | 15 #include "content/browser/devtools/devtools_protocol_handler.h" |
| 16 #include "content/browser/devtools/page_navigation_throttle.h" |
16 #include "content/browser/devtools/protocol/browser_handler.h" | 17 #include "content/browser/devtools/protocol/browser_handler.h" |
17 #include "content/browser/devtools/protocol/dom_handler.h" | 18 #include "content/browser/devtools/protocol/dom_handler.h" |
18 #include "content/browser/devtools/protocol/emulation_handler.h" | 19 #include "content/browser/devtools/protocol/emulation_handler.h" |
19 #include "content/browser/devtools/protocol/input_handler.h" | 20 #include "content/browser/devtools/protocol/input_handler.h" |
20 #include "content/browser/devtools/protocol/inspector_handler.h" | 21 #include "content/browser/devtools/protocol/inspector_handler.h" |
21 #include "content/browser/devtools/protocol/io_handler.h" | 22 #include "content/browser/devtools/protocol/io_handler.h" |
22 #include "content/browser/devtools/protocol/network_handler.h" | 23 #include "content/browser/devtools/protocol/network_handler.h" |
23 #include "content/browser/devtools/protocol/page_handler.h" | 24 #include "content/browser/devtools/protocol/page_handler.h" |
24 #include "content/browser/devtools/protocol/security_handler.h" | 25 #include "content/browser/devtools/protocol/security_handler.h" |
25 #include "content/browser/devtools/protocol/service_worker_handler.h" | 26 #include "content/browser/devtools/protocol/service_worker_handler.h" |
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
338 // static | 339 // static |
339 void RenderFrameDevToolsAgentHost::OnBeforeNavigation( | 340 void RenderFrameDevToolsAgentHost::OnBeforeNavigation( |
340 NavigationHandle* navigation_handle) { | 341 NavigationHandle* navigation_handle) { |
341 FrameTreeNode* frame_tree_node = | 342 FrameTreeNode* frame_tree_node = |
342 static_cast<NavigationHandleImpl*>(navigation_handle)->frame_tree_node(); | 343 static_cast<NavigationHandleImpl*>(navigation_handle)->frame_tree_node(); |
343 RenderFrameDevToolsAgentHost* agent_host = FindAgentHost(frame_tree_node); | 344 RenderFrameDevToolsAgentHost* agent_host = FindAgentHost(frame_tree_node); |
344 if (agent_host) | 345 if (agent_host) |
345 agent_host->AboutToNavigate(navigation_handle); | 346 agent_host->AboutToNavigate(navigation_handle); |
346 } | 347 } |
347 | 348 |
| 349 // static |
| 350 std::unique_ptr<NavigationThrottle> |
| 351 RenderFrameDevToolsAgentHost::CreateThrottleForNavigation( |
| 352 NavigationHandle* navigation_handle) { |
| 353 FrameTreeNode* frame_tree_node = |
| 354 static_cast<NavigationHandleImpl*>(navigation_handle)->frame_tree_node(); |
| 355 while (frame_tree_node && frame_tree_node->parent()) { |
| 356 frame_tree_node = frame_tree_node->parent(); |
| 357 } |
| 358 RenderFrameDevToolsAgentHost* agent_host = FindAgentHost(frame_tree_node); |
| 359 // Note Page.setControlNavigations is intended to control navigations in the |
| 360 // main frame and all child frames and |page_handler_| only exists for the |
| 361 // main frame. |
| 362 if (agent_host && agent_host->page_handler_) { |
| 363 return agent_host->page_handler_->CreateThrottleForNavigation( |
| 364 navigation_handle); |
| 365 } |
| 366 return nullptr; |
| 367 } |
| 368 |
348 RenderFrameDevToolsAgentHost::RenderFrameDevToolsAgentHost( | 369 RenderFrameDevToolsAgentHost::RenderFrameDevToolsAgentHost( |
349 RenderFrameHostImpl* host) | 370 RenderFrameHostImpl* host) |
350 : browser_handler_(new devtools::browser::BrowserHandler()), | 371 : browser_handler_(new devtools::browser::BrowserHandler()), |
351 dom_handler_(new devtools::dom::DOMHandler()), | 372 dom_handler_(new devtools::dom::DOMHandler()), |
352 input_handler_(new devtools::input::InputHandler()), | 373 input_handler_(new devtools::input::InputHandler()), |
353 inspector_handler_(new devtools::inspector::InspectorHandler()), | 374 inspector_handler_(new devtools::inspector::InspectorHandler()), |
354 io_handler_(new devtools::io::IOHandler(GetIOContext())), | 375 io_handler_(new devtools::io::IOHandler(GetIOContext())), |
355 network_handler_(new devtools::network::NetworkHandler()), | 376 network_handler_(new devtools::network::NetworkHandler()), |
356 page_handler_(nullptr), | 377 page_handler_(nullptr), |
357 security_handler_(nullptr), | 378 security_handler_(nullptr), |
(...skipping 564 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
922 RenderFrameHost* host) { | 943 RenderFrameHost* host) { |
923 return (current_ && current_->host() == host) || | 944 return (current_ && current_->host() == host) || |
924 (pending_ && pending_->host() == host); | 945 (pending_ && pending_->host() == host); |
925 } | 946 } |
926 | 947 |
927 bool RenderFrameDevToolsAgentHost::IsChildFrame() { | 948 bool RenderFrameDevToolsAgentHost::IsChildFrame() { |
928 return current_ && current_->host()->GetParent(); | 949 return current_ && current_->host()->GetParent(); |
929 } | 950 } |
930 | 951 |
931 } // namespace content | 952 } // namespace content |
OLD | NEW |