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_cross_site_transition_(false), | 150 unload_ack_is_for_cross_site_transition_(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 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
334 OnDidFailProvisionalLoadWithError) | 337 OnDidFailProvisionalLoadWithError) |
335 IPC_MESSAGE_HANDLER(FrameHostMsg_DidFailLoadWithError, | 338 IPC_MESSAGE_HANDLER(FrameHostMsg_DidFailLoadWithError, |
336 OnDidFailLoadWithError) | 339 OnDidFailLoadWithError) |
337 IPC_MESSAGE_HANDLER_GENERIC(FrameHostMsg_DidCommitProvisionalLoad, | 340 IPC_MESSAGE_HANDLER_GENERIC(FrameHostMsg_DidCommitProvisionalLoad, |
338 OnDidCommitProvisionalLoad(msg)) | 341 OnDidCommitProvisionalLoad(msg)) |
339 IPC_MESSAGE_HANDLER(FrameHostMsg_DidDropNavigation, OnDidDropNavigation) | 342 IPC_MESSAGE_HANDLER(FrameHostMsg_DidDropNavigation, OnDidDropNavigation) |
340 IPC_MESSAGE_HANDLER(FrameHostMsg_OpenURL, OnOpenURL) | 343 IPC_MESSAGE_HANDLER(FrameHostMsg_OpenURL, OnOpenURL) |
341 IPC_MESSAGE_HANDLER(FrameHostMsg_DocumentOnLoadCompleted, | 344 IPC_MESSAGE_HANDLER(FrameHostMsg_DocumentOnLoadCompleted, |
342 OnDocumentOnLoadCompleted) | 345 OnDocumentOnLoadCompleted) |
343 IPC_MESSAGE_HANDLER(FrameHostMsg_BeforeUnload_ACK, OnBeforeUnloadACK) | 346 IPC_MESSAGE_HANDLER(FrameHostMsg_BeforeUnload_ACK, OnBeforeUnloadACK) |
| 347 IPC_MESSAGE_HANDLER(FrameHostMsg_BeforeUnloadHandlersPresent, |
| 348 OnBeforeUnloadHandlersPresent) |
| 349 IPC_MESSAGE_HANDLER(FrameHostMsg_UnloadHandlersPresent, |
| 350 OnUnloadHandlersPresent) |
344 IPC_MESSAGE_HANDLER(FrameHostMsg_SwapOut_ACK, OnSwapOutACK) | 351 IPC_MESSAGE_HANDLER(FrameHostMsg_SwapOut_ACK, OnSwapOutACK) |
345 IPC_MESSAGE_HANDLER(FrameHostMsg_ContextMenu, OnContextMenu) | 352 IPC_MESSAGE_HANDLER(FrameHostMsg_ContextMenu, OnContextMenu) |
346 IPC_MESSAGE_HANDLER(FrameHostMsg_JavaScriptExecuteResponse, | 353 IPC_MESSAGE_HANDLER(FrameHostMsg_JavaScriptExecuteResponse, |
347 OnJavaScriptExecuteResponse) | 354 OnJavaScriptExecuteResponse) |
348 IPC_MESSAGE_HANDLER_DELAY_REPLY(FrameHostMsg_RunJavaScriptMessage, | 355 IPC_MESSAGE_HANDLER_DELAY_REPLY(FrameHostMsg_RunJavaScriptMessage, |
349 OnRunJavaScriptMessage) | 356 OnRunJavaScriptMessage) |
350 IPC_MESSAGE_HANDLER_DELAY_REPLY(FrameHostMsg_RunBeforeUnloadConfirm, | 357 IPC_MESSAGE_HANDLER_DELAY_REPLY(FrameHostMsg_RunBeforeUnloadConfirm, |
351 OnRunBeforeUnloadConfirm) | 358 OnRunBeforeUnloadConfirm) |
352 IPC_MESSAGE_HANDLER(FrameHostMsg_DidAccessInitialDocument, | 359 IPC_MESSAGE_HANDLER(FrameHostMsg_DidAccessInitialDocument, |
353 OnDidAccessInitialDocument) | 360 OnDidAccessInitialDocument) |
(...skipping 638 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
992 } | 999 } |
993 return frame_tree_node_->navigator()->IsWaitingForBeforeUnloadACK( | 1000 return frame_tree_node_->navigator()->IsWaitingForBeforeUnloadACK( |
994 frame_tree_node_); | 1001 frame_tree_node_); |
995 } | 1002 } |
996 | 1003 |
997 bool RenderFrameHostImpl::IsWaitingForUnloadACK() const { | 1004 bool RenderFrameHostImpl::IsWaitingForUnloadACK() const { |
998 return render_view_host_->is_waiting_for_close_ack_ || | 1005 return render_view_host_->is_waiting_for_close_ack_ || |
999 rfh_state_ == STATE_PENDING_SWAP_OUT; | 1006 rfh_state_ == STATE_PENDING_SWAP_OUT; |
1000 } | 1007 } |
1001 | 1008 |
| 1009 bool RenderFrameHostImpl::SuddenTerminationAllowed() const { |
| 1010 return override_sudden_termination_status_ || |
| 1011 (!has_beforeunload_handlers_ && !has_unload_handlers_); |
| 1012 } |
| 1013 |
1002 void RenderFrameHostImpl::OnSwapOutACK() { | 1014 void RenderFrameHostImpl::OnSwapOutACK() { |
1003 OnSwappedOut(); | 1015 OnSwappedOut(); |
1004 } | 1016 } |
1005 | 1017 |
1006 void RenderFrameHostImpl::OnSwappedOut() { | 1018 void RenderFrameHostImpl::OnSwappedOut() { |
1007 // Ignore spurious swap out ack. | 1019 // Ignore spurious swap out ack. |
1008 if (rfh_state_ != STATE_PENDING_SWAP_OUT) | 1020 if (rfh_state_ != STATE_PENDING_SWAP_OUT) |
1009 return; | 1021 return; |
1010 | 1022 |
1011 TRACE_EVENT_ASYNC_END0("navigation", "RenderFrameHostImpl::SwapOut", this); | 1023 TRACE_EVENT_ASYNC_END0("navigation", "RenderFrameHostImpl::SwapOut", this); |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1256 if (enter_fullscreen) | 1268 if (enter_fullscreen) |
1257 delegate_->EnterFullscreenMode(GetLastCommittedURL().GetOrigin()); | 1269 delegate_->EnterFullscreenMode(GetLastCommittedURL().GetOrigin()); |
1258 else | 1270 else |
1259 delegate_->ExitFullscreenMode(); | 1271 delegate_->ExitFullscreenMode(); |
1260 | 1272 |
1261 // The previous call might change the fullscreen state. We need to make sure | 1273 // The previous call might change the fullscreen state. We need to make sure |
1262 // the renderer is aware of that, which is done via the resize message. | 1274 // the renderer is aware of that, which is done via the resize message. |
1263 render_view_host_->WasResized(); | 1275 render_view_host_->WasResized(); |
1264 } | 1276 } |
1265 | 1277 |
| 1278 void RenderFrameHostImpl::OnBeforeUnloadHandlersPresent(bool present) { |
| 1279 has_beforeunload_handlers_ = present; |
| 1280 } |
| 1281 |
| 1282 void RenderFrameHostImpl::OnUnloadHandlersPresent(bool present) { |
| 1283 has_unload_handlers_ = present; |
| 1284 } |
| 1285 |
1266 #if defined(OS_MACOSX) || defined(OS_ANDROID) | 1286 #if defined(OS_MACOSX) || defined(OS_ANDROID) |
1267 void RenderFrameHostImpl::OnShowPopup( | 1287 void RenderFrameHostImpl::OnShowPopup( |
1268 const FrameHostMsg_ShowPopup_Params& params) { | 1288 const FrameHostMsg_ShowPopup_Params& params) { |
1269 RenderViewHostDelegateView* view = | 1289 RenderViewHostDelegateView* view = |
1270 render_view_host_->delegate_->GetDelegateView(); | 1290 render_view_host_->delegate_->GetDelegateView(); |
1271 if (view) { | 1291 if (view) { |
1272 view->ShowPopupMenu(this, | 1292 view->ShowPopupMenu(this, |
1273 params.bounds, | 1293 params.bounds, |
1274 params.item_height, | 1294 params.item_height, |
1275 params.item_font_size, | 1295 params.item_font_size, |
(...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1780 void RenderFrameHostImpl::DidUseGeolocationPermission() { | 1800 void RenderFrameHostImpl::DidUseGeolocationPermission() { |
1781 RenderFrameHost* top_frame = frame_tree_node()->frame_tree()->GetMainFrame(); | 1801 RenderFrameHost* top_frame = frame_tree_node()->frame_tree()->GetMainFrame(); |
1782 GetContentClient()->browser()->RegisterPermissionUsage( | 1802 GetContentClient()->browser()->RegisterPermissionUsage( |
1783 PERMISSION_GEOLOCATION, | 1803 PERMISSION_GEOLOCATION, |
1784 delegate_->GetAsWebContents(), | 1804 delegate_->GetAsWebContents(), |
1785 GetLastCommittedURL().GetOrigin(), | 1805 GetLastCommittedURL().GetOrigin(), |
1786 top_frame->GetLastCommittedURL().GetOrigin()); | 1806 top_frame->GetLastCommittedURL().GetOrigin()); |
1787 } | 1807 } |
1788 | 1808 |
1789 } // namespace content | 1809 } // namespace content |
OLD | NEW |