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

Side by Side Diff: content/renderer/render_frame_impl.cc

Issue 2655433002: Execute BeforeUnload on subframe browser-initiated navigations (Closed)
Patch Set: Rebase 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/renderer/render_frame_impl.h" 5 #include "content/renderer/render_frame_impl.h"
6 6
7 #include <map> 7 #include <map>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 1641 matching lines...) Expand 10 before | Expand all | Expand 10 after
1652 } 1652 }
1653 1653
1654 void RenderFrameImpl::SetPendingNavigationParams( 1654 void RenderFrameImpl::SetPendingNavigationParams(
1655 std::unique_ptr<NavigationParams> navigation_params) { 1655 std::unique_ptr<NavigationParams> navigation_params) {
1656 pending_navigation_params_ = std::move(navigation_params); 1656 pending_navigation_params_ = std::move(navigation_params);
1657 } 1657 }
1658 1658
1659 void RenderFrameImpl::OnBeforeUnload(bool is_reload) { 1659 void RenderFrameImpl::OnBeforeUnload(bool is_reload) {
1660 TRACE_EVENT1("navigation,rail", "RenderFrameImpl::OnBeforeUnload", 1660 TRACE_EVENT1("navigation,rail", "RenderFrameImpl::OnBeforeUnload",
1661 "id", routing_id_); 1661 "id", routing_id_);
1662 // TODO(creis): Right now, this is only called on the main frame. Make the
1663 // browser process send dispatchBeforeUnloadEvent to every frame that needs
1664 // it.
1665 CHECK(!frame_->parent());
1666
1667 // Save the routing_id, as the RenderFrameImpl can be deleted in 1662 // Save the routing_id, as the RenderFrameImpl can be deleted in
1668 // dispatchBeforeUnloadEvent. See https://crbug.com/666714 for details. 1663 // dispatchBeforeUnloadEvent. See https://crbug.com/666714 for details.
1669 int routing_id = routing_id_; 1664 int routing_id = routing_id_;
1670 1665
1671 base::TimeTicks before_unload_start_time = base::TimeTicks::Now(); 1666 base::TimeTicks before_unload_start_time = base::TimeTicks::Now();
1667
1668 // TODO(clamy): Ensure BeforeUnload is dispatched to all subframes, even when
1669 // --site-per-process is enabled. |dispatchBeforeUnloadEvent| will only
1670 // execute the BeforeUnload event in this frame and local child frames. It
1671 // should also be dispatched to out-of-process child frames.
1672 bool proceed = frame_->dispatchBeforeUnloadEvent(is_reload); 1672 bool proceed = frame_->dispatchBeforeUnloadEvent(is_reload);
1673
1673 base::TimeTicks before_unload_end_time = base::TimeTicks::Now(); 1674 base::TimeTicks before_unload_end_time = base::TimeTicks::Now();
1674 RenderThread::Get()->Send(new FrameHostMsg_BeforeUnload_ACK( 1675 RenderThread::Get()->Send(new FrameHostMsg_BeforeUnload_ACK(
1675 routing_id, proceed, before_unload_start_time, before_unload_end_time)); 1676 routing_id, proceed, before_unload_start_time, before_unload_end_time));
1676 } 1677 }
1677 1678
1678 void RenderFrameImpl::OnSwapOut( 1679 void RenderFrameImpl::OnSwapOut(
1679 int proxy_routing_id, 1680 int proxy_routing_id,
1680 bool is_loading, 1681 bool is_loading,
1681 const FrameReplicationState& replicated_frame_state) { 1682 const FrameReplicationState& replicated_frame_state) {
1682 TRACE_EVENT1("navigation,rail", "RenderFrameImpl::OnSwapOut", 1683 TRACE_EVENT1("navigation,rail", "RenderFrameImpl::OnSwapOut",
(...skipping 5181 matching lines...) Expand 10 before | Expand all | Expand 10 after
6864 // event target. Potentially a Pepper plugin will receive the event. 6865 // event target. Potentially a Pepper plugin will receive the event.
6865 // In order to tell whether a plugin gets the last mouse event and which it 6866 // In order to tell whether a plugin gets the last mouse event and which it
6866 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets 6867 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets
6867 // the event, it will notify us via DidReceiveMouseEvent() and set itself as 6868 // the event, it will notify us via DidReceiveMouseEvent() and set itself as
6868 // |pepper_last_mouse_event_target_|. 6869 // |pepper_last_mouse_event_target_|.
6869 pepper_last_mouse_event_target_ = nullptr; 6870 pepper_last_mouse_event_target_ = nullptr;
6870 #endif 6871 #endif
6871 } 6872 }
6872 6873
6873 } // namespace content 6874 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698