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

Side by Side Diff: content/browser/frame_host/navigation_request.cc

Issue 2735183003: PlzNavigate: stop navigations when opening a document for write (Closed)
Patch Set: Addressed commemts Created 3 years, 9 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 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 462 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 473
474 // For non browser initiated navigations we need to check if the source has 474 // For non browser initiated navigations we need to check if the source has
475 // access to the URL. We always allow browser initiated requests. 475 // access to the URL. We always allow browser initiated requests.
476 // TODO(clamy): Kill the renderer if FilterURL fails? 476 // TODO(clamy): Kill the renderer if FilterURL fails?
477 GURL url = common_params_.url; 477 GURL url = common_params_.url;
478 if (!browser_initiated_ && source_site_instance()) { 478 if (!browser_initiated_ && source_site_instance()) {
479 source_site_instance()->GetProcess()->FilterURL(false, &url); 479 source_site_instance()->GetProcess()->FilterURL(false, &url);
480 // FilterURL sets the URL to about:blank if the CSP checks prevent the 480 // FilterURL sets the URL to about:blank if the CSP checks prevent the
481 // renderer from accessing it. 481 // renderer from accessing it.
482 if ((url == url::kAboutBlankURL) && (url != common_params_.url)) { 482 if ((url == url::kAboutBlankURL) && (url != common_params_.url)) {
483 frame_tree_node_->ResetNavigationRequest(false); 483 frame_tree_node_->ResetNavigationRequest(false, true);
484 return; 484 return;
485 } 485 }
486 } 486 }
487 487
488 // It's safe to use base::Unretained because this NavigationRequest owns the 488 // It's safe to use base::Unretained because this NavigationRequest owns the
489 // NavigationHandle where the callback will be stored. 489 // NavigationHandle where the callback will be stored.
490 // TODO(clamy): pass the real value for |is_external_protocol| if needed. 490 // TODO(clamy): pass the real value for |is_external_protocol| if needed.
491 navigation_handle_->WillRedirectRequest( 491 navigation_handle_->WillRedirectRequest(
492 common_params_.url, common_params_.method, common_params_.referrer.url, 492 common_params_.url, common_params_.method, common_params_.referrer.url,
493 false, response->head.headers, response->head.connection_info, 493 false, response->head.headers, response->head.connection_info,
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
552 render_frame_host != frame_tree_node_->current_frame_host()) { 552 render_frame_host != frame_tree_node_->current_frame_host()) {
553 // Reset the source location information if the navigation will not commit 553 // Reset the source location information if the navigation will not commit
554 // in the current renderer process. This information originated in another 554 // in the current renderer process. This information originated in another
555 // process (the current one), it should not be transferred to the new one. 555 // process (the current one), it should not be transferred to the new one.
556 common_params_.source_location.reset(); 556 common_params_.source_location.reset();
557 557
558 // Allow the embedder to cancel the cross-process commit if needed. 558 // Allow the embedder to cancel the cross-process commit if needed.
559 // TODO(clamy): Rename ShouldTransferNavigation once PlzNavigate ships. 559 // TODO(clamy): Rename ShouldTransferNavigation once PlzNavigate ships.
560 if (!frame_tree_node_->navigator()->GetDelegate()->ShouldTransferNavigation( 560 if (!frame_tree_node_->navigator()->GetDelegate()->ShouldTransferNavigation(
561 frame_tree_node_->IsMainFrame())) { 561 frame_tree_node_->IsMainFrame())) {
562 frame_tree_node_->ResetNavigationRequest(false); 562 frame_tree_node_->ResetNavigationRequest(false, true);
563 return; 563 return;
564 } 564 }
565 } 565 }
566 566
567 if (navigation_data) 567 if (navigation_data)
568 navigation_handle_->set_navigation_data(std::move(navigation_data)); 568 navigation_handle_->set_navigation_data(std::move(navigation_data));
569 569
570 // Store the response and the StreamHandle until checks have been processed. 570 // Store the response and the StreamHandle until checks have been processed.
571 response_ = response; 571 response_ = response;
572 body_ = std::move(body); 572 body_ = std::move(body);
(...skipping 18 matching lines...) Expand all
591 // WebUI backend won't find a handler for them. They will be processed in the 591 // WebUI backend won't find a handler for them. They will be processed in the
592 // renderer, however do not discard the pending entry so that the URL bar 592 // renderer, however do not discard the pending entry so that the URL bar
593 // shows them correctly. 593 // shows them correctly.
594 if (!IsRendererDebugURL(common_params_.url)) { 594 if (!IsRendererDebugURL(common_params_.url)) {
595 frame_tree_node_->navigator()->DiscardPendingEntryIfNeeded( 595 frame_tree_node_->navigator()->DiscardPendingEntryIfNeeded(
596 navigation_handle_.get()); 596 navigation_handle_.get());
597 } 597 }
598 598
599 // If the request was canceled by the user do not show an error page. 599 // If the request was canceled by the user do not show an error page.
600 if (net_error == net::ERR_ABORTED) { 600 if (net_error == net::ERR_ABORTED) {
601 frame_tree_node_->ResetNavigationRequest(false); 601 frame_tree_node_->ResetNavigationRequest(false, true);
602 return; 602 return;
603 } 603 }
604 604
605 // There are two types of error pages that need to be handled differently. 605 // There are two types of error pages that need to be handled differently.
606 // * Error pages resulting from blocking the request, because the original 606 // * Error pages resulting from blocking the request, because the original
607 // document wasn't even allowed to make the request. In such case, 607 // document wasn't even allowed to make the request. In such case,
608 // the error pages should be committed in the process of the original 608 // the error pages should be committed in the process of the original
609 // document, to avoid creating a process for the destination. 609 // document, to avoid creating a process for the destination.
610 // * Error pages resulting from either network outage (no network, DNS 610 // * Error pages resulting from either network outage (no network, DNS
611 // error, etc) or similar cases, where the user can reasonably expect that 611 // error, etc) or similar cases, where the user can reasonably expect that
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
826 frame_tree_node_->render_manager()->speculative_frame_host()); 826 frame_tree_node_->render_manager()->speculative_frame_host());
827 827
828 TransferNavigationHandleOwnership(render_frame_host); 828 TransferNavigationHandleOwnership(render_frame_host);
829 829
830 DCHECK_EQ(request_params_.has_user_gesture, begin_params_.has_user_gesture); 830 DCHECK_EQ(request_params_.has_user_gesture, begin_params_.has_user_gesture);
831 831
832 render_frame_host->CommitNavigation(response_.get(), std::move(body_), 832 render_frame_host->CommitNavigation(response_.get(), std::move(body_),
833 common_params_, request_params_, 833 common_params_, request_params_,
834 is_view_source_); 834 is_view_source_);
835 835
836 frame_tree_node_->ResetNavigationRequest(true); 836 frame_tree_node_->ResetNavigationRequest(true, true);
837 } 837 }
838 838
839 } // namespace content 839 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/frame_host/navigation_controller_impl_unittest.cc ('k') | content/browser/frame_host/navigator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698