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

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

Issue 2735183003: PlzNavigate: stop navigations when opening a document for write (Closed)
Patch Set: Rebase + fixed compilation error 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/render_frame_host_impl.h" 5 #include "content/browser/frame_host/render_frame_host_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 766 matching lines...) Expand 10 before | Expand all | Expand 10 after
777 IPC_MESSAGE_HANDLER(FrameHostMsg_UpdateToUniqueOrigin, 777 IPC_MESSAGE_HANDLER(FrameHostMsg_UpdateToUniqueOrigin,
778 OnUpdateToUniqueOrigin) 778 OnUpdateToUniqueOrigin)
779 IPC_MESSAGE_HANDLER(FrameHostMsg_DidChangeSandboxFlags, 779 IPC_MESSAGE_HANDLER(FrameHostMsg_DidChangeSandboxFlags,
780 OnDidChangeSandboxFlags) 780 OnDidChangeSandboxFlags)
781 IPC_MESSAGE_HANDLER(FrameHostMsg_DidChangeFrameOwnerProperties, 781 IPC_MESSAGE_HANDLER(FrameHostMsg_DidChangeFrameOwnerProperties,
782 OnDidChangeFrameOwnerProperties) 782 OnDidChangeFrameOwnerProperties)
783 IPC_MESSAGE_HANDLER(FrameHostMsg_UpdateTitle, OnUpdateTitle) 783 IPC_MESSAGE_HANDLER(FrameHostMsg_UpdateTitle, OnUpdateTitle)
784 IPC_MESSAGE_HANDLER(FrameHostMsg_UpdateEncoding, OnUpdateEncoding) 784 IPC_MESSAGE_HANDLER(FrameHostMsg_UpdateEncoding, OnUpdateEncoding)
785 IPC_MESSAGE_HANDLER(FrameHostMsg_BeginNavigation, 785 IPC_MESSAGE_HANDLER(FrameHostMsg_BeginNavigation,
786 OnBeginNavigation) 786 OnBeginNavigation)
787 IPC_MESSAGE_HANDLER(FrameHostMsg_AbortNavigation, OnAbortNavigation)
787 IPC_MESSAGE_HANDLER(FrameHostMsg_DispatchLoad, OnDispatchLoad) 788 IPC_MESSAGE_HANDLER(FrameHostMsg_DispatchLoad, OnDispatchLoad)
788 IPC_MESSAGE_HANDLER(FrameHostMsg_TextSurroundingSelectionResponse, 789 IPC_MESSAGE_HANDLER(FrameHostMsg_TextSurroundingSelectionResponse,
789 OnTextSurroundingSelectionResponse) 790 OnTextSurroundingSelectionResponse)
790 IPC_MESSAGE_HANDLER(AccessibilityHostMsg_Events, OnAccessibilityEvents) 791 IPC_MESSAGE_HANDLER(AccessibilityHostMsg_Events, OnAccessibilityEvents)
791 IPC_MESSAGE_HANDLER(AccessibilityHostMsg_LocationChanges, 792 IPC_MESSAGE_HANDLER(AccessibilityHostMsg_LocationChanges,
792 OnAccessibilityLocationChanges) 793 OnAccessibilityLocationChanges)
793 IPC_MESSAGE_HANDLER(AccessibilityHostMsg_FindInPageResult, 794 IPC_MESSAGE_HANDLER(AccessibilityHostMsg_FindInPageResult,
794 OnAccessibilityFindInPageResult) 795 OnAccessibilityFindInPageResult)
795 IPC_MESSAGE_HANDLER(AccessibilityHostMsg_ChildFrameHitTestResult, 796 IPC_MESSAGE_HANDLER(AccessibilityHostMsg_ChildFrameHitTestResult,
796 OnAccessibilityChildFrameHitTestResult) 797 OnAccessibilityChildFrameHitTestResult)
(...skipping 1240 matching lines...) Expand 10 before | Expand all | Expand 10 after
2037 if (waiting_for_init_) { 2038 if (waiting_for_init_) {
2038 pendinging_navigate_ = base::MakeUnique<PendingNavigation>( 2039 pendinging_navigate_ = base::MakeUnique<PendingNavigation>(
2039 validated_params, validated_begin_params); 2040 validated_params, validated_begin_params);
2040 return; 2041 return;
2041 } 2042 }
2042 2043
2043 frame_tree_node()->navigator()->OnBeginNavigation( 2044 frame_tree_node()->navigator()->OnBeginNavigation(
2044 frame_tree_node(), validated_params, validated_begin_params); 2045 frame_tree_node(), validated_params, validated_begin_params);
2045 } 2046 }
2046 2047
2048 void RenderFrameHostImpl::OnAbortNavigation() {
2049 if (!IsBrowserSideNavigationEnabled()) {
2050 NOTREACHED();
2051 return;
2052 }
2053 if (!is_active())
2054 return;
2055 frame_tree_node()->navigator()->OnAbortNavigation(frame_tree_node());
2056 }
2057
2047 void RenderFrameHostImpl::OnDispatchLoad() { 2058 void RenderFrameHostImpl::OnDispatchLoad() {
2048 CHECK(SiteIsolationPolicy::AreCrossProcessFramesPossible()); 2059 CHECK(SiteIsolationPolicy::AreCrossProcessFramesPossible());
2049 2060
2050 // Don't forward the load event if this RFH is pending deletion. This can 2061 // Don't forward the load event if this RFH is pending deletion. This can
2051 // happen in a race where this RenderFrameHost finishes loading just after 2062 // happen in a race where this RenderFrameHost finishes loading just after
2052 // the frame navigates away. See https://crbug.com/626802. 2063 // the frame navigates away. See https://crbug.com/626802.
2053 if (!is_active()) 2064 if (!is_active())
2054 return; 2065 return;
2055 2066
2056 // Only frames with an out-of-process parent frame should be sending this 2067 // Only frames with an out-of-process parent frame should be sending this
(...skipping 577 matching lines...) Expand 10 before | Expand all | Expand 10 after
2634 Send(new FrameMsg_Stop(routing_id_)); 2645 Send(new FrameMsg_Stop(routing_id_));
2635 } 2646 }
2636 2647
2637 void RenderFrameHostImpl::DispatchBeforeUnload(bool for_navigation, 2648 void RenderFrameHostImpl::DispatchBeforeUnload(bool for_navigation,
2638 bool is_reload) { 2649 bool is_reload) {
2639 DCHECK(for_navigation || !is_reload); 2650 DCHECK(for_navigation || !is_reload);
2640 2651
2641 if (IsBrowserSideNavigationEnabled() && !for_navigation) { 2652 if (IsBrowserSideNavigationEnabled() && !for_navigation) {
2642 // Cancel any pending navigations, to avoid their navigation commit/fail 2653 // Cancel any pending navigations, to avoid their navigation commit/fail
2643 // event from wiping out the is_waiting_for_beforeunload_ack_ state. 2654 // event from wiping out the is_waiting_for_beforeunload_ack_ state.
2644 frame_tree_node_->ResetNavigationRequest(false); 2655 frame_tree_node_->ResetNavigationRequest(false, true);
2645 } 2656 }
2646 2657
2647 // TODO(creis): Support beforeunload on subframes. For now just pretend that 2658 // TODO(creis): Support beforeunload on subframes. For now just pretend that
2648 // the handler ran and allowed the navigation to proceed. 2659 // the handler ran and allowed the navigation to proceed.
2649 if (!ShouldDispatchBeforeUnload()) { 2660 if (!ShouldDispatchBeforeUnload()) {
2650 DCHECK(!(IsBrowserSideNavigationEnabled() && for_navigation)); 2661 DCHECK(!(IsBrowserSideNavigationEnabled() && for_navigation));
2651 frame_tree_node_->render_manager()->OnBeforeUnloadACK( 2662 frame_tree_node_->render_manager()->OnBeforeUnloadACK(
2652 for_navigation, true, base::TimeTicks::Now()); 2663 for_navigation, true, base::TimeTicks::Now());
2653 return; 2664 return;
2654 } 2665 }
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
2845 ResetWaitingState(); 2856 ResetWaitingState();
2846 2857
2847 Send(new FrameMsg_FailedNavigation(routing_id_, common_params, request_params, 2858 Send(new FrameMsg_FailedNavigation(routing_id_, common_params, request_params,
2848 has_stale_copy_in_cache, error_code)); 2859 has_stale_copy_in_cache, error_code));
2849 2860
2850 RenderFrameDevToolsAgentHost::OnFailedNavigation( 2861 RenderFrameDevToolsAgentHost::OnFailedNavigation(
2851 this, common_params, begin_params, static_cast<net::Error>(error_code)); 2862 this, common_params, begin_params, static_cast<net::Error>(error_code));
2852 2863
2853 // An error page is expected to commit, hence why is_loading_ is set to true. 2864 // An error page is expected to commit, hence why is_loading_ is set to true.
2854 is_loading_ = true; 2865 is_loading_ = true;
2855 frame_tree_node_->ResetNavigationRequest(true); 2866 frame_tree_node_->ResetNavigationRequest(true, true);
2856 } 2867 }
2857 2868
2858 void RenderFrameHostImpl::SetUpMojoIfNeeded() { 2869 void RenderFrameHostImpl::SetUpMojoIfNeeded() {
2859 if (interface_registry_.get()) 2870 if (interface_registry_.get())
2860 return; 2871 return;
2861 2872
2862 interface_registry_ = base::MakeUnique<service_manager::InterfaceRegistry>( 2873 interface_registry_ = base::MakeUnique<service_manager::InterfaceRegistry>(
2863 mojom::kNavigation_FrameSpec); 2874 mojom::kNavigation_FrameSpec);
2864 2875
2865 ServiceManagerConnection* service_manager_connection = 2876 ServiceManagerConnection* service_manager_connection =
(...skipping 756 matching lines...) Expand 10 before | Expand all | Expand 10 after
3622 service_manager::mojom::InterfaceProviderPtr provider; 3633 service_manager::mojom::InterfaceProviderPtr provider;
3623 BindInterfaceRegistryForRenderFrameHost(mojo::MakeRequest(&provider), this); 3634 BindInterfaceRegistryForRenderFrameHost(mojo::MakeRequest(&provider), this);
3624 java_interfaces_.reset(new service_manager::InterfaceProvider); 3635 java_interfaces_.reset(new service_manager::InterfaceProvider);
3625 java_interfaces_->Bind(std::move(provider)); 3636 java_interfaces_->Bind(std::move(provider));
3626 } 3637 }
3627 return java_interfaces_.get(); 3638 return java_interfaces_.get();
3628 } 3639 }
3629 #endif 3640 #endif
3630 3641
3631 } // namespace content 3642 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698