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

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

Issue 903043002: Skip BeforeUnload on cross-site navigations when there are no handlers Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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 "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/containers/hash_tables.h" 9 #include "base/containers/hash_tables.h"
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
(...skipping 902 matching lines...) Expand 10 before | Expand all | Expand 10 after
913 913
914 // There may be no proxy if there are no active views in the process. 914 // There may be no proxy if there are no active views in the process.
915 int proxy_routing_id = MSG_ROUTING_NONE; 915 int proxy_routing_id = MSG_ROUTING_NONE;
916 FrameReplicationState replication_state; 916 FrameReplicationState replication_state;
917 if (proxy) { 917 if (proxy) {
918 set_render_frame_proxy_host(proxy); 918 set_render_frame_proxy_host(proxy);
919 proxy_routing_id = proxy->GetRoutingID(); 919 proxy_routing_id = proxy->GetRoutingID();
920 replication_state = proxy->frame_tree_node()->current_replication_state(); 920 replication_state = proxy->frame_tree_node()->current_replication_state();
921 } 921 }
922 922
923 // TODO(clamy): if the frame has no unload handlers and |proxy| is null, it
924 // could be discarded immediately, improving performance. However that means
925 // losing the last sync of PageState.
923 if (IsRenderFrameLive()) { 926 if (IsRenderFrameLive()) {
924 Send(new FrameMsg_SwapOut(routing_id_, proxy_routing_id, is_loading, 927 Send(new FrameMsg_SwapOut(routing_id_, proxy_routing_id, is_loading,
925 replication_state)); 928 replication_state));
926 } 929 }
927 930
928 if (!GetParent()) 931 if (!GetParent())
929 delegate_->SwappedOut(this); 932 delegate_->SwappedOut(this);
930 } 933 }
931 934
932 void RenderFrameHostImpl::OnBeforeUnloadACK( 935 void RenderFrameHostImpl::OnBeforeUnloadACK(
(...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after
1544 this, validated_url, source_site_instance, params.referrer, 1547 this, validated_url, source_site_instance, params.referrer,
1545 params.disposition, params.should_replace_current_entry, 1548 params.disposition, params.should_replace_current_entry,
1546 params.user_gesture); 1549 params.user_gesture);
1547 } 1550 }
1548 1551
1549 void RenderFrameHostImpl::Stop() { 1552 void RenderFrameHostImpl::Stop() {
1550 Send(new FrameMsg_Stop(routing_id_)); 1553 Send(new FrameMsg_Stop(routing_id_));
1551 } 1554 }
1552 1555
1553 void RenderFrameHostImpl::DispatchBeforeUnload(bool for_navigation) { 1556 void RenderFrameHostImpl::DispatchBeforeUnload(bool for_navigation) {
1554 // TODO(creis): Support beforeunload on subframes. For now just pretend that 1557 // Skip running beforeUnload if:
1558 // - the renderer is not live.
1559 // - the frame is a subframe.
1560 // - this is a cross-site navigation and the current frame has no
1561 // beforeUnload handler registered.
1562 // TODO(creis): Support beforeUnload on subframes. For now just pretend that
1555 // the handler ran and allowed the navigation to proceed. 1563 // the handler ran and allowed the navigation to proceed.
1556 if (GetParent() || !IsRenderFrameLive()) { 1564 // TODO(clamy): Skip beforeUnload when closing a frame with no registered
1557 // We don't have a live renderer, so just skip running beforeunload. 1565 // beforeUnload handlers.
clamy 2015/02/16 17:43:53 We currently only skip waiting for beforeUnload in
1566 if (GetParent() || !IsRenderFrameLive() ||
1567 (!has_beforeunload_handlers_ && for_navigation)) {
1558 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 1568 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
1559 switches::kEnableBrowserSideNavigation)) { 1569 switches::kEnableBrowserSideNavigation)) {
1560 frame_tree_node_->navigator()->OnBeforeUnloadACK( 1570 frame_tree_node_->navigator()->OnBeforeUnloadACK(
1561 frame_tree_node_, true); 1571 frame_tree_node_, true);
1562 } else { 1572 } else {
1563 frame_tree_node_->render_manager()->OnBeforeUnloadACK( 1573 frame_tree_node_->render_manager()->OnBeforeUnloadACK(
1564 for_navigation, true, base::TimeTicks::Now()); 1574 for_navigation, true, base::TimeTicks::Now());
1565 } 1575 }
1566 return; 1576 return;
1567 } 1577 }
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
1886 void RenderFrameHostImpl::DidUseGeolocationPermission() { 1896 void RenderFrameHostImpl::DidUseGeolocationPermission() {
1887 RenderFrameHost* top_frame = frame_tree_node()->frame_tree()->GetMainFrame(); 1897 RenderFrameHost* top_frame = frame_tree_node()->frame_tree()->GetMainFrame();
1888 GetContentClient()->browser()->RegisterPermissionUsage( 1898 GetContentClient()->browser()->RegisterPermissionUsage(
1889 PERMISSION_GEOLOCATION, 1899 PERMISSION_GEOLOCATION,
1890 delegate_->GetAsWebContents(), 1900 delegate_->GetAsWebContents(),
1891 GetLastCommittedURL().GetOrigin(), 1901 GetLastCommittedURL().GetOrigin(),
1892 top_frame->GetLastCommittedURL().GetOrigin()); 1902 top_frame->GetLastCommittedURL().GetOrigin());
1893 } 1903 }
1894 1904
1895 } // namespace content 1905 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698