| OLD | NEW |
| 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 1649 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1660 if (beforeunload_timeout_) | 1660 if (beforeunload_timeout_) |
| 1661 beforeunload_timeout_->Stop(); | 1661 beforeunload_timeout_->Stop(); |
| 1662 send_before_unload_start_time_ = base::TimeTicks(); | 1662 send_before_unload_start_time_ = base::TimeTicks(); |
| 1663 | 1663 |
| 1664 // PlzNavigate: if the ACK is for a navigation, send it to the Navigator to | 1664 // PlzNavigate: if the ACK is for a navigation, send it to the Navigator to |
| 1665 // have the current navigation stop/proceed. Otherwise, send it to the | 1665 // have the current navigation stop/proceed. Otherwise, send it to the |
| 1666 // RenderFrameHostManager which handles closing. | 1666 // RenderFrameHostManager which handles closing. |
| 1667 if (IsBrowserSideNavigationEnabled() && unload_ack_is_for_navigation_) { | 1667 if (IsBrowserSideNavigationEnabled() && unload_ack_is_for_navigation_) { |
| 1668 // TODO(clamy): see if before_unload_end_time should be transmitted to the | 1668 // TODO(clamy): see if before_unload_end_time should be transmitted to the |
| 1669 // Navigator. | 1669 // Navigator. |
| 1670 frame_tree_node_->navigator()->OnBeforeUnloadACK( | 1670 frame_tree_node_->navigator()->OnBeforeUnloadACK(frame_tree_node_, proceed, |
| 1671 frame_tree_node_, proceed); | 1671 before_unload_end_time); |
| 1672 } else { | 1672 } else { |
| 1673 frame_tree_node_->render_manager()->OnBeforeUnloadACK( | 1673 frame_tree_node_->render_manager()->OnBeforeUnloadACK( |
| 1674 unload_ack_is_for_navigation_, proceed, | 1674 unload_ack_is_for_navigation_, proceed, before_unload_end_time); |
| 1675 before_unload_end_time); | |
| 1676 } | 1675 } |
| 1677 | 1676 |
| 1678 // If canceled, notify the delegate to cancel its pending navigation entry. | 1677 // If canceled, notify the delegate to cancel its pending navigation entry. |
| 1679 if (!proceed) | 1678 if (!proceed) |
| 1680 render_view_host_->GetDelegate()->DidCancelLoading(); | 1679 render_view_host_->GetDelegate()->DidCancelLoading(); |
| 1681 } | 1680 } |
| 1682 | 1681 |
| 1683 bool RenderFrameHostImpl::IsWaitingForUnloadACK() const { | 1682 bool RenderFrameHostImpl::IsWaitingForUnloadACK() const { |
| 1684 return render_view_host_->is_waiting_for_close_ack_ || | 1683 return render_view_host_->is_waiting_for_close_ack_ || |
| 1685 is_waiting_for_swapout_ack_; | 1684 is_waiting_for_swapout_ack_; |
| (...skipping 1274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2960 // (if there was a cross-site "close" request pending when the user clicked | 2959 // (if there was a cross-site "close" request pending when the user clicked |
| 2961 // the close button). We want to keep the "for cross site" flag only if | 2960 // the close button). We want to keep the "for cross site" flag only if |
| 2962 // both the old and the new ones are also for cross site. | 2961 // both the old and the new ones are also for cross site. |
| 2963 unload_ack_is_for_navigation_ = | 2962 unload_ack_is_for_navigation_ = |
| 2964 unload_ack_is_for_navigation_ && for_navigation; | 2963 unload_ack_is_for_navigation_ && for_navigation; |
| 2965 } else { | 2964 } else { |
| 2966 // Start the hang monitor in case the renderer hangs in the beforeunload | 2965 // Start the hang monitor in case the renderer hangs in the beforeunload |
| 2967 // handler. | 2966 // handler. |
| 2968 is_waiting_for_beforeunload_ack_ = true; | 2967 is_waiting_for_beforeunload_ack_ = true; |
| 2969 unload_ack_is_for_navigation_ = for_navigation; | 2968 unload_ack_is_for_navigation_ = for_navigation; |
| 2969 send_before_unload_start_time_ = base::TimeTicks::Now(); |
| 2970 if (render_view_host_->GetDelegate()->IsJavaScriptDialogShowing()) { | 2970 if (render_view_host_->GetDelegate()->IsJavaScriptDialogShowing()) { |
| 2971 // If there is a JavaScript dialog up, don't bother sending the renderer | 2971 // If there is a JavaScript dialog up, don't bother sending the renderer |
| 2972 // the unload event because it is known unresponsive, waiting for the | 2972 // the unload event because it is known unresponsive, waiting for the |
| 2973 // reply from the dialog. | 2973 // reply from the dialog. |
| 2974 SimulateBeforeUnloadAck(); | 2974 SimulateBeforeUnloadAck(); |
| 2975 } else { | 2975 } else { |
| 2976 if (beforeunload_timeout_) { | 2976 if (beforeunload_timeout_) { |
| 2977 beforeunload_timeout_->Start( | 2977 beforeunload_timeout_->Start( |
| 2978 TimeDelta::FromMilliseconds(RenderViewHostImpl::kUnloadTimeoutMS)); | 2978 TimeDelta::FromMilliseconds(RenderViewHostImpl::kUnloadTimeoutMS)); |
| 2979 } | 2979 } |
| 2980 send_before_unload_start_time_ = base::TimeTicks::Now(); | |
| 2981 Send(new FrameMsg_BeforeUnload(routing_id_, is_reload)); | 2980 Send(new FrameMsg_BeforeUnload(routing_id_, is_reload)); |
| 2982 } | 2981 } |
| 2983 } | 2982 } |
| 2984 } | 2983 } |
| 2985 | 2984 |
| 2986 void RenderFrameHostImpl::SimulateBeforeUnloadAck() { | 2985 void RenderFrameHostImpl::SimulateBeforeUnloadAck() { |
| 2987 DCHECK(is_waiting_for_beforeunload_ack_); | 2986 DCHECK(is_waiting_for_beforeunload_ack_); |
| 2988 base::TimeTicks approx_renderer_start_time = send_before_unload_start_time_; | 2987 base::TimeTicks approx_renderer_start_time = send_before_unload_start_time_; |
| 2989 OnBeforeUnloadACK(true, approx_renderer_start_time, base::TimeTicks::Now()); | 2988 OnBeforeUnloadACK(true, approx_renderer_start_time, base::TimeTicks::Now()); |
| 2990 } | 2989 } |
| (...skipping 993 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3984 } | 3983 } |
| 3985 | 3984 |
| 3986 void RenderFrameHostImpl::ForwardGetInterfaceToRenderFrame( | 3985 void RenderFrameHostImpl::ForwardGetInterfaceToRenderFrame( |
| 3987 const std::string& interface_name, | 3986 const std::string& interface_name, |
| 3988 mojo::ScopedMessagePipeHandle pipe) { | 3987 mojo::ScopedMessagePipeHandle pipe) { |
| 3989 GetRemoteInterfaces()->GetInterface(interface_name, std::move(pipe)); | 3988 GetRemoteInterfaces()->GetInterface(interface_name, std::move(pipe)); |
| 3990 } | 3989 } |
| 3991 #endif | 3990 #endif |
| 3992 | 3991 |
| 3993 } // namespace content | 3992 } // namespace content |
| OLD | NEW |