| 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 933 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 944 | 944 |
| 945 frame_tree_node_->navigator()->LogBeforeUnloadTime( | 945 frame_tree_node_->navigator()->LogBeforeUnloadTime( |
| 946 renderer_before_unload_start_time, renderer_before_unload_end_time); | 946 renderer_before_unload_start_time, renderer_before_unload_end_time); |
| 947 } | 947 } |
| 948 // Resets beforeunload waiting state. | 948 // Resets beforeunload waiting state. |
| 949 is_waiting_for_beforeunload_ack_ = false; | 949 is_waiting_for_beforeunload_ack_ = false; |
| 950 render_view_host_->decrement_in_flight_event_count(); | 950 render_view_host_->decrement_in_flight_event_count(); |
| 951 render_view_host_->StopHangMonitorTimeout(); | 951 render_view_host_->StopHangMonitorTimeout(); |
| 952 send_before_unload_start_time_ = base::TimeTicks(); | 952 send_before_unload_start_time_ = base::TimeTicks(); |
| 953 | 953 |
| 954 frame_tree_node_->render_manager()->OnBeforeUnloadACK( | 954 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 955 unload_ack_is_for_cross_site_transition_, proceed, | 955 switches::kEnableBrowserSideNavigation)) { |
| 956 before_unload_end_time); | 956 // TODO(clamy): see if before_unload_end_time should be transmitted to the |
| 957 // Navigator. |
| 958 frame_tree_node_->navigator()->OnBeforeUnloadACK( |
| 959 frame_tree_node_, proceed); |
| 960 } else { |
| 961 frame_tree_node_->render_manager()->OnBeforeUnloadACK( |
| 962 unload_ack_is_for_cross_site_transition_, proceed, |
| 963 before_unload_end_time); |
| 964 } |
| 957 | 965 |
| 958 // If canceled, notify the delegate to cancel its pending navigation entry. | 966 // If canceled, notify the delegate to cancel its pending navigation entry. |
| 959 if (!proceed) | 967 if (!proceed) |
| 960 render_view_host_->GetDelegate()->DidCancelLoading(); | 968 render_view_host_->GetDelegate()->DidCancelLoading(); |
| 961 } | 969 } |
| 962 | 970 |
| 963 bool RenderFrameHostImpl::IsWaitingForBeforeUnloadACK() const { | 971 bool RenderFrameHostImpl::IsWaitingForBeforeUnloadACK() const { |
| 964 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( | 972 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 965 switches::kEnableBrowserSideNavigation)) { | 973 switches::kEnableBrowserSideNavigation)) { |
| 966 return is_waiting_for_beforeunload_ack_; | 974 return is_waiting_for_beforeunload_ack_; |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1095 title_direction)); | 1103 title_direction)); |
| 1096 } | 1104 } |
| 1097 | 1105 |
| 1098 void RenderFrameHostImpl::OnUpdateEncoding(const std::string& encoding_name) { | 1106 void RenderFrameHostImpl::OnUpdateEncoding(const std::string& encoding_name) { |
| 1099 // This message is only sent for top-level frames. TODO(avi): when frame tree | 1107 // This message is only sent for top-level frames. TODO(avi): when frame tree |
| 1100 // mirroring works correctly, add a check here to enforce it. | 1108 // mirroring works correctly, add a check here to enforce it. |
| 1101 delegate_->UpdateEncoding(this, encoding_name); | 1109 delegate_->UpdateEncoding(this, encoding_name); |
| 1102 } | 1110 } |
| 1103 | 1111 |
| 1104 void RenderFrameHostImpl::OnBeginNavigation( | 1112 void RenderFrameHostImpl::OnBeginNavigation( |
| 1105 const FrameHostMsg_BeginNavigation_Params& params, | 1113 const CommonNavigationParams& common_params, |
| 1106 const CommonNavigationParams& common_params) { | 1114 const BeginNavigationParams& begin_params, |
| 1115 scoped_refptr<ResourceRequestBody> body) { |
| 1107 CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( | 1116 CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 1108 switches::kEnableBrowserSideNavigation)); | 1117 switches::kEnableBrowserSideNavigation)); |
| 1109 frame_tree_node()->navigator()->OnBeginNavigation( | 1118 frame_tree_node()->navigator()->OnBeginNavigation( |
| 1110 frame_tree_node(), params, common_params); | 1119 frame_tree_node(), common_params, begin_params, body); |
| 1111 } | 1120 } |
| 1112 | 1121 |
| 1113 void RenderFrameHostImpl::OnAccessibilityEvents( | 1122 void RenderFrameHostImpl::OnAccessibilityEvents( |
| 1114 const std::vector<AccessibilityHostMsg_EventParams>& params, | 1123 const std::vector<AccessibilityHostMsg_EventParams>& params, |
| 1115 int reset_token) { | 1124 int reset_token) { |
| 1116 // Don't process this IPC if either we're waiting on a reset and this | 1125 // Don't process this IPC if either we're waiting on a reset and this |
| 1117 // IPC doesn't have the matching token ID, or if we're not waiting on a | 1126 // IPC doesn't have the matching token ID, or if we're not waiting on a |
| 1118 // reset but this message includes a reset token. | 1127 // reset but this message includes a reset token. |
| 1119 if (accessibility_reset_token_ != reset_token) { | 1128 if (accessibility_reset_token_ != reset_token) { |
| 1120 Send(new AccessibilityMsg_Events_ACK(routing_id_)); | 1129 Send(new AccessibilityMsg_Events_ACK(routing_id_)); |
| (...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1418 | 1427 |
| 1419 void RenderFrameHostImpl::Stop() { | 1428 void RenderFrameHostImpl::Stop() { |
| 1420 Send(new FrameMsg_Stop(routing_id_)); | 1429 Send(new FrameMsg_Stop(routing_id_)); |
| 1421 } | 1430 } |
| 1422 | 1431 |
| 1423 void RenderFrameHostImpl::DispatchBeforeUnload(bool for_cross_site_transition) { | 1432 void RenderFrameHostImpl::DispatchBeforeUnload(bool for_cross_site_transition) { |
| 1424 // TODO(creis): Support beforeunload on subframes. For now just pretend that | 1433 // TODO(creis): Support beforeunload on subframes. For now just pretend that |
| 1425 // the handler ran and allowed the navigation to proceed. | 1434 // the handler ran and allowed the navigation to proceed. |
| 1426 if (GetParent() || !IsRenderFrameLive()) { | 1435 if (GetParent() || !IsRenderFrameLive()) { |
| 1427 // We don't have a live renderer, so just skip running beforeunload. | 1436 // We don't have a live renderer, so just skip running beforeunload. |
| 1428 frame_tree_node_->render_manager()->OnBeforeUnloadACK( | 1437 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 1429 for_cross_site_transition, true, base::TimeTicks::Now()); | 1438 switches::kEnableBrowserSideNavigation)) { |
| 1439 frame_tree_node_->navigator()->OnBeforeUnloadACK( |
| 1440 frame_tree_node_, true); |
| 1441 } else { |
| 1442 frame_tree_node_->render_manager()->OnBeforeUnloadACK( |
| 1443 for_cross_site_transition, true, base::TimeTicks::Now()); |
| 1444 } |
| 1430 return; | 1445 return; |
| 1431 } | 1446 } |
| 1432 TRACE_EVENT_ASYNC_BEGIN0( | 1447 TRACE_EVENT_ASYNC_BEGIN0( |
| 1433 "navigation", "RenderFrameHostImpl::BeforeUnload", this); | 1448 "navigation", "RenderFrameHostImpl::BeforeUnload", this); |
| 1434 | 1449 |
| 1435 // This may be called more than once (if the user clicks the tab close button | 1450 // This may be called more than once (if the user clicks the tab close button |
| 1436 // several times, or if she clicks the tab close button then the browser close | 1451 // several times, or if she clicks the tab close button then the browser close |
| 1437 // button), and we only send the message once. | 1452 // button), and we only send the message once. |
| 1438 if (is_waiting_for_beforeunload_ack_) { | 1453 if (is_waiting_for_beforeunload_ack_) { |
| 1439 // Some of our close messages could be for the tab, others for cross-site | 1454 // Some of our close messages could be for the tab, others for cross-site |
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1728 void RenderFrameHostImpl::DidUseGeolocationPermission() { | 1743 void RenderFrameHostImpl::DidUseGeolocationPermission() { |
| 1729 RenderFrameHost* top_frame = frame_tree_node()->frame_tree()->GetMainFrame(); | 1744 RenderFrameHost* top_frame = frame_tree_node()->frame_tree()->GetMainFrame(); |
| 1730 GetContentClient()->browser()->RegisterPermissionUsage( | 1745 GetContentClient()->browser()->RegisterPermissionUsage( |
| 1731 PERMISSION_GEOLOCATION, | 1746 PERMISSION_GEOLOCATION, |
| 1732 delegate_->GetAsWebContents(), | 1747 delegate_->GetAsWebContents(), |
| 1733 GetLastCommittedURL().GetOrigin(), | 1748 GetLastCommittedURL().GetOrigin(), |
| 1734 top_frame->GetLastCommittedURL().GetOrigin()); | 1749 top_frame->GetLastCommittedURL().GetOrigin()); |
| 1735 } | 1750 } |
| 1736 | 1751 |
| 1737 } // namespace content | 1752 } // namespace content |
| OLD | NEW |