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 <algorithm> | 7 #include <algorithm> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
371 site_instance_(static_cast<SiteInstanceImpl*>(site_instance)), | 371 site_instance_(static_cast<SiteInstanceImpl*>(site_instance)), |
372 process_(site_instance->GetProcess()), | 372 process_(site_instance->GetProcess()), |
373 frame_tree_(frame_tree), | 373 frame_tree_(frame_tree), |
374 frame_tree_node_(frame_tree_node), | 374 frame_tree_node_(frame_tree_node), |
375 parent_(nullptr), | 375 parent_(nullptr), |
376 render_widget_host_(nullptr), | 376 render_widget_host_(nullptr), |
377 routing_id_(routing_id), | 377 routing_id_(routing_id), |
378 is_waiting_for_swapout_ack_(false), | 378 is_waiting_for_swapout_ack_(false), |
379 render_frame_created_(false), | 379 render_frame_created_(false), |
380 navigations_suspended_(false), | 380 navigations_suspended_(false), |
| 381 has_beforeunload_handlers_(false), |
| 382 has_unload_handlers_(false), |
381 is_waiting_for_beforeunload_ack_(false), | 383 is_waiting_for_beforeunload_ack_(false), |
382 unload_ack_is_for_navigation_(false), | 384 unload_ack_is_for_navigation_(false), |
383 is_loading_(false), | 385 is_loading_(false), |
384 pending_commit_(false), | 386 pending_commit_(false), |
385 nav_entry_id_(0), | 387 nav_entry_id_(0), |
386 accessibility_reset_token_(0), | 388 accessibility_reset_token_(0), |
387 accessibility_reset_count_(0), | 389 accessibility_reset_count_(0), |
388 browser_plugin_embedder_ax_tree_id_(ui::AXTreeIDRegistry::kNoAXTreeID), | 390 browser_plugin_embedder_ax_tree_id_(ui::AXTreeIDRegistry::kNoAXTreeID), |
389 no_create_browser_accessibility_manager_for_testing_(false), | 391 no_create_browser_accessibility_manager_for_testing_(false), |
390 web_ui_type_(WebUI::kNoWebUI), | 392 web_ui_type_(WebUI::kNoWebUI), |
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
744 OnDidFailLoadWithError) | 746 OnDidFailLoadWithError) |
745 IPC_MESSAGE_HANDLER_GENERIC(FrameHostMsg_DidCommitProvisionalLoad, | 747 IPC_MESSAGE_HANDLER_GENERIC(FrameHostMsg_DidCommitProvisionalLoad, |
746 OnDidCommitProvisionalLoad(msg)) | 748 OnDidCommitProvisionalLoad(msg)) |
747 IPC_MESSAGE_HANDLER(FrameHostMsg_UpdateState, OnUpdateState) | 749 IPC_MESSAGE_HANDLER(FrameHostMsg_UpdateState, OnUpdateState) |
748 IPC_MESSAGE_HANDLER(FrameHostMsg_OpenURL, OnOpenURL) | 750 IPC_MESSAGE_HANDLER(FrameHostMsg_OpenURL, OnOpenURL) |
749 IPC_MESSAGE_HANDLER(FrameHostMsg_CancelInitialHistoryLoad, | 751 IPC_MESSAGE_HANDLER(FrameHostMsg_CancelInitialHistoryLoad, |
750 OnCancelInitialHistoryLoad) | 752 OnCancelInitialHistoryLoad) |
751 IPC_MESSAGE_HANDLER(FrameHostMsg_DocumentOnLoadCompleted, | 753 IPC_MESSAGE_HANDLER(FrameHostMsg_DocumentOnLoadCompleted, |
752 OnDocumentOnLoadCompleted) | 754 OnDocumentOnLoadCompleted) |
753 IPC_MESSAGE_HANDLER(FrameHostMsg_BeforeUnload_ACK, OnBeforeUnloadACK) | 755 IPC_MESSAGE_HANDLER(FrameHostMsg_BeforeUnload_ACK, OnBeforeUnloadACK) |
| 756 IPC_MESSAGE_HANDLER(FrameHostMsg_BeforeUnloadHandlersPresent, |
| 757 OnBeforeUnloadHandlersPresent) |
| 758 IPC_MESSAGE_HANDLER(FrameHostMsg_UnloadHandlersPresent, |
| 759 OnUnloadHandlersPresent) |
754 IPC_MESSAGE_HANDLER(FrameHostMsg_SwapOut_ACK, OnSwapOutACK) | 760 IPC_MESSAGE_HANDLER(FrameHostMsg_SwapOut_ACK, OnSwapOutACK) |
755 IPC_MESSAGE_HANDLER(FrameHostMsg_ContextMenu, OnContextMenu) | 761 IPC_MESSAGE_HANDLER(FrameHostMsg_ContextMenu, OnContextMenu) |
756 IPC_MESSAGE_HANDLER(FrameHostMsg_JavaScriptExecuteResponse, | 762 IPC_MESSAGE_HANDLER(FrameHostMsg_JavaScriptExecuteResponse, |
757 OnJavaScriptExecuteResponse) | 763 OnJavaScriptExecuteResponse) |
758 IPC_MESSAGE_HANDLER(FrameHostMsg_VisualStateResponse, | 764 IPC_MESSAGE_HANDLER(FrameHostMsg_VisualStateResponse, |
759 OnVisualStateResponse) | 765 OnVisualStateResponse) |
760 IPC_MESSAGE_HANDLER(FrameHostMsg_SmartClipDataExtracted, | 766 IPC_MESSAGE_HANDLER(FrameHostMsg_SmartClipDataExtracted, |
761 OnSmartClipDataExtracted) | 767 OnSmartClipDataExtracted) |
762 IPC_MESSAGE_HANDLER_DELAY_REPLY(FrameHostMsg_RunJavaScriptDialog, | 768 IPC_MESSAGE_HANDLER_DELAY_REPLY(FrameHostMsg_RunJavaScriptDialog, |
763 OnRunJavaScriptDialog) | 769 OnRunJavaScriptDialog) |
(...skipping 1602 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2366 delegate_->OnFocusedElementChangedInFrame( | 2372 delegate_->OnFocusedElementChangedInFrame( |
2367 this, gfx::Rect(GetView()->TransformPointToRootCoordSpace( | 2373 this, gfx::Rect(GetView()->TransformPointToRootCoordSpace( |
2368 bounds_in_frame_widget.origin()), | 2374 bounds_in_frame_widget.origin()), |
2369 bounds_in_frame_widget.size())); | 2375 bounds_in_frame_widget.size())); |
2370 } | 2376 } |
2371 | 2377 |
2372 void RenderFrameHostImpl::OnSetHasReceivedUserGesture() { | 2378 void RenderFrameHostImpl::OnSetHasReceivedUserGesture() { |
2373 frame_tree_node_->OnSetHasReceivedUserGesture(); | 2379 frame_tree_node_->OnSetHasReceivedUserGesture(); |
2374 } | 2380 } |
2375 | 2381 |
| 2382 void RenderFrameHostImpl::OnBeforeUnloadHandlersPresent(bool present) { |
| 2383 has_beforeunload_handlers_ = present; |
| 2384 } |
| 2385 |
| 2386 void RenderFrameHostImpl::OnUnloadHandlersPresent(bool present) { |
| 2387 has_unload_handlers_ = present; |
| 2388 } |
| 2389 |
2376 #if BUILDFLAG(USE_EXTERNAL_POPUP_MENU) | 2390 #if BUILDFLAG(USE_EXTERNAL_POPUP_MENU) |
2377 void RenderFrameHostImpl::OnShowPopup( | 2391 void RenderFrameHostImpl::OnShowPopup( |
2378 const FrameHostMsg_ShowPopup_Params& params) { | 2392 const FrameHostMsg_ShowPopup_Params& params) { |
2379 RenderViewHostDelegateView* view = | 2393 RenderViewHostDelegateView* view = |
2380 render_view_host_->delegate_->GetDelegateView(); | 2394 render_view_host_->delegate_->GetDelegateView(); |
2381 if (view) { | 2395 if (view) { |
2382 gfx::Point original_point(params.bounds.x(), params.bounds.y()); | 2396 gfx::Point original_point(params.bounds.x(), params.bounds.y()); |
2383 gfx::Point transformed_point = | 2397 gfx::Point transformed_point = |
2384 static_cast<RenderWidgetHostViewBase*>(GetView()) | 2398 static_cast<RenderWidgetHostViewBase*>(GetView()) |
2385 ->TransformPointToRootCoordSpace(original_point); | 2399 ->TransformPointToRootCoordSpace(original_point); |
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2694 } | 2708 } |
2695 } | 2709 } |
2696 | 2710 |
2697 void RenderFrameHostImpl::SimulateBeforeUnloadAck() { | 2711 void RenderFrameHostImpl::SimulateBeforeUnloadAck() { |
2698 DCHECK(is_waiting_for_beforeunload_ack_); | 2712 DCHECK(is_waiting_for_beforeunload_ack_); |
2699 base::TimeTicks approx_renderer_start_time = send_before_unload_start_time_; | 2713 base::TimeTicks approx_renderer_start_time = send_before_unload_start_time_; |
2700 OnBeforeUnloadACK(true, approx_renderer_start_time, base::TimeTicks::Now()); | 2714 OnBeforeUnloadACK(true, approx_renderer_start_time, base::TimeTicks::Now()); |
2701 } | 2715 } |
2702 | 2716 |
2703 bool RenderFrameHostImpl::ShouldDispatchBeforeUnload() { | 2717 bool RenderFrameHostImpl::ShouldDispatchBeforeUnload() { |
2704 return IsRenderFrameLive(); | 2718 if (!IsRenderFrameLive()) |
| 2719 return false; |
| 2720 |
| 2721 for (FrameTreeNode* node : frame_tree_->SubtreeNodes(frame_tree_node_)) { |
| 2722 if (node->current_frame_host()->has_beforeunload_handlers_) |
| 2723 return true; |
| 2724 } |
| 2725 return false; |
| 2726 } |
| 2727 |
| 2728 bool RenderFrameHostImpl::ShouldDispatchUnload() { |
| 2729 if (!IsRenderFrameLive()) |
| 2730 return false; |
| 2731 |
| 2732 for (FrameTreeNode* node : frame_tree_->SubtreeNodes(frame_tree_node_)) { |
| 2733 if (node->current_frame_host()->has_unload_handlers_) |
| 2734 return true; |
| 2735 } |
| 2736 return false; |
2705 } | 2737 } |
2706 | 2738 |
2707 void RenderFrameHostImpl::UpdateOpener() { | 2739 void RenderFrameHostImpl::UpdateOpener() { |
2708 // This frame (the frame whose opener is being updated) might not have had | 2740 // This frame (the frame whose opener is being updated) might not have had |
2709 // proxies for the new opener chain in its SiteInstance. Make sure they | 2741 // proxies for the new opener chain in its SiteInstance. Make sure they |
2710 // exist. | 2742 // exist. |
2711 if (frame_tree_node_->opener()) { | 2743 if (frame_tree_node_->opener()) { |
2712 frame_tree_node_->opener()->render_manager()->CreateOpenerProxies( | 2744 frame_tree_node_->opener()->render_manager()->CreateOpenerProxies( |
2713 GetSiteInstance(), frame_tree_node_); | 2745 GetSiteInstance(), frame_tree_node_); |
2714 } | 2746 } |
(...skipping 915 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3630 service_manager::mojom::InterfaceProviderPtr provider; | 3662 service_manager::mojom::InterfaceProviderPtr provider; |
3631 BindInterfaceRegistryForRenderFrameHost(mojo::MakeRequest(&provider), this); | 3663 BindInterfaceRegistryForRenderFrameHost(mojo::MakeRequest(&provider), this); |
3632 java_interfaces_.reset(new service_manager::InterfaceProvider); | 3664 java_interfaces_.reset(new service_manager::InterfaceProvider); |
3633 java_interfaces_->Bind(std::move(provider)); | 3665 java_interfaces_->Bind(std::move(provider)); |
3634 } | 3666 } |
3635 return java_interfaces_.get(); | 3667 return java_interfaces_.get(); |
3636 } | 3668 } |
3637 #endif | 3669 #endif |
3638 | 3670 |
3639 } // namespace content | 3671 } // namespace content |
OLD | NEW |