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

Side by Side Diff: content/browser/frame_host/navigation_handle_impl.cc

Issue 2132673002: Adding Navigation Throttles to DevTools (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove print 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
« no previous file with comments | « content/browser/frame_host/navigation_handle_impl.h ('k') | content/content_browser.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/frame_host/navigation_handle_impl.h" 5 #include "content/browser/frame_host/navigation_handle_impl.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "content/browser/devtools/render_frame_devtools_agent_host.h"
10 #include "content/browser/frame_host/frame_tree_node.h" 11 #include "content/browser/frame_host/frame_tree_node.h"
11 #include "content/browser/frame_host/navigator.h" 12 #include "content/browser/frame_host/navigator.h"
12 #include "content/browser/frame_host/navigator_delegate.h" 13 #include "content/browser/frame_host/navigator_delegate.h"
13 #include "content/browser/service_worker/service_worker_context_wrapper.h" 14 #include "content/browser/service_worker/service_worker_context_wrapper.h"
14 #include "content/common/frame_messages.h" 15 #include "content/common/frame_messages.h"
15 #include "content/common/resource_request_body_impl.h" 16 #include "content/common/resource_request_body_impl.h"
16 #include "content/public/browser/content_browser_client.h" 17 #include "content/public/browser/content_browser_client.h"
17 #include "content/public/common/browser_side_navigation_policy.h" 18 #include "content/public/common/browser_side_navigation_policy.h"
18 #include "content/public/common/content_client.h" 19 #include "content/public/common/content_client.h"
19 #include "net/url_request/redirect_info.h" 20 #include "net/url_request/redirect_info.h"
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 if (method_ == "POST") 317 if (method_ == "POST")
317 resource_request_body_ = resource_request_body; 318 resource_request_body_ = resource_request_body;
318 sanitized_referrer_ = sanitized_referrer; 319 sanitized_referrer_ = sanitized_referrer;
319 has_user_gesture_ = has_user_gesture; 320 has_user_gesture_ = has_user_gesture;
320 transition_ = transition; 321 transition_ = transition;
321 is_external_protocol_ = is_external_protocol; 322 is_external_protocol_ = is_external_protocol;
322 323
323 state_ = WILL_SEND_REQUEST; 324 state_ = WILL_SEND_REQUEST;
324 complete_callback_ = callback; 325 complete_callback_ = callback;
325 326
326 // Register the navigation throttles. The ScopedVector returned by 327 RegisterNavigationThrottles();
327 // GetNavigationThrottles is not assigned to throttles_ directly because it
328 // would overwrite any throttle previously added with
329 // RegisterThrottleForTesting.
330 ScopedVector<NavigationThrottle> throttles_to_register =
331 GetContentClient()->browser()->CreateThrottlesForNavigation(this);
332 if (throttles_to_register.size() > 0) {
333 throttles_.insert(throttles_.end(), throttles_to_register.begin(),
334 throttles_to_register.end());
335 throttles_to_register.weak_clear();
336 }
337 328
338 // Notify each throttle of the request. 329 // Notify each throttle of the request.
339 NavigationThrottle::ThrottleCheckResult result = CheckWillStartRequest(); 330 NavigationThrottle::ThrottleCheckResult result = CheckWillStartRequest();
340 331
341 // If the navigation is not deferred, run the callback. 332 // If the navigation is not deferred, run the callback.
342 if (result != NavigationThrottle::DEFER) 333 if (result != NavigationThrottle::DEFER)
343 RunCompleteCallback(result); 334 RunCompleteCallback(result);
344 } 335 }
345 336
346 void NavigationHandleImpl::WillRedirectRequest( 337 void NavigationHandleImpl::WillRedirectRequest(
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
526 ThrottleChecksFinishedCallback callback = complete_callback_; 517 ThrottleChecksFinishedCallback callback = complete_callback_;
527 complete_callback_.Reset(); 518 complete_callback_.Reset();
528 519
529 if (!callback.is_null()) 520 if (!callback.is_null())
530 callback.Run(result); 521 callback.Run(result);
531 522
532 // No code after running the callback, as it might have resulted in our 523 // No code after running the callback, as it might have resulted in our
533 // destruction. 524 // destruction.
534 } 525 }
535 526
527 void NavigationHandleImpl::RegisterNavigationThrottles() {
528 // Register the navigation throttles. The ScopedVector returned by
529 // GetNavigationThrottles is not assigned to throttles_ directly because it
530 // would overwrite any throttle previously added with
531 // RegisterThrottleForTesting.
532 ScopedVector<NavigationThrottle> throttles_to_register =
533 GetContentClient()->browser()->CreateThrottlesForNavigation(this);
534 if (throttles_to_register.size() > 0) {
535 throttles_.insert(throttles_.end(), throttles_to_register.begin(),
536 throttles_to_register.end());
537 throttles_to_register.weak_clear();
538 }
539 std::unique_ptr<NavigationThrottle> devtools_throttle =
540 RenderFrameDevToolsAgentHost::CreateThrottleForNavigation(this);
541 if (devtools_throttle)
542 throttles_.push_back(devtools_throttle.release());
543 }
544
536 } // namespace content 545 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/frame_host/navigation_handle_impl.h ('k') | content/content_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698