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 "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 1660 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1671 params.user_gesture); | 1671 params.user_gesture); |
1672 } | 1672 } |
1673 | 1673 |
1674 void RenderFrameHostImpl::Stop() { | 1674 void RenderFrameHostImpl::Stop() { |
1675 Send(new FrameMsg_Stop(routing_id_)); | 1675 Send(new FrameMsg_Stop(routing_id_)); |
1676 } | 1676 } |
1677 | 1677 |
1678 void RenderFrameHostImpl::DispatchBeforeUnload(bool for_navigation) { | 1678 void RenderFrameHostImpl::DispatchBeforeUnload(bool for_navigation) { |
1679 // TODO(creis): Support beforeunload on subframes. For now just pretend that | 1679 // TODO(creis): Support beforeunload on subframes. For now just pretend that |
1680 // the handler ran and allowed the navigation to proceed. | 1680 // the handler ran and allowed the navigation to proceed. |
1681 if (GetParent() || !IsRenderFrameLive()) { | 1681 if (!ShouldDispatchBeforeUnload()) { |
1682 // We don't have a live renderer, so just skip running beforeunload. | 1682 // There's no live renderer or this is a subframe, so just skip running |
1683 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 1683 // BeforeUnload. |
1684 switches::kEnableBrowserSideNavigation)) { | 1684 DCHECK(!base::CommandLine::ForCurrentProcess()->HasSwitch( |
1685 frame_tree_node_->navigator()->OnBeforeUnloadACK( | 1685 switches::kEnableBrowserSideNavigation)); |
clamy
2015/06/10 12:30:27
The check should be:
!base::CommandLine::ForCurren
carlosk
2015/06/10 13:15:05
Done. I missed that part from the previous comment
| |
1686 frame_tree_node_, true); | 1686 frame_tree_node_->render_manager()->OnBeforeUnloadACK( |
1687 } else { | 1687 for_navigation, true, base::TimeTicks::Now()); |
1688 frame_tree_node_->render_manager()->OnBeforeUnloadACK( | |
1689 for_navigation, true, base::TimeTicks::Now()); | |
1690 } | |
1691 return; | 1688 return; |
1692 } | 1689 } |
1693 TRACE_EVENT_ASYNC_BEGIN0( | 1690 TRACE_EVENT_ASYNC_BEGIN0( |
1694 "navigation", "RenderFrameHostImpl::BeforeUnload", this); | 1691 "navigation", "RenderFrameHostImpl::BeforeUnload", this); |
1695 | 1692 |
1696 // This may be called more than once (if the user clicks the tab close button | 1693 // This may be called more than once (if the user clicks the tab close button |
1697 // several times, or if she clicks the tab close button then the browser close | 1694 // several times, or if she clicks the tab close button then the browser close |
1698 // button), and we only send the message once. | 1695 // button), and we only send the message once. |
1699 if (is_waiting_for_beforeunload_ack_) { | 1696 if (is_waiting_for_beforeunload_ack_) { |
1700 // Some of our close messages could be for the tab, others for cross-site | 1697 // Some of our close messages could be for the tab, others for cross-site |
(...skipping 12 matching lines...) Expand all Loading... | |
1713 // Increment the in-flight event count, to ensure that input events won't | 1710 // Increment the in-flight event count, to ensure that input events won't |
1714 // cancel the timeout timer. | 1711 // cancel the timeout timer. |
1715 render_view_host_->increment_in_flight_event_count(); | 1712 render_view_host_->increment_in_flight_event_count(); |
1716 render_view_host_->StartHangMonitorTimeout( | 1713 render_view_host_->StartHangMonitorTimeout( |
1717 TimeDelta::FromMilliseconds(RenderViewHostImpl::kUnloadTimeoutMS)); | 1714 TimeDelta::FromMilliseconds(RenderViewHostImpl::kUnloadTimeoutMS)); |
1718 send_before_unload_start_time_ = base::TimeTicks::Now(); | 1715 send_before_unload_start_time_ = base::TimeTicks::Now(); |
1719 Send(new FrameMsg_BeforeUnload(routing_id_)); | 1716 Send(new FrameMsg_BeforeUnload(routing_id_)); |
1720 } | 1717 } |
1721 } | 1718 } |
1722 | 1719 |
1720 bool RenderFrameHostImpl::ShouldDispatchBeforeUnload() { | |
1721 // TODO(creis): Support beforeunload on subframes. For now just pretend that | |
clamy
2015/06/10 12:30:27
Remove the sentence starting with "For now..."
carlosk
2015/06/10 13:15:05
Done.
| |
1722 // the handler ran and allowed the navigation to proceed. | |
1723 return !GetParent() && IsRenderFrameLive(); | |
1724 } | |
1725 | |
1723 void RenderFrameHostImpl::DisownOpener() { | 1726 void RenderFrameHostImpl::DisownOpener() { |
1724 Send(new FrameMsg_DisownOpener(GetRoutingID())); | 1727 Send(new FrameMsg_DisownOpener(GetRoutingID())); |
1725 } | 1728 } |
1726 | 1729 |
1727 void RenderFrameHostImpl::ExtendSelectionAndDelete(size_t before, | 1730 void RenderFrameHostImpl::ExtendSelectionAndDelete(size_t before, |
1728 size_t after) { | 1731 size_t after) { |
1729 Send(new InputMsg_ExtendSelectionAndDelete(routing_id_, before, after)); | 1732 Send(new InputMsg_ExtendSelectionAndDelete(routing_id_, before, after)); |
1730 } | 1733 } |
1731 | 1734 |
1732 void RenderFrameHostImpl::JavaScriptDialogClosed( | 1735 void RenderFrameHostImpl::JavaScriptDialogClosed( |
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2068 // We may be returning to an existing NavigationEntry that had been granted | 2071 // We may be returning to an existing NavigationEntry that had been granted |
2069 // file access. If this is a different process, we will need to grant the | 2072 // file access. If this is a different process, we will need to grant the |
2070 // access again. The files listed in the page state are validated when they | 2073 // access again. The files listed in the page state are validated when they |
2071 // are received from the renderer to prevent abuse. | 2074 // are received from the renderer to prevent abuse. |
2072 if (request_params.page_state.IsValid()) { | 2075 if (request_params.page_state.IsValid()) { |
2073 render_view_host_->GrantFileAccessFromPageState(request_params.page_state); | 2076 render_view_host_->GrantFileAccessFromPageState(request_params.page_state); |
2074 } | 2077 } |
2075 } | 2078 } |
2076 | 2079 |
2077 } // namespace content | 2080 } // namespace content |
OLD | NEW |