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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 delegate_(delegate), | 136 delegate_(delegate), |
137 site_instance_(static_cast<SiteInstanceImpl*>(site_instance)), | 137 site_instance_(static_cast<SiteInstanceImpl*>(site_instance)), |
138 process_(site_instance->GetProcess()), | 138 process_(site_instance->GetProcess()), |
139 cross_process_frame_connector_(NULL), | 139 cross_process_frame_connector_(NULL), |
140 render_frame_proxy_host_(NULL), | 140 render_frame_proxy_host_(NULL), |
141 frame_tree_(frame_tree), | 141 frame_tree_(frame_tree), |
142 frame_tree_node_(frame_tree_node), | 142 frame_tree_node_(frame_tree_node), |
143 routing_id_(routing_id), | 143 routing_id_(routing_id), |
144 render_frame_created_(false), | 144 render_frame_created_(false), |
145 navigations_suspended_(false), | 145 navigations_suspended_(false), |
| 146 has_beforeunload_handlers_(false), |
| 147 has_unload_handlers_(false), |
| 148 override_sudden_termination_status_(false), |
146 is_waiting_for_beforeunload_ack_(false), | 149 is_waiting_for_beforeunload_ack_(false), |
147 unload_ack_is_for_navigation_(false), | 150 unload_ack_is_for_navigation_(false), |
148 accessibility_reset_token_(0), | 151 accessibility_reset_token_(0), |
149 accessibility_reset_count_(0), | 152 accessibility_reset_count_(0), |
150 no_create_browser_accessibility_manager_for_testing_(false), | 153 no_create_browser_accessibility_manager_for_testing_(false), |
151 weak_ptr_factory_(this) { | 154 weak_ptr_factory_(this) { |
152 bool is_swapped_out = !!(flags & CREATE_RF_SWAPPED_OUT); | 155 bool is_swapped_out = !!(flags & CREATE_RF_SWAPPED_OUT); |
153 bool hidden = !!(flags & CREATE_RF_HIDDEN); | 156 bool hidden = !!(flags & CREATE_RF_HIDDEN); |
154 frame_tree_->RegisterRenderFrameHost(this); | 157 frame_tree_->RegisterRenderFrameHost(this); |
155 GetProcess()->AddRoute(routing_id_, this); | 158 GetProcess()->AddRoute(routing_id_, this); |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
340 OnDidFailProvisionalLoadWithError) | 343 OnDidFailProvisionalLoadWithError) |
341 IPC_MESSAGE_HANDLER(FrameHostMsg_DidFailLoadWithError, | 344 IPC_MESSAGE_HANDLER(FrameHostMsg_DidFailLoadWithError, |
342 OnDidFailLoadWithError) | 345 OnDidFailLoadWithError) |
343 IPC_MESSAGE_HANDLER_GENERIC(FrameHostMsg_DidCommitProvisionalLoad, | 346 IPC_MESSAGE_HANDLER_GENERIC(FrameHostMsg_DidCommitProvisionalLoad, |
344 OnDidCommitProvisionalLoad(msg)) | 347 OnDidCommitProvisionalLoad(msg)) |
345 IPC_MESSAGE_HANDLER(FrameHostMsg_DidDropNavigation, OnDidDropNavigation) | 348 IPC_MESSAGE_HANDLER(FrameHostMsg_DidDropNavigation, OnDidDropNavigation) |
346 IPC_MESSAGE_HANDLER(FrameHostMsg_OpenURL, OnOpenURL) | 349 IPC_MESSAGE_HANDLER(FrameHostMsg_OpenURL, OnOpenURL) |
347 IPC_MESSAGE_HANDLER(FrameHostMsg_DocumentOnLoadCompleted, | 350 IPC_MESSAGE_HANDLER(FrameHostMsg_DocumentOnLoadCompleted, |
348 OnDocumentOnLoadCompleted) | 351 OnDocumentOnLoadCompleted) |
349 IPC_MESSAGE_HANDLER(FrameHostMsg_BeforeUnload_ACK, OnBeforeUnloadACK) | 352 IPC_MESSAGE_HANDLER(FrameHostMsg_BeforeUnload_ACK, OnBeforeUnloadACK) |
| 353 IPC_MESSAGE_HANDLER(FrameHostMsg_BeforeUnloadHandlersPresent, |
| 354 OnBeforeUnloadHandlersPresent) |
| 355 IPC_MESSAGE_HANDLER(FrameHostMsg_UnloadHandlersPresent, |
| 356 OnUnloadHandlersPresent) |
350 IPC_MESSAGE_HANDLER(FrameHostMsg_SwapOut_ACK, OnSwapOutACK) | 357 IPC_MESSAGE_HANDLER(FrameHostMsg_SwapOut_ACK, OnSwapOutACK) |
351 IPC_MESSAGE_HANDLER(FrameHostMsg_ContextMenu, OnContextMenu) | 358 IPC_MESSAGE_HANDLER(FrameHostMsg_ContextMenu, OnContextMenu) |
352 IPC_MESSAGE_HANDLER(FrameHostMsg_JavaScriptExecuteResponse, | 359 IPC_MESSAGE_HANDLER(FrameHostMsg_JavaScriptExecuteResponse, |
353 OnJavaScriptExecuteResponse) | 360 OnJavaScriptExecuteResponse) |
354 IPC_MESSAGE_HANDLER(FrameHostMsg_FlushVisualStateResponse, | 361 IPC_MESSAGE_HANDLER(FrameHostMsg_FlushVisualStateResponse, |
355 OnFlushVisualStateResponse) | 362 OnFlushVisualStateResponse) |
356 IPC_MESSAGE_HANDLER_DELAY_REPLY(FrameHostMsg_RunJavaScriptMessage, | 363 IPC_MESSAGE_HANDLER_DELAY_REPLY(FrameHostMsg_RunJavaScriptMessage, |
357 OnRunJavaScriptMessage) | 364 OnRunJavaScriptMessage) |
358 IPC_MESSAGE_HANDLER_DELAY_REPLY(FrameHostMsg_RunBeforeUnloadConfirm, | 365 IPC_MESSAGE_HANDLER_DELAY_REPLY(FrameHostMsg_RunBeforeUnloadConfirm, |
359 OnRunBeforeUnloadConfirm) | 366 OnRunBeforeUnloadConfirm) |
(...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1008 } | 1015 } |
1009 return frame_tree_node_->navigator()->IsWaitingForBeforeUnloadACK( | 1016 return frame_tree_node_->navigator()->IsWaitingForBeforeUnloadACK( |
1010 frame_tree_node_); | 1017 frame_tree_node_); |
1011 } | 1018 } |
1012 | 1019 |
1013 bool RenderFrameHostImpl::IsWaitingForUnloadACK() const { | 1020 bool RenderFrameHostImpl::IsWaitingForUnloadACK() const { |
1014 return render_view_host_->is_waiting_for_close_ack_ || | 1021 return render_view_host_->is_waiting_for_close_ack_ || |
1015 rfh_state_ == STATE_PENDING_SWAP_OUT; | 1022 rfh_state_ == STATE_PENDING_SWAP_OUT; |
1016 } | 1023 } |
1017 | 1024 |
| 1025 bool RenderFrameHostImpl::SuddenTerminationAllowed() const { |
| 1026 return override_sudden_termination_status_ || |
| 1027 (!has_beforeunload_handlers_ && !has_unload_handlers_); |
| 1028 } |
| 1029 |
1018 void RenderFrameHostImpl::OnSwapOutACK() { | 1030 void RenderFrameHostImpl::OnSwapOutACK() { |
1019 OnSwappedOut(); | 1031 OnSwappedOut(); |
1020 } | 1032 } |
1021 | 1033 |
1022 void RenderFrameHostImpl::OnSwappedOut() { | 1034 void RenderFrameHostImpl::OnSwappedOut() { |
1023 // Ignore spurious swap out ack. | 1035 // Ignore spurious swap out ack. |
1024 if (rfh_state_ != STATE_PENDING_SWAP_OUT) | 1036 if (rfh_state_ != STATE_PENDING_SWAP_OUT) |
1025 return; | 1037 return; |
1026 | 1038 |
1027 TRACE_EVENT_ASYNC_END0("navigation", "RenderFrameHostImpl::SwapOut", this); | 1039 TRACE_EVENT_ASYNC_END0("navigation", "RenderFrameHostImpl::SwapOut", this); |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1283 if (enter_fullscreen) | 1295 if (enter_fullscreen) |
1284 delegate_->EnterFullscreenMode(GetLastCommittedURL().GetOrigin()); | 1296 delegate_->EnterFullscreenMode(GetLastCommittedURL().GetOrigin()); |
1285 else | 1297 else |
1286 delegate_->ExitFullscreenMode(); | 1298 delegate_->ExitFullscreenMode(); |
1287 | 1299 |
1288 // The previous call might change the fullscreen state. We need to make sure | 1300 // The previous call might change the fullscreen state. We need to make sure |
1289 // the renderer is aware of that, which is done via the resize message. | 1301 // the renderer is aware of that, which is done via the resize message. |
1290 render_view_host_->WasResized(); | 1302 render_view_host_->WasResized(); |
1291 } | 1303 } |
1292 | 1304 |
| 1305 void RenderFrameHostImpl::OnBeforeUnloadHandlersPresent(bool present) { |
| 1306 has_beforeunload_handlers_ = present; |
| 1307 } |
| 1308 |
| 1309 void RenderFrameHostImpl::OnUnloadHandlersPresent(bool present) { |
| 1310 has_unload_handlers_ = present; |
| 1311 } |
| 1312 |
1293 #if defined(OS_MACOSX) || defined(OS_ANDROID) | 1313 #if defined(OS_MACOSX) || defined(OS_ANDROID) |
1294 void RenderFrameHostImpl::OnShowPopup( | 1314 void RenderFrameHostImpl::OnShowPopup( |
1295 const FrameHostMsg_ShowPopup_Params& params) { | 1315 const FrameHostMsg_ShowPopup_Params& params) { |
1296 RenderViewHostDelegateView* view = | 1316 RenderViewHostDelegateView* view = |
1297 render_view_host_->delegate_->GetDelegateView(); | 1317 render_view_host_->delegate_->GetDelegateView(); |
1298 if (view) { | 1318 if (view) { |
1299 view->ShowPopupMenu(this, | 1319 view->ShowPopupMenu(this, |
1300 params.bounds, | 1320 params.bounds, |
1301 params.item_height, | 1321 params.item_height, |
1302 params.item_font_size, | 1322 params.item_font_size, |
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1824 void RenderFrameHostImpl::DidUseGeolocationPermission() { | 1844 void RenderFrameHostImpl::DidUseGeolocationPermission() { |
1825 RenderFrameHost* top_frame = frame_tree_node()->frame_tree()->GetMainFrame(); | 1845 RenderFrameHost* top_frame = frame_tree_node()->frame_tree()->GetMainFrame(); |
1826 GetContentClient()->browser()->RegisterPermissionUsage( | 1846 GetContentClient()->browser()->RegisterPermissionUsage( |
1827 PERMISSION_GEOLOCATION, | 1847 PERMISSION_GEOLOCATION, |
1828 delegate_->GetAsWebContents(), | 1848 delegate_->GetAsWebContents(), |
1829 GetLastCommittedURL().GetOrigin(), | 1849 GetLastCommittedURL().GetOrigin(), |
1830 top_frame->GetLastCommittedURL().GetOrigin()); | 1850 top_frame->GetLastCommittedURL().GetOrigin()); |
1831 } | 1851 } |
1832 | 1852 |
1833 } // namespace content | 1853 } // namespace content |
OLD | NEW |