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

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

Issue 2655433002: Execute BeforeUnload on subframe browser-initiated navigations (Closed)
Patch Set: Execute BeforeUnload on subframe browser-initiated navigations Created 3 years, 11 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 1403 matching lines...) Expand 10 before | Expand all | Expand 10 after
1414 is_waiting_for_swapout_ack_ = true; 1414 is_waiting_for_swapout_ack_ = true;
1415 } 1415 }
1416 1416
1417 void RenderFrameHostImpl::OnBeforeUnloadACK( 1417 void RenderFrameHostImpl::OnBeforeUnloadACK(
1418 bool proceed, 1418 bool proceed,
1419 const base::TimeTicks& renderer_before_unload_start_time, 1419 const base::TimeTicks& renderer_before_unload_start_time,
1420 const base::TimeTicks& renderer_before_unload_end_time) { 1420 const base::TimeTicks& renderer_before_unload_end_time) {
1421 TRACE_EVENT_ASYNC_END1("navigation", "RenderFrameHostImpl BeforeUnload", this, 1421 TRACE_EVENT_ASYNC_END1("navigation", "RenderFrameHostImpl BeforeUnload", this,
1422 "FrameTreeNode id", 1422 "FrameTreeNode id",
1423 frame_tree_node_->frame_tree_node_id()); 1423 frame_tree_node_->frame_tree_node_id());
1424 DCHECK(!GetParent());
1425 // If this renderer navigated while the beforeunload request was in flight, we 1424 // If this renderer navigated while the beforeunload request was in flight, we
1426 // may have cleared this state in OnDidCommitProvisionalLoad, in which case we 1425 // may have cleared this state in OnDidCommitProvisionalLoad, in which case we
1427 // can ignore this message. 1426 // can ignore this message.
1428 // However renderer might also be swapped out but we still want to proceed 1427 // However renderer might also be swapped out but we still want to proceed
1429 // with navigation, otherwise it would block future navigations. This can 1428 // with navigation, otherwise it would block future navigations. This can
1430 // happen when pending cross-site navigation is canceled by a second one just 1429 // happen when pending cross-site navigation is canceled by a second one just
1431 // before OnDidCommitProvisionalLoad while current RVH is waiting for commit 1430 // before OnDidCommitProvisionalLoad while current RVH is waiting for commit
1432 // but second navigation is started from the beginning. 1431 // but second navigation is started from the beginning.
1433 if (!is_waiting_for_beforeunload_ack_) { 1432 if (!is_waiting_for_beforeunload_ack_) {
1434 return; 1433 return;
(...skipping 1095 matching lines...) Expand 10 before | Expand all | Expand 10 after
2530 } 2529 }
2531 } 2530 }
2532 2531
2533 void RenderFrameHostImpl::SimulateBeforeUnloadAck() { 2532 void RenderFrameHostImpl::SimulateBeforeUnloadAck() {
2534 DCHECK(is_waiting_for_beforeunload_ack_); 2533 DCHECK(is_waiting_for_beforeunload_ack_);
2535 base::TimeTicks approx_renderer_start_time = send_before_unload_start_time_; 2534 base::TimeTicks approx_renderer_start_time = send_before_unload_start_time_;
2536 OnBeforeUnloadACK(true, approx_renderer_start_time, base::TimeTicks::Now()); 2535 OnBeforeUnloadACK(true, approx_renderer_start_time, base::TimeTicks::Now());
2537 } 2536 }
2538 2537
2539 bool RenderFrameHostImpl::ShouldDispatchBeforeUnload() { 2538 bool RenderFrameHostImpl::ShouldDispatchBeforeUnload() {
2540 // TODO(creis): Support beforeunload on subframes. 2539 // TODO(clamy): Ensure BeforeUnload is dispatched to all subframes, even when
2541 return !GetParent() && IsRenderFrameLive(); 2540 // --site-per-process is enabled.
Charlie Reis 2017/01/24 21:42:50 I missed out on the discussion-- what's still left
clamy 2017/01/25 14:09:39 I've moved the comment to a more appropriate place
2541 return IsRenderFrameLive();
2542 } 2542 }
2543 2543
2544 void RenderFrameHostImpl::UpdateOpener() { 2544 void RenderFrameHostImpl::UpdateOpener() {
2545 // This frame (the frame whose opener is being updated) might not have had 2545 // This frame (the frame whose opener is being updated) might not have had
2546 // proxies for the new opener chain in its SiteInstance. Make sure they 2546 // proxies for the new opener chain in its SiteInstance. Make sure they
2547 // exist. 2547 // exist.
2548 if (frame_tree_node_->opener()) { 2548 if (frame_tree_node_->opener()) {
2549 frame_tree_node_->opener()->render_manager()->CreateOpenerProxies( 2549 frame_tree_node_->opener()->render_manager()->CreateOpenerProxies(
2550 GetSiteInstance(), frame_tree_node_); 2550 GetSiteInstance(), frame_tree_node_);
2551 } 2551 }
(...skipping 854 matching lines...) Expand 10 before | Expand all | Expand 10 after
3406 // There is no pending NavigationEntry in these cases, so pass 0 as the 3406 // There is no pending NavigationEntry in these cases, so pass 0 as the
3407 // pending_nav_entry_id. If the previous handle was a prematurely aborted 3407 // pending_nav_entry_id. If the previous handle was a prematurely aborted
3408 // navigation loaded via LoadDataWithBaseURL, propagate the entry id. 3408 // navigation loaded via LoadDataWithBaseURL, propagate the entry id.
3409 return NavigationHandleImpl::Create( 3409 return NavigationHandleImpl::Create(
3410 params.url, frame_tree_node_, is_renderer_initiated, 3410 params.url, frame_tree_node_, is_renderer_initiated,
3411 params.was_within_same_page, base::TimeTicks::Now(), 3411 params.was_within_same_page, base::TimeTicks::Now(),
3412 entry_id_for_data_nav, false); // started_from_context_menu 3412 entry_id_for_data_nav, false); // started_from_context_menu
3413 } 3413 }
3414 3414
3415 } // namespace content 3415 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/frame_host/navigator_impl_unittest.cc ('k') | content/renderer/render_frame_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698