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" |
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
466 | 466 |
467 // For non browser initiated navigations we need to check if the source has | 467 // For non browser initiated navigations we need to check if the source has |
468 // access to the URL. We always allow browser initiated requests. | 468 // access to the URL. We always allow browser initiated requests. |
469 // TODO(clamy): Kill the renderer if FilterURL fails? | 469 // TODO(clamy): Kill the renderer if FilterURL fails? |
470 GURL url = common_params_.url; | 470 GURL url = common_params_.url; |
471 if (!browser_initiated_ && source_site_instance()) { | 471 if (!browser_initiated_ && source_site_instance()) { |
472 source_site_instance()->GetProcess()->FilterURL(false, &url); | 472 source_site_instance()->GetProcess()->FilterURL(false, &url); |
473 // FilterURL sets the URL to about:blank if the CSP checks prevent the | 473 // FilterURL sets the URL to about:blank if the CSP checks prevent the |
474 // renderer from accessing it. | 474 // renderer from accessing it. |
475 if ((url == url::kAboutBlankURL) && (url != common_params_.url)) { | 475 if ((url == url::kAboutBlankURL) && (url != common_params_.url)) { |
476 frame_tree_node_->ResetNavigationRequest(false); | 476 frame_tree_node_->ResetNavigationRequest(false, true); |
477 return; | 477 return; |
478 } | 478 } |
479 } | 479 } |
480 | 480 |
481 // It's safe to use base::Unretained because this NavigationRequest owns the | 481 // It's safe to use base::Unretained because this NavigationRequest owns the |
482 // NavigationHandle where the callback will be stored. | 482 // NavigationHandle where the callback will be stored. |
483 // TODO(clamy): pass the real value for |is_external_protocol| if needed. | 483 // TODO(clamy): pass the real value for |is_external_protocol| if needed. |
484 navigation_handle_->WillRedirectRequest( | 484 navigation_handle_->WillRedirectRequest( |
485 common_params_.url, common_params_.method, common_params_.referrer.url, | 485 common_params_.url, common_params_.method, common_params_.referrer.url, |
486 false, response->head.headers, response->head.connection_info, | 486 false, response->head.headers, response->head.connection_info, |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
545 render_frame_host != frame_tree_node_->current_frame_host()) { | 545 render_frame_host != frame_tree_node_->current_frame_host()) { |
546 // Reset the source location information if the navigation will not commit | 546 // Reset the source location information if the navigation will not commit |
547 // in the current renderer process. This information originated in another | 547 // in the current renderer process. This information originated in another |
548 // process (the current one), it should not be transferred to the new one. | 548 // process (the current one), it should not be transferred to the new one. |
549 common_params_.source_location.reset(); | 549 common_params_.source_location.reset(); |
550 | 550 |
551 // Allow the embedder to cancel the cross-process commit if needed. | 551 // Allow the embedder to cancel the cross-process commit if needed. |
552 // TODO(clamy): Rename ShouldTransferNavigation once PlzNavigate ships. | 552 // TODO(clamy): Rename ShouldTransferNavigation once PlzNavigate ships. |
553 if (!frame_tree_node_->navigator()->GetDelegate()->ShouldTransferNavigation( | 553 if (!frame_tree_node_->navigator()->GetDelegate()->ShouldTransferNavigation( |
554 frame_tree_node_->IsMainFrame())) { | 554 frame_tree_node_->IsMainFrame())) { |
555 frame_tree_node_->ResetNavigationRequest(false); | 555 frame_tree_node_->ResetNavigationRequest(false, true); |
556 return; | 556 return; |
557 } | 557 } |
558 } | 558 } |
559 | 559 |
560 if (navigation_data) | 560 if (navigation_data) |
561 navigation_handle_->set_navigation_data(std::move(navigation_data)); | 561 navigation_handle_->set_navigation_data(std::move(navigation_data)); |
562 | 562 |
563 // Store the response and the StreamHandle until checks have been processed. | 563 // Store the response and the StreamHandle until checks have been processed. |
564 response_ = response; | 564 response_ = response; |
565 body_ = std::move(body); | 565 body_ = std::move(body); |
(...skipping 18 matching lines...) Expand all Loading... |
584 // WebUI backend won't find a handler for them. They will be processed in the | 584 // WebUI backend won't find a handler for them. They will be processed in the |
585 // renderer, however do not discard the pending entry so that the URL bar | 585 // renderer, however do not discard the pending entry so that the URL bar |
586 // shows them correctly. | 586 // shows them correctly. |
587 if (!IsRendererDebugURL(common_params_.url)) { | 587 if (!IsRendererDebugURL(common_params_.url)) { |
588 frame_tree_node_->navigator()->DiscardPendingEntryIfNeeded( | 588 frame_tree_node_->navigator()->DiscardPendingEntryIfNeeded( |
589 navigation_handle_.get()); | 589 navigation_handle_.get()); |
590 } | 590 } |
591 | 591 |
592 // If the request was canceled by the user do not show an error page. | 592 // If the request was canceled by the user do not show an error page. |
593 if (net_error == net::ERR_ABORTED) { | 593 if (net_error == net::ERR_ABORTED) { |
594 frame_tree_node_->ResetNavigationRequest(false); | 594 frame_tree_node_->ResetNavigationRequest(false, true); |
595 return; | 595 return; |
596 } | 596 } |
597 | 597 |
598 // There are two types of error pages that need to be handled differently. | 598 // There are two types of error pages that need to be handled differently. |
599 // * Error pages resulting from blocking the request, because the original | 599 // * Error pages resulting from blocking the request, because the original |
600 // document wasn't even allowed to make the request. In such case, | 600 // document wasn't even allowed to make the request. In such case, |
601 // the error pages should be committed in the process of the original | 601 // the error pages should be committed in the process of the original |
602 // document, to avoid creating a process for the destination. | 602 // document, to avoid creating a process for the destination. |
603 // * Error pages resulting from either network outage (no network, DNS | 603 // * Error pages resulting from either network outage (no network, DNS |
604 // error, etc) or similar cases, where the user can reasonably expect that | 604 // error, etc) or similar cases, where the user can reasonably expect that |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
819 frame_tree_node_->render_manager()->speculative_frame_host()); | 819 frame_tree_node_->render_manager()->speculative_frame_host()); |
820 | 820 |
821 TransferNavigationHandleOwnership(render_frame_host); | 821 TransferNavigationHandleOwnership(render_frame_host); |
822 | 822 |
823 DCHECK_EQ(request_params_.has_user_gesture, begin_params_.has_user_gesture); | 823 DCHECK_EQ(request_params_.has_user_gesture, begin_params_.has_user_gesture); |
824 | 824 |
825 render_frame_host->CommitNavigation(response_.get(), std::move(body_), | 825 render_frame_host->CommitNavigation(response_.get(), std::move(body_), |
826 common_params_, request_params_, | 826 common_params_, request_params_, |
827 is_view_source_); | 827 is_view_source_); |
828 | 828 |
829 frame_tree_node_->ResetNavigationRequest(true); | 829 frame_tree_node_->ResetNavigationRequest(true, true); |
830 } | 830 } |
831 | 831 |
832 } // namespace content | 832 } // namespace content |
OLD | NEW |