| 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/containers/hash_tables.h" | 8 #include "base/containers/hash_tables.h" |
| 9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| (...skipping 1113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1124 } | 1124 } |
| 1125 | 1125 |
| 1126 if (!GetParent()) | 1126 if (!GetParent()) |
| 1127 delegate_->SwappedOut(this); | 1127 delegate_->SwappedOut(this); |
| 1128 } | 1128 } |
| 1129 | 1129 |
| 1130 void RenderFrameHostImpl::OnBeforeUnloadACK( | 1130 void RenderFrameHostImpl::OnBeforeUnloadACK( |
| 1131 bool proceed, | 1131 bool proceed, |
| 1132 const base::TimeTicks& renderer_before_unload_start_time, | 1132 const base::TimeTicks& renderer_before_unload_start_time, |
| 1133 const base::TimeTicks& renderer_before_unload_end_time) { | 1133 const base::TimeTicks& renderer_before_unload_end_time) { |
| 1134 TRACE_EVENT_ASYNC_END0( | 1134 TRACE_EVENT_ASYNC_END1("navigation", "RenderFrameHostImpl BeforeUnload", this, |
| 1135 "navigation", "RenderFrameHostImpl::BeforeUnload", this); | 1135 "FrameTreeNode id", |
| 1136 frame_tree_node_->frame_tree_node_id()); |
| 1136 DCHECK(!GetParent()); | 1137 DCHECK(!GetParent()); |
| 1137 // If this renderer navigated while the beforeunload request was in flight, we | 1138 // If this renderer navigated while the beforeunload request was in flight, we |
| 1138 // may have cleared this state in OnDidCommitProvisionalLoad, in which case we | 1139 // may have cleared this state in OnDidCommitProvisionalLoad, in which case we |
| 1139 // can ignore this message. | 1140 // can ignore this message. |
| 1140 // However renderer might also be swapped out but we still want to proceed | 1141 // However renderer might also be swapped out but we still want to proceed |
| 1141 // with navigation, otherwise it would block future navigations. This can | 1142 // with navigation, otherwise it would block future navigations. This can |
| 1142 // happen when pending cross-site navigation is canceled by a second one just | 1143 // happen when pending cross-site navigation is canceled by a second one just |
| 1143 // before OnDidCommitProvisionalLoad while current RVH is waiting for commit | 1144 // before OnDidCommitProvisionalLoad while current RVH is waiting for commit |
| 1144 // but second navigation is started from the beginning. | 1145 // but second navigation is started from the beginning. |
| 1145 if (!is_waiting_for_beforeunload_ack_) { | 1146 if (!is_waiting_for_beforeunload_ack_) { |
| (...skipping 768 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1914 | 1915 |
| 1915 void RenderFrameHostImpl::DispatchBeforeUnload(bool for_navigation) { | 1916 void RenderFrameHostImpl::DispatchBeforeUnload(bool for_navigation) { |
| 1916 // TODO(creis): Support beforeunload on subframes. For now just pretend that | 1917 // TODO(creis): Support beforeunload on subframes. For now just pretend that |
| 1917 // the handler ran and allowed the navigation to proceed. | 1918 // the handler ran and allowed the navigation to proceed. |
| 1918 if (!ShouldDispatchBeforeUnload()) { | 1919 if (!ShouldDispatchBeforeUnload()) { |
| 1919 DCHECK(!(IsBrowserSideNavigationEnabled() && for_navigation)); | 1920 DCHECK(!(IsBrowserSideNavigationEnabled() && for_navigation)); |
| 1920 frame_tree_node_->render_manager()->OnBeforeUnloadACK( | 1921 frame_tree_node_->render_manager()->OnBeforeUnloadACK( |
| 1921 for_navigation, true, base::TimeTicks::Now()); | 1922 for_navigation, true, base::TimeTicks::Now()); |
| 1922 return; | 1923 return; |
| 1923 } | 1924 } |
| 1924 TRACE_EVENT_ASYNC_BEGIN0( | 1925 TRACE_EVENT_ASYNC_BEGIN1("navigation", "RenderFrameHostImpl BeforeUnload", |
| 1925 "navigation", "RenderFrameHostImpl::BeforeUnload", this); | 1926 this, "&RenderFrameHostImpl", (void*)this); |
| 1926 | 1927 |
| 1927 // This may be called more than once (if the user clicks the tab close button | 1928 // This may be called more than once (if the user clicks the tab close button |
| 1928 // several times, or if she clicks the tab close button then the browser close | 1929 // several times, or if she clicks the tab close button then the browser close |
| 1929 // button), and we only send the message once. | 1930 // button), and we only send the message once. |
| 1930 if (is_waiting_for_beforeunload_ack_) { | 1931 if (is_waiting_for_beforeunload_ack_) { |
| 1931 // Some of our close messages could be for the tab, others for cross-site | 1932 // Some of our close messages could be for the tab, others for cross-site |
| 1932 // transitions. We always want to think it's for closing the tab if any | 1933 // transitions. We always want to think it's for closing the tab if any |
| 1933 // of the messages were, since otherwise it might be impossible to close | 1934 // of the messages were, since otherwise it might be impossible to close |
| 1934 // (if there was a cross-site "close" request pending when the user clicked | 1935 // (if there was a cross-site "close" request pending when the user clicked |
| 1935 // the close button). We want to keep the "for cross site" flag only if | 1936 // the close button). We want to keep the "for cross site" flag only if |
| (...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2514 *dst = src; | 2515 *dst = src; |
| 2515 | 2516 |
| 2516 if (src.routing_id != -1) | 2517 if (src.routing_id != -1) |
| 2517 dst->tree_id = RoutingIDToAXTreeID(src.routing_id); | 2518 dst->tree_id = RoutingIDToAXTreeID(src.routing_id); |
| 2518 | 2519 |
| 2519 if (src.parent_routing_id != -1) | 2520 if (src.parent_routing_id != -1) |
| 2520 dst->parent_tree_id = RoutingIDToAXTreeID(src.parent_routing_id); | 2521 dst->parent_tree_id = RoutingIDToAXTreeID(src.parent_routing_id); |
| 2521 } | 2522 } |
| 2522 | 2523 |
| 2523 } // namespace content | 2524 } // namespace content |
| OLD | NEW |