| 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/frame_tree.h" | 15 #include "content/browser/frame_host/frame_tree.h" |
| 15 #include "content/browser/frame_host/frame_tree_node.h" | 16 #include "content/browser/frame_host/frame_tree_node.h" |
| 16 #include "content/browser/frame_host/navigation_controller_impl.h" | 17 #include "content/browser/frame_host/navigation_controller_impl.h" |
| 17 #include "content/browser/frame_host/navigation_handle_impl.h" | 18 #include "content/browser/frame_host/navigation_handle_impl.h" |
| 18 #include "content/browser/frame_host/navigation_request_info.h" | 19 #include "content/browser/frame_host/navigation_request_info.h" |
| 19 #include "content/browser/frame_host/navigator.h" | 20 #include "content/browser/frame_host/navigator.h" |
| 20 #include "content/browser/frame_host/navigator_impl.h" | 21 #include "content/browser/frame_host/navigator_impl.h" |
| 21 #include "content/browser/loader/navigation_url_loader.h" | 22 #include "content/browser/loader/navigation_url_loader.h" |
| 22 #include "content/browser/renderer_host/render_process_host_impl.h" | 23 #include "content/browser/renderer_host/render_process_host_impl.h" |
| 23 #include "content/browser/service_worker/service_worker_context_wrapper.h" | 24 #include "content/browser/service_worker/service_worker_context_wrapper.h" |
| (...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 540 base::Closure(), | 541 base::Closure(), |
| 541 base::Bind(&NavigationRequest::OnWillProcessResponseChecksComplete, | 542 base::Bind(&NavigationRequest::OnWillProcessResponseChecksComplete, |
| 542 base::Unretained(this))); | 543 base::Unretained(this))); |
| 543 } | 544 } |
| 544 | 545 |
| 545 void NavigationRequest::OnRequestFailed(bool has_stale_copy_in_cache, | 546 void NavigationRequest::OnRequestFailed(bool has_stale_copy_in_cache, |
| 546 int net_error) { | 547 int net_error) { |
| 547 DCHECK(state_ == STARTED || state_ == RESPONSE_STARTED); | 548 DCHECK(state_ == STARTED || state_ == RESPONSE_STARTED); |
| 548 state_ = FAILED; | 549 state_ = FAILED; |
| 549 navigation_handle_->set_net_error_code(static_cast<net::Error>(net_error)); | 550 navigation_handle_->set_net_error_code(static_cast<net::Error>(net_error)); |
| 550 frame_tree_node_->navigator()->FailedNavigation( | 551 |
| 551 frame_tree_node_, has_stale_copy_in_cache, net_error); | 552 // With PlzNavigate, debug URLs will give a failed navigation because the |
| 553 // WebUI backend won't find a handler for them. They will be processed in the |
| 554 // renderer, however do not discard the pending entry so that the URL bar |
| 555 // shows them correctly. |
| 556 if (!IsRendererDebugURL(common_params_.url)) { |
| 557 frame_tree_node_->navigator()->DiscardPendingEntryIfNeeded( |
| 558 navigation_handle_.get()); |
| 559 } |
| 560 |
| 561 // If the request was canceled by the user do not show an error page. |
| 562 if (net_error == net::ERR_ABORTED) { |
| 563 frame_tree_node_->ResetNavigationRequest(false); |
| 564 return; |
| 565 } |
| 566 |
| 567 // Select an appropriate renderer to show the error page. |
| 568 RenderFrameHostImpl* render_frame_host = |
| 569 frame_tree_node_->render_manager()->GetFrameHostForNavigation(*this); |
| 570 NavigatorImpl::CheckWebUIRendererDoesNotDisplayNormalURL(render_frame_host, |
| 571 common_params_.url); |
| 572 |
| 573 TransferNavigationHandleOwnership(render_frame_host); |
| 574 render_frame_host->navigation_handle()->ReadyToCommitNavigation( |
| 575 render_frame_host); |
| 576 render_frame_host->FailedNavigation(common_params_, request_params_, |
| 577 has_stale_copy_in_cache, net_error); |
| 552 } | 578 } |
| 553 | 579 |
| 554 void NavigationRequest::OnRequestStarted(base::TimeTicks timestamp) { | 580 void NavigationRequest::OnRequestStarted(base::TimeTicks timestamp) { |
| 555 if (frame_tree_node_->IsMainFrame()) { | 581 if (frame_tree_node_->IsMainFrame()) { |
| 556 TRACE_EVENT_ASYNC_END_WITH_TIMESTAMP0( | 582 TRACE_EVENT_ASYNC_END_WITH_TIMESTAMP0( |
| 557 "navigation", "Navigation timeToNetworkStack", navigation_handle_.get(), | 583 "navigation", "Navigation timeToNetworkStack", navigation_handle_.get(), |
| 558 timestamp); | 584 timestamp); |
| 559 } | 585 } |
| 560 | 586 |
| 561 frame_tree_node_->navigator()->LogResourceRequestTime(timestamp, | 587 frame_tree_node_->navigator()->LogResourceRequestTime(timestamp, |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 732 DCHECK_EQ(request_params_.has_user_gesture, begin_params_.has_user_gesture); | 758 DCHECK_EQ(request_params_.has_user_gesture, begin_params_.has_user_gesture); |
| 733 | 759 |
| 734 render_frame_host->CommitNavigation(response_.get(), std::move(body_), | 760 render_frame_host->CommitNavigation(response_.get(), std::move(body_), |
| 735 common_params_, request_params_, | 761 common_params_, request_params_, |
| 736 is_view_source_); | 762 is_view_source_); |
| 737 | 763 |
| 738 frame_tree_node_->ResetNavigationRequest(true); | 764 frame_tree_node_->ResetNavigationRequest(true); |
| 739 } | 765 } |
| 740 | 766 |
| 741 } // namespace content | 767 } // namespace content |
| OLD | NEW |