OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_request.h" | 5 #include "content/browser/frame_host/navigation_request.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
10 #include "content/browser/appcache/appcache_navigation_handle.h" | 10 #include "content/browser/appcache/appcache_navigation_handle.h" |
11 #include "content/browser/appcache/chrome_appcache_service.h" | 11 #include "content/browser/appcache/chrome_appcache_service.h" |
12 #include "content/browser/child_process_security_policy_impl.h" | 12 #include "content/browser/child_process_security_policy_impl.h" |
13 #include "content/browser/devtools/render_frame_devtools_agent_host.h" | 13 #include "content/browser/devtools/render_frame_devtools_agent_host.h" |
14 #include "content/browser/frame_host/debug_urls.h" | 14 #include "content/browser/frame_host/debug_urls.h" |
15 #include "content/browser/frame_host/frame_tree.h" | 15 #include "content/browser/frame_host/frame_tree.h" |
16 #include "content/browser/frame_host/frame_tree_node.h" | 16 #include "content/browser/frame_host/frame_tree_node.h" |
17 #include "content/browser/frame_host/navigation_controller_impl.h" | 17 #include "content/browser/frame_host/navigation_controller_impl.h" |
18 #include "content/browser/frame_host/navigation_handle_impl.h" | |
19 #include "content/browser/frame_host/navigation_request_info.h" | 18 #include "content/browser/frame_host/navigation_request_info.h" |
20 #include "content/browser/frame_host/navigator.h" | 19 #include "content/browser/frame_host/navigator.h" |
21 #include "content/browser/frame_host/navigator_impl.h" | 20 #include "content/browser/frame_host/navigator_impl.h" |
22 #include "content/browser/loader/navigation_url_loader.h" | 21 #include "content/browser/loader/navigation_url_loader.h" |
23 #include "content/browser/renderer_host/render_process_host_impl.h" | 22 #include "content/browser/renderer_host/render_process_host_impl.h" |
24 #include "content/browser/service_worker/service_worker_context_wrapper.h" | 23 #include "content/browser/service_worker/service_worker_context_wrapper.h" |
25 #include "content/browser/service_worker/service_worker_navigation_handle.h" | 24 #include "content/browser/service_worker/service_worker_navigation_handle.h" |
26 #include "content/browser/site_instance_impl.h" | 25 #include "content/browser/site_instance_impl.h" |
27 #include "content/common/appcache_interfaces.h" | 26 #include "content/common/appcache_interfaces.h" |
28 #include "content/common/resource_request_body_impl.h" | 27 #include "content/common/resource_request_body_impl.h" |
(...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
597 | 596 |
598 frame_tree_node_->navigator()->LogResourceRequestTime(timestamp, | 597 frame_tree_node_->navigator()->LogResourceRequestTime(timestamp, |
599 common_params_.url); | 598 common_params_.url); |
600 } | 599 } |
601 | 600 |
602 void NavigationRequest::OnStartChecksComplete( | 601 void NavigationRequest::OnStartChecksComplete( |
603 NavigationThrottle::ThrottleCheckResult result) { | 602 NavigationThrottle::ThrottleCheckResult result) { |
604 DCHECK(result != NavigationThrottle::DEFER); | 603 DCHECK(result != NavigationThrottle::DEFER); |
605 DCHECK(result != NavigationThrottle::BLOCK_RESPONSE); | 604 DCHECK(result != NavigationThrottle::BLOCK_RESPONSE); |
606 | 605 |
607 if (on_start_checks_complete_closure_) | 606 if (on_checks_complete_callback_) |
608 on_start_checks_complete_closure_.Run(); | 607 on_checks_complete_callback_.Run(result); |
609 | 608 |
610 // Abort the request if needed. This will destroy the NavigationRequest. | 609 // Abort the request if needed. This will destroy the NavigationRequest. |
611 if (result == NavigationThrottle::CANCEL_AND_IGNORE || | 610 if (result == NavigationThrottle::CANCEL_AND_IGNORE || |
612 result == NavigationThrottle::CANCEL) { | 611 result == NavigationThrottle::CANCEL) { |
613 // TODO(clamy): distinguish between CANCEL and CANCEL_AND_IGNORE. | 612 // TODO(clamy): distinguish between CANCEL and CANCEL_AND_IGNORE. |
614 OnRequestFailed(false, net::ERR_ABORTED); | 613 OnRequestFailed(false, net::ERR_ABORTED); |
615 | 614 |
616 // DO NOT ADD CODE after this. The previous call to OnRequestFailed has | 615 // DO NOT ADD CODE after this. The previous call to OnRequestFailed has |
617 // destroyed the NavigationRequest. | 616 // destroyed the NavigationRequest. |
618 return; | 617 return; |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
697 std::move(navigation_ui_data), | 696 std::move(navigation_ui_data), |
698 navigation_handle_->service_worker_handle(), | 697 navigation_handle_->service_worker_handle(), |
699 navigation_handle_->appcache_handle(), this); | 698 navigation_handle_->appcache_handle(), this); |
700 } | 699 } |
701 | 700 |
702 void NavigationRequest::OnRedirectChecksComplete( | 701 void NavigationRequest::OnRedirectChecksComplete( |
703 NavigationThrottle::ThrottleCheckResult result) { | 702 NavigationThrottle::ThrottleCheckResult result) { |
704 DCHECK(result != NavigationThrottle::DEFER); | 703 DCHECK(result != NavigationThrottle::DEFER); |
705 DCHECK(result != NavigationThrottle::BLOCK_RESPONSE); | 704 DCHECK(result != NavigationThrottle::BLOCK_RESPONSE); |
706 | 705 |
| 706 if (on_checks_complete_callback_) |
| 707 on_checks_complete_callback_.Run(result); |
707 // Abort the request if needed. This will destroy the NavigationRequest. | 708 // Abort the request if needed. This will destroy the NavigationRequest. |
708 if (result == NavigationThrottle::CANCEL_AND_IGNORE || | 709 if (result == NavigationThrottle::CANCEL_AND_IGNORE || |
709 result == NavigationThrottle::CANCEL) { | 710 result == NavigationThrottle::CANCEL) { |
710 // TODO(clamy): distinguish between CANCEL and CANCEL_AND_IGNORE. | 711 // TODO(clamy): distinguish between CANCEL and CANCEL_AND_IGNORE. |
711 OnRequestFailed(false, net::ERR_ABORTED); | 712 OnRequestFailed(false, net::ERR_ABORTED); |
712 | 713 |
713 // DO NOT ADD CODE after this. The previous call to OnRequestFailed has | 714 // DO NOT ADD CODE after this. The previous call to OnRequestFailed has |
714 // destroyed the NavigationRequest. | 715 // destroyed the NavigationRequest. |
715 return; | 716 return; |
716 } | 717 } |
717 | 718 |
718 loader_->FollowRedirect(); | 719 loader_->FollowRedirect(); |
719 } | 720 } |
720 | 721 |
721 void NavigationRequest::OnWillProcessResponseChecksComplete( | 722 void NavigationRequest::OnWillProcessResponseChecksComplete( |
722 NavigationThrottle::ThrottleCheckResult result) { | 723 NavigationThrottle::ThrottleCheckResult result) { |
723 DCHECK(result != NavigationThrottle::DEFER); | 724 DCHECK(result != NavigationThrottle::DEFER); |
724 | 725 |
| 726 if (on_checks_complete_callback_) |
| 727 on_checks_complete_callback_.Run(result); |
| 728 |
725 // Abort the request if needed. This includes requests that were blocked by | 729 // Abort the request if needed. This includes requests that were blocked by |
726 // NavigationThrottles and requests that should not commit (e.g. downloads, | 730 // NavigationThrottles and requests that should not commit (e.g. downloads, |
727 // 204/205s). This will destroy the NavigationRequest. | 731 // 204/205s). This will destroy the NavigationRequest. |
728 if (result == NavigationThrottle::CANCEL_AND_IGNORE || | 732 if (result == NavigationThrottle::CANCEL_AND_IGNORE || |
729 result == NavigationThrottle::CANCEL || !response_should_be_rendered_) { | 733 result == NavigationThrottle::CANCEL || !response_should_be_rendered_) { |
730 // TODO(clamy): distinguish between CANCEL and CANCEL_AND_IGNORE. | 734 // TODO(clamy): distinguish between CANCEL and CANCEL_AND_IGNORE. |
731 OnRequestFailed(false, net::ERR_ABORTED); | 735 OnRequestFailed(false, net::ERR_ABORTED); |
732 | 736 |
733 // DO NOT ADD CODE after this. The previous call to OnRequestFailed has | 737 // DO NOT ADD CODE after this. The previous call to OnRequestFailed has |
734 // destroyed the NavigationRequest. | 738 // destroyed the NavigationRequest. |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
769 DCHECK_EQ(request_params_.has_user_gesture, begin_params_.has_user_gesture); | 773 DCHECK_EQ(request_params_.has_user_gesture, begin_params_.has_user_gesture); |
770 | 774 |
771 render_frame_host->CommitNavigation(response_.get(), std::move(body_), | 775 render_frame_host->CommitNavigation(response_.get(), std::move(body_), |
772 common_params_, request_params_, | 776 common_params_, request_params_, |
773 is_view_source_); | 777 is_view_source_); |
774 | 778 |
775 frame_tree_node_->ResetNavigationRequest(true); | 779 frame_tree_node_->ResetNavigationRequest(true); |
776 } | 780 } |
777 | 781 |
778 } // namespace content | 782 } // namespace content |
OLD | NEW |