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