| 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 1660 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1671 if (beforeunload_timeout_) | 1671 if (beforeunload_timeout_) |
| 1672 beforeunload_timeout_->Stop(); | 1672 beforeunload_timeout_->Stop(); |
| 1673 send_before_unload_start_time_ = base::TimeTicks(); | 1673 send_before_unload_start_time_ = base::TimeTicks(); |
| 1674 | 1674 |
| 1675 // PlzNavigate: if the ACK is for a navigation, send it to the Navigator to | 1675 // PlzNavigate: if the ACK is for a navigation, send it to the Navigator to |
| 1676 // have the current navigation stop/proceed. Otherwise, send it to the | 1676 // have the current navigation stop/proceed. Otherwise, send it to the |
| 1677 // RenderFrameHostManager which handles closing. | 1677 // RenderFrameHostManager which handles closing. |
| 1678 if (IsBrowserSideNavigationEnabled() && unload_ack_is_for_navigation_) { | 1678 if (IsBrowserSideNavigationEnabled() && unload_ack_is_for_navigation_) { |
| 1679 // TODO(clamy): see if before_unload_end_time should be transmitted to the | 1679 // TODO(clamy): see if before_unload_end_time should be transmitted to the |
| 1680 // Navigator. | 1680 // Navigator. |
| 1681 frame_tree_node_->navigator()->OnBeforeUnloadACK( | 1681 frame_tree_node_->navigator()->OnBeforeUnloadACK(frame_tree_node_, proceed, |
| 1682 frame_tree_node_, proceed); | 1682 before_unload_end_time); |
| 1683 } else { | 1683 } else { |
| 1684 frame_tree_node_->render_manager()->OnBeforeUnloadACK( | 1684 frame_tree_node_->render_manager()->OnBeforeUnloadACK( |
| 1685 unload_ack_is_for_navigation_, proceed, | 1685 unload_ack_is_for_navigation_, proceed, before_unload_end_time); |
| 1686 before_unload_end_time); | |
| 1687 } | 1686 } |
| 1688 | 1687 |
| 1689 // If canceled, notify the delegate to cancel its pending navigation entry. | 1688 // If canceled, notify the delegate to cancel its pending navigation entry. |
| 1690 if (!proceed) | 1689 if (!proceed) |
| 1691 render_view_host_->GetDelegate()->DidCancelLoading(); | 1690 render_view_host_->GetDelegate()->DidCancelLoading(); |
| 1692 } | 1691 } |
| 1693 | 1692 |
| 1694 bool RenderFrameHostImpl::IsWaitingForUnloadACK() const { | 1693 bool RenderFrameHostImpl::IsWaitingForUnloadACK() const { |
| 1695 return render_view_host_->is_waiting_for_close_ack_ || | 1694 return render_view_host_->is_waiting_for_close_ack_ || |
| 1696 is_waiting_for_swapout_ack_; | 1695 is_waiting_for_swapout_ack_; |
| (...skipping 1273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2970 // (if there was a cross-site "close" request pending when the user clicked | 2969 // (if there was a cross-site "close" request pending when the user clicked |
| 2971 // the close button). We want to keep the "for cross site" flag only if | 2970 // the close button). We want to keep the "for cross site" flag only if |
| 2972 // both the old and the new ones are also for cross site. | 2971 // both the old and the new ones are also for cross site. |
| 2973 unload_ack_is_for_navigation_ = | 2972 unload_ack_is_for_navigation_ = |
| 2974 unload_ack_is_for_navigation_ && for_navigation; | 2973 unload_ack_is_for_navigation_ && for_navigation; |
| 2975 } else { | 2974 } else { |
| 2976 // Start the hang monitor in case the renderer hangs in the beforeunload | 2975 // Start the hang monitor in case the renderer hangs in the beforeunload |
| 2977 // handler. | 2976 // handler. |
| 2978 is_waiting_for_beforeunload_ack_ = true; | 2977 is_waiting_for_beforeunload_ack_ = true; |
| 2979 unload_ack_is_for_navigation_ = for_navigation; | 2978 unload_ack_is_for_navigation_ = for_navigation; |
| 2979 send_before_unload_start_time_ = base::TimeTicks::Now(); |
| 2980 if (render_view_host_->GetDelegate()->IsJavaScriptDialogShowing()) { | 2980 if (render_view_host_->GetDelegate()->IsJavaScriptDialogShowing()) { |
| 2981 // If there is a JavaScript dialog up, don't bother sending the renderer | 2981 // If there is a JavaScript dialog up, don't bother sending the renderer |
| 2982 // the unload event because it is known unresponsive, waiting for the | 2982 // the unload event because it is known unresponsive, waiting for the |
| 2983 // reply from the dialog. | 2983 // reply from the dialog. |
| 2984 SimulateBeforeUnloadAck(); | 2984 SimulateBeforeUnloadAck(); |
| 2985 } else { | 2985 } else { |
| 2986 if (beforeunload_timeout_) { | 2986 if (beforeunload_timeout_) { |
| 2987 beforeunload_timeout_->Start( | 2987 beforeunload_timeout_->Start( |
| 2988 TimeDelta::FromMilliseconds(RenderViewHostImpl::kUnloadTimeoutMS)); | 2988 TimeDelta::FromMilliseconds(RenderViewHostImpl::kUnloadTimeoutMS)); |
| 2989 } | 2989 } |
| 2990 send_before_unload_start_time_ = base::TimeTicks::Now(); | |
| 2991 Send(new FrameMsg_BeforeUnload(routing_id_, is_reload)); | 2990 Send(new FrameMsg_BeforeUnload(routing_id_, is_reload)); |
| 2992 } | 2991 } |
| 2993 } | 2992 } |
| 2994 } | 2993 } |
| 2995 | 2994 |
| 2996 void RenderFrameHostImpl::SimulateBeforeUnloadAck() { | 2995 void RenderFrameHostImpl::SimulateBeforeUnloadAck() { |
| 2997 DCHECK(is_waiting_for_beforeunload_ack_); | 2996 DCHECK(is_waiting_for_beforeunload_ack_); |
| 2998 base::TimeTicks approx_renderer_start_time = send_before_unload_start_time_; | 2997 base::TimeTicks approx_renderer_start_time = send_before_unload_start_time_; |
| 2999 OnBeforeUnloadACK(true, approx_renderer_start_time, base::TimeTicks::Now()); | 2998 OnBeforeUnloadACK(true, approx_renderer_start_time, base::TimeTicks::Now()); |
| 3000 } | 2999 } |
| (...skipping 1019 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4020 } | 4019 } |
| 4021 | 4020 |
| 4022 void RenderFrameHostImpl::ForwardGetInterfaceToRenderFrame( | 4021 void RenderFrameHostImpl::ForwardGetInterfaceToRenderFrame( |
| 4023 const std::string& interface_name, | 4022 const std::string& interface_name, |
| 4024 mojo::ScopedMessagePipeHandle pipe) { | 4023 mojo::ScopedMessagePipeHandle pipe) { |
| 4025 GetRemoteInterfaces()->GetInterface(interface_name, std::move(pipe)); | 4024 GetRemoteInterfaces()->GetInterface(interface_name, std::move(pipe)); |
| 4026 } | 4025 } |
| 4027 #endif | 4026 #endif |
| 4028 | 4027 |
| 4029 } // namespace content | 4028 } // namespace content |
| OLD | NEW |