Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 "base/debug/dump_without_crashing.h" | 7 #include "base/debug/dump_without_crashing.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "content/browser/appcache/appcache_navigation_handle.h" | 9 #include "content/browser/appcache/appcache_navigation_handle.h" |
| 10 #include "content/browser/appcache/appcache_service_impl.h" | 10 #include "content/browser/appcache/appcache_service_impl.h" |
| (...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 427 if (method_ == "POST") | 427 if (method_ == "POST") |
| 428 resource_request_body_ = resource_request_body; | 428 resource_request_body_ = resource_request_body; |
| 429 sanitized_referrer_ = sanitized_referrer; | 429 sanitized_referrer_ = sanitized_referrer; |
| 430 has_user_gesture_ = has_user_gesture; | 430 has_user_gesture_ = has_user_gesture; |
| 431 transition_ = transition; | 431 transition_ = transition; |
| 432 is_external_protocol_ = is_external_protocol; | 432 is_external_protocol_ = is_external_protocol; |
| 433 request_context_type_ = request_context_type; | 433 request_context_type_ = request_context_type; |
| 434 state_ = WILL_SEND_REQUEST; | 434 state_ = WILL_SEND_REQUEST; |
| 435 complete_callback_ = callback; | 435 complete_callback_ = callback; |
| 436 | 436 |
| 437 LOG(INFO) << "Will start request"; | |
|
alexmos
2016/12/28 00:25:59
Don't forget to remove the LOGs, here and below
davidsac (gone - try alexmos)
2017/01/06 00:44:57
Done.
| |
| 438 if (isURLBlocked()) { | |
| 439 RunCompleteCallback(NavigationThrottle::CANCEL); | |
| 440 return; | |
| 441 } | |
| 442 | |
| 437 RegisterNavigationThrottles(); | 443 RegisterNavigationThrottles(); |
| 438 | 444 |
| 439 if (IsBrowserSideNavigationEnabled()) | 445 if (IsBrowserSideNavigationEnabled()) |
| 440 navigation_ui_data_ = GetDelegate()->GetNavigationUIData(this); | 446 navigation_ui_data_ = GetDelegate()->GetNavigationUIData(this); |
| 441 | 447 |
| 442 // Notify each throttle of the request. | 448 // Notify each throttle of the request. |
| 443 NavigationThrottle::ThrottleCheckResult result = CheckWillStartRequest(); | 449 NavigationThrottle::ThrottleCheckResult result = CheckWillStartRequest(); |
| 444 | 450 |
| 445 // If the navigation is not deferred, run the callback. | 451 // If the navigation is not deferred, run the callback. |
| 446 if (result != NavigationThrottle::DEFER) | 452 if (result != NavigationThrottle::DEFER) |
| 447 RunCompleteCallback(result); | 453 RunCompleteCallback(result); |
| 448 } | 454 } |
| 449 | 455 |
| 456 bool NavigationHandleImpl::isURLBlocked() { | |
| 457 // return false; | |
|
alexmos
2016/12/28 00:25:59
Not needed
davidsac (gone - try alexmos)
2017/01/06 00:44:57
Done.
| |
| 458 if (url_.SchemeIs("about")) | |
|
alexmos
2016/12/28 00:25:59
Let's keep the comment about excluding about: from
davidsac (gone - try alexmos)
2017/01/06 00:44:57
Done.
| |
| 459 return false; | |
| 460 | |
| 461 // We allow one level of self-reference because some sites depend on that, | |
| 462 // but we don't allow more than one. | |
| 463 bool foundSelfReference = false; | |
|
alexmos
2016/12/28 00:25:59
nit: rename this according to Chromium style, i.e.
davidsac (gone - try alexmos)
2017/01/06 00:44:57
Done.
| |
| 464 for (const FrameTreeNode* node = frame_tree_node_; node; | |
|
alexmos
2016/12/28 00:25:59
I think there might be a bug here, in that this sh
davidsac (gone - try alexmos)
2017/01/06 00:44:57
Done.
| |
| 465 node = node->parent()) { | |
| 466 if (node->current_url() == url_) { | |
|
alexmos
2016/12/28 00:25:59
This also doesn't look the same as the old check.
davidsac (gone - try alexmos)
2017/01/06 00:44:57
Done.
| |
| 467 if (foundSelfReference) { | |
| 468 LOG(INFO) << "Blocked URL: " << url_; | |
| 469 return true; | |
| 470 } | |
| 471 foundSelfReference = true; | |
| 472 } | |
| 473 } | |
| 474 return false; | |
| 475 } | |
| 476 | |
| 450 void NavigationHandleImpl::WillRedirectRequest( | 477 void NavigationHandleImpl::WillRedirectRequest( |
| 451 const GURL& new_url, | 478 const GURL& new_url, |
| 452 const std::string& new_method, | 479 const std::string& new_method, |
| 453 const GURL& new_referrer_url, | 480 const GURL& new_referrer_url, |
| 454 bool new_is_external_protocol, | 481 bool new_is_external_protocol, |
| 455 scoped_refptr<net::HttpResponseHeaders> response_headers, | 482 scoped_refptr<net::HttpResponseHeaders> response_headers, |
| 456 net::HttpResponseInfo::ConnectionInfo connection_info, | 483 net::HttpResponseInfo::ConnectionInfo connection_info, |
| 457 const ThrottleChecksFinishedCallback& callback) { | 484 const ThrottleChecksFinishedCallback& callback) { |
| 458 // Update the navigation parameters. | 485 // Update the navigation parameters. |
| 459 url_ = new_url; | 486 url_ = new_url; |
| 460 method_ = new_method; | 487 method_ = new_method; |
| 461 sanitized_referrer_.url = new_referrer_url; | 488 sanitized_referrer_.url = new_referrer_url; |
| 462 sanitized_referrer_ = Referrer::SanitizeForRequest(url_, sanitized_referrer_); | 489 sanitized_referrer_ = Referrer::SanitizeForRequest(url_, sanitized_referrer_); |
| 463 is_external_protocol_ = new_is_external_protocol; | 490 is_external_protocol_ = new_is_external_protocol; |
| 464 response_headers_ = response_headers; | 491 response_headers_ = response_headers; |
| 465 connection_info_ = connection_info; | 492 connection_info_ = connection_info; |
| 466 was_redirected_ = true; | 493 was_redirected_ = true; |
| 467 redirect_chain_.push_back(new_url); | 494 redirect_chain_.push_back(new_url); |
| 468 if (new_method != "POST") | 495 if (new_method != "POST") |
| 469 resource_request_body_ = nullptr; | 496 resource_request_body_ = nullptr; |
| 470 | 497 |
| 471 state_ = WILL_REDIRECT_REQUEST; | 498 state_ = WILL_REDIRECT_REQUEST; |
| 472 complete_callback_ = callback; | 499 complete_callback_ = callback; |
| 473 | 500 |
| 501 LOG(INFO) << "Will redirect request"; | |
| 502 if (isURLBlocked()) { | |
| 503 RunCompleteCallback(NavigationThrottle::CANCEL); | |
|
alexmos
2016/12/28 00:25:59
Looking at how CheckWill(Start|Redirect)Request wo
davidsac (gone - try alexmos)
2017/01/06 00:44:57
Done.
| |
| 504 return; | |
| 505 } | |
| 506 | |
| 474 // Notify each throttle of the request. | 507 // Notify each throttle of the request. |
| 475 NavigationThrottle::ThrottleCheckResult result = CheckWillRedirectRequest(); | 508 NavigationThrottle::ThrottleCheckResult result = CheckWillRedirectRequest(); |
| 476 | 509 |
| 477 // If the navigation is not deferred, run the callback. | 510 // If the navigation is not deferred, run the callback. |
| 478 if (result != NavigationThrottle::DEFER) | 511 if (result != NavigationThrottle::DEFER) |
| 479 RunCompleteCallback(result); | 512 RunCompleteCallback(result); |
| 480 } | 513 } |
| 481 | 514 |
| 482 void NavigationHandleImpl::WillProcessResponse( | 515 void NavigationHandleImpl::WillProcessResponse( |
| 483 RenderFrameHostImpl* render_frame_host, | 516 RenderFrameHostImpl* render_frame_host, |
| (...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 781 throttles_to_register.push_back(std::move(clear_site_data_throttle)); | 814 throttles_to_register.push_back(std::move(clear_site_data_throttle)); |
| 782 | 815 |
| 783 if (throttles_to_register.size() > 0) { | 816 if (throttles_to_register.size() > 0) { |
| 784 throttles_.insert(throttles_.begin(), throttles_to_register.begin(), | 817 throttles_.insert(throttles_.begin(), throttles_to_register.begin(), |
| 785 throttles_to_register.end()); | 818 throttles_to_register.end()); |
| 786 throttles_to_register.weak_clear(); | 819 throttles_to_register.weak_clear(); |
| 787 } | 820 } |
| 788 } | 821 } |
| 789 | 822 |
| 790 } // namespace content | 823 } // namespace content |
| OLD | NEW |