Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(72)

Side by Side Diff: content/browser/devtools/render_frame_devtools_agent_host.cc

Issue 2132673002: Adding Navigation Throttles to DevTools (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Renamed Page.setNavigationThrottleEnabled to Page.setControlNavigations Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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::GetThrottleForNavigation(
352 NavigationHandle* navigation_handle) {
353 // NOTE a single throttle registered by Page.setControlNavigations is intended
nasko 2016/07/13 22:37:34 This comment is not entirely correct. Each navigat
alex clarke (OOO till 29th) 2016/07/14 16:06:05 Acknowledged.
354 // to control navigations in the main frame and all child frames.
355 FrameTreeNode* frame_tree_node =
356 static_cast<NavigationHandleImpl*>(navigation_handle)->frame_tree_node();
357 while (frame_tree_node && frame_tree_node->parent()) {
358 frame_tree_node = frame_tree_node->parent();
359 }
360 RenderFrameDevToolsAgentHost* agent_host = FindAgentHost(frame_tree_node);
361 if (agent_host && agent_host->page_handler_) {
nasko 2016/07/13 22:37:34 After offline chat with dgozman@, it became more c
alex clarke (OOO till 29th) 2016/07/14 16:06:05 Done.
362 return agent_host->page_handler_->GetThrottleForNavigation(
363 navigation_handle);
364 }
365 return nullptr;
366 }
367
348 RenderFrameDevToolsAgentHost::RenderFrameDevToolsAgentHost( 368 RenderFrameDevToolsAgentHost::RenderFrameDevToolsAgentHost(
349 RenderFrameHostImpl* host) 369 RenderFrameHostImpl* host)
350 : browser_handler_(new devtools::browser::BrowserHandler()), 370 : browser_handler_(new devtools::browser::BrowserHandler()),
351 dom_handler_(new devtools::dom::DOMHandler()), 371 dom_handler_(new devtools::dom::DOMHandler()),
352 input_handler_(new devtools::input::InputHandler()), 372 input_handler_(new devtools::input::InputHandler()),
353 inspector_handler_(new devtools::inspector::InspectorHandler()), 373 inspector_handler_(new devtools::inspector::InspectorHandler()),
354 io_handler_(new devtools::io::IOHandler(GetIOContext())), 374 io_handler_(new devtools::io::IOHandler(GetIOContext())),
355 network_handler_(new devtools::network::NetworkHandler()), 375 network_handler_(new devtools::network::NetworkHandler()),
356 page_handler_(nullptr), 376 page_handler_(nullptr),
357 security_handler_(nullptr), 377 security_handler_(nullptr),
(...skipping 564 matching lines...) Expand 10 before | Expand all | Expand 10 after
922 RenderFrameHost* host) { 942 RenderFrameHost* host) {
923 return (current_ && current_->host() == host) || 943 return (current_ && current_->host() == host) ||
924 (pending_ && pending_->host() == host); 944 (pending_ && pending_->host() == host);
925 } 945 }
926 946
927 bool RenderFrameDevToolsAgentHost::IsChildFrame() { 947 bool RenderFrameDevToolsAgentHost::IsChildFrame() {
928 return current_ && current_->host()->GetParent(); 948 return current_ && current_->host()->GetParent();
929 } 949 }
930 950
931 } // namespace content 951 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698