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

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: Removed frameID 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 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
327 RegisterNavigationThrottles();
328
329 // Notify each throttle of the request.
330 NavigationThrottle::ThrottleCheckResult result = CheckWillStartRequest();
331
332 // If the navigation is not deferred, run the callback.
333 if (result != NavigationThrottle::DEFER)
334 RunCompleteCallback(result);
335 }
336
337 void NavigationHandleImpl::RegisterNavigationThrottles() {
326 // Register the navigation throttles. The ScopedVector returned by 338 // Register the navigation throttles. The ScopedVector returned by
327 // GetNavigationThrottles is not assigned to throttles_ directly because it 339 // GetNavigationThrottles is not assigned to throttles_ directly because it
328 // would overwrite any throttle previously added with 340 // would overwrite any throttle previously added with
329 // RegisterThrottleForTesting. 341 // RegisterThrottleForTesting.
330 ScopedVector<NavigationThrottle> throttles_to_register = 342 ScopedVector<NavigationThrottle> throttles_to_register =
331 GetContentClient()->browser()->CreateThrottlesForNavigation(this); 343 GetContentClient()->browser()->CreateThrottlesForNavigation(this);
332 if (throttles_to_register.size() > 0) { 344 if (throttles_to_register.size() > 0) {
333 throttles_.insert(throttles_.end(), throttles_to_register.begin(), 345 throttles_.insert(throttles_.end(), throttles_to_register.begin(),
334 throttles_to_register.end()); 346 throttles_to_register.end());
335 throttles_to_register.weak_clear(); 347 throttles_to_register.weak_clear();
336 } 348 }
337 349 std::unique_ptr<NavigationThrottle> devtools_throttle =
338 // Notify each throttle of the request. 350 RenderFrameDevToolsAgentHost::GetThrottleForNavigation(this);
339 NavigationThrottle::ThrottleCheckResult result = CheckWillStartRequest(); 351 if (devtools_throttle)
340 352 throttles_.push_back(devtools_throttle.release());
341 // If the navigation is not deferred, run the callback.
342 if (result != NavigationThrottle::DEFER)
343 RunCompleteCallback(result);
344 } 353 }
345 354
346 void NavigationHandleImpl::WillRedirectRequest( 355 void NavigationHandleImpl::WillRedirectRequest(
347 const GURL& new_url, 356 const GURL& new_url,
348 const std::string& new_method, 357 const std::string& new_method,
349 const GURL& new_referrer_url, 358 const GURL& new_referrer_url,
350 bool new_is_external_protocol, 359 bool new_is_external_protocol,
351 scoped_refptr<net::HttpResponseHeaders> response_headers, 360 scoped_refptr<net::HttpResponseHeaders> response_headers,
352 const ThrottleChecksFinishedCallback& callback) { 361 const ThrottleChecksFinishedCallback& callback) {
353 // Update the navigation parameters. 362 // Update the navigation parameters.
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
527 complete_callback_.Reset(); 536 complete_callback_.Reset();
528 537
529 if (!callback.is_null()) 538 if (!callback.is_null())
530 callback.Run(result); 539 callback.Run(result);
531 540
532 // No code after running the callback, as it might have resulted in our 541 // No code after running the callback, as it might have resulted in our
533 // destruction. 542 // destruction.
534 } 543 }
535 544
536 } // namespace content 545 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698