Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(130)

Side by Side Diff: content/browser/frame_host/render_frame_host_impl.cc

Issue 2803633004: Revert of Keep track in the browser of which frames have onunload and onbeforeunload handlers. (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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),
383 is_waiting_for_beforeunload_ack_(false), 381 is_waiting_for_beforeunload_ack_(false),
384 unload_ack_is_for_navigation_(false), 382 unload_ack_is_for_navigation_(false),
385 is_loading_(false), 383 is_loading_(false),
386 pending_commit_(false), 384 pending_commit_(false),
387 nav_entry_id_(0), 385 nav_entry_id_(0),
388 accessibility_reset_token_(0), 386 accessibility_reset_token_(0),
389 accessibility_reset_count_(0), 387 accessibility_reset_count_(0),
390 browser_plugin_embedder_ax_tree_id_(ui::AXTreeIDRegistry::kNoAXTreeID), 388 browser_plugin_embedder_ax_tree_id_(ui::AXTreeIDRegistry::kNoAXTreeID),
391 no_create_browser_accessibility_manager_for_testing_(false), 389 no_create_browser_accessibility_manager_for_testing_(false),
392 web_ui_type_(WebUI::kNoWebUI), 390 web_ui_type_(WebUI::kNoWebUI),
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
746 OnDidFailLoadWithError) 744 OnDidFailLoadWithError)
747 IPC_MESSAGE_HANDLER_GENERIC(FrameHostMsg_DidCommitProvisionalLoad, 745 IPC_MESSAGE_HANDLER_GENERIC(FrameHostMsg_DidCommitProvisionalLoad,
748 OnDidCommitProvisionalLoad(msg)) 746 OnDidCommitProvisionalLoad(msg))
749 IPC_MESSAGE_HANDLER(FrameHostMsg_UpdateState, OnUpdateState) 747 IPC_MESSAGE_HANDLER(FrameHostMsg_UpdateState, OnUpdateState)
750 IPC_MESSAGE_HANDLER(FrameHostMsg_OpenURL, OnOpenURL) 748 IPC_MESSAGE_HANDLER(FrameHostMsg_OpenURL, OnOpenURL)
751 IPC_MESSAGE_HANDLER(FrameHostMsg_CancelInitialHistoryLoad, 749 IPC_MESSAGE_HANDLER(FrameHostMsg_CancelInitialHistoryLoad,
752 OnCancelInitialHistoryLoad) 750 OnCancelInitialHistoryLoad)
753 IPC_MESSAGE_HANDLER(FrameHostMsg_DocumentOnLoadCompleted, 751 IPC_MESSAGE_HANDLER(FrameHostMsg_DocumentOnLoadCompleted,
754 OnDocumentOnLoadCompleted) 752 OnDocumentOnLoadCompleted)
755 IPC_MESSAGE_HANDLER(FrameHostMsg_BeforeUnload_ACK, OnBeforeUnloadACK) 753 IPC_MESSAGE_HANDLER(FrameHostMsg_BeforeUnload_ACK, OnBeforeUnloadACK)
756 IPC_MESSAGE_HANDLER(FrameHostMsg_BeforeUnloadHandlersPresent,
757 OnBeforeUnloadHandlersPresent)
758 IPC_MESSAGE_HANDLER(FrameHostMsg_UnloadHandlersPresent,
759 OnUnloadHandlersPresent)
760 IPC_MESSAGE_HANDLER(FrameHostMsg_SwapOut_ACK, OnSwapOutACK) 754 IPC_MESSAGE_HANDLER(FrameHostMsg_SwapOut_ACK, OnSwapOutACK)
761 IPC_MESSAGE_HANDLER(FrameHostMsg_ContextMenu, OnContextMenu) 755 IPC_MESSAGE_HANDLER(FrameHostMsg_ContextMenu, OnContextMenu)
762 IPC_MESSAGE_HANDLER(FrameHostMsg_JavaScriptExecuteResponse, 756 IPC_MESSAGE_HANDLER(FrameHostMsg_JavaScriptExecuteResponse,
763 OnJavaScriptExecuteResponse) 757 OnJavaScriptExecuteResponse)
764 IPC_MESSAGE_HANDLER(FrameHostMsg_VisualStateResponse, 758 IPC_MESSAGE_HANDLER(FrameHostMsg_VisualStateResponse,
765 OnVisualStateResponse) 759 OnVisualStateResponse)
766 IPC_MESSAGE_HANDLER(FrameHostMsg_SmartClipDataExtracted, 760 IPC_MESSAGE_HANDLER(FrameHostMsg_SmartClipDataExtracted,
767 OnSmartClipDataExtracted) 761 OnSmartClipDataExtracted)
768 IPC_MESSAGE_HANDLER_DELAY_REPLY(FrameHostMsg_RunJavaScriptDialog, 762 IPC_MESSAGE_HANDLER_DELAY_REPLY(FrameHostMsg_RunJavaScriptDialog,
769 OnRunJavaScriptDialog) 763 OnRunJavaScriptDialog)
(...skipping 1602 matching lines...) Expand 10 before | Expand all | Expand 10 after
2372 delegate_->OnFocusedElementChangedInFrame( 2366 delegate_->OnFocusedElementChangedInFrame(
2373 this, gfx::Rect(GetView()->TransformPointToRootCoordSpace( 2367 this, gfx::Rect(GetView()->TransformPointToRootCoordSpace(
2374 bounds_in_frame_widget.origin()), 2368 bounds_in_frame_widget.origin()),
2375 bounds_in_frame_widget.size())); 2369 bounds_in_frame_widget.size()));
2376 } 2370 }
2377 2371
2378 void RenderFrameHostImpl::OnSetHasReceivedUserGesture() { 2372 void RenderFrameHostImpl::OnSetHasReceivedUserGesture() {
2379 frame_tree_node_->OnSetHasReceivedUserGesture(); 2373 frame_tree_node_->OnSetHasReceivedUserGesture();
2380 } 2374 }
2381 2375
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
2390 #if BUILDFLAG(USE_EXTERNAL_POPUP_MENU) 2376 #if BUILDFLAG(USE_EXTERNAL_POPUP_MENU)
2391 void RenderFrameHostImpl::OnShowPopup( 2377 void RenderFrameHostImpl::OnShowPopup(
2392 const FrameHostMsg_ShowPopup_Params& params) { 2378 const FrameHostMsg_ShowPopup_Params& params) {
2393 RenderViewHostDelegateView* view = 2379 RenderViewHostDelegateView* view =
2394 render_view_host_->delegate_->GetDelegateView(); 2380 render_view_host_->delegate_->GetDelegateView();
2395 if (view) { 2381 if (view) {
2396 gfx::Point original_point(params.bounds.x(), params.bounds.y()); 2382 gfx::Point original_point(params.bounds.x(), params.bounds.y());
2397 gfx::Point transformed_point = 2383 gfx::Point transformed_point =
2398 static_cast<RenderWidgetHostViewBase*>(GetView()) 2384 static_cast<RenderWidgetHostViewBase*>(GetView())
2399 ->TransformPointToRootCoordSpace(original_point); 2385 ->TransformPointToRootCoordSpace(original_point);
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
2708 } 2694 }
2709 } 2695 }
2710 2696
2711 void RenderFrameHostImpl::SimulateBeforeUnloadAck() { 2697 void RenderFrameHostImpl::SimulateBeforeUnloadAck() {
2712 DCHECK(is_waiting_for_beforeunload_ack_); 2698 DCHECK(is_waiting_for_beforeunload_ack_);
2713 base::TimeTicks approx_renderer_start_time = send_before_unload_start_time_; 2699 base::TimeTicks approx_renderer_start_time = send_before_unload_start_time_;
2714 OnBeforeUnloadACK(true, approx_renderer_start_time, base::TimeTicks::Now()); 2700 OnBeforeUnloadACK(true, approx_renderer_start_time, base::TimeTicks::Now());
2715 } 2701 }
2716 2702
2717 bool RenderFrameHostImpl::ShouldDispatchBeforeUnload() { 2703 bool RenderFrameHostImpl::ShouldDispatchBeforeUnload() {
2718 if (!IsRenderFrameLive()) 2704 return 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;
2737 } 2705 }
2738 2706
2739 void RenderFrameHostImpl::UpdateOpener() { 2707 void RenderFrameHostImpl::UpdateOpener() {
2740 // This frame (the frame whose opener is being updated) might not have had 2708 // This frame (the frame whose opener is being updated) might not have had
2741 // proxies for the new opener chain in its SiteInstance. Make sure they 2709 // proxies for the new opener chain in its SiteInstance. Make sure they
2742 // exist. 2710 // exist.
2743 if (frame_tree_node_->opener()) { 2711 if (frame_tree_node_->opener()) {
2744 frame_tree_node_->opener()->render_manager()->CreateOpenerProxies( 2712 frame_tree_node_->opener()->render_manager()->CreateOpenerProxies(
2745 GetSiteInstance(), frame_tree_node_); 2713 GetSiteInstance(), frame_tree_node_);
2746 } 2714 }
(...skipping 915 matching lines...) Expand 10 before | Expand all | Expand 10 after
3662 service_manager::mojom::InterfaceProviderPtr provider; 3630 service_manager::mojom::InterfaceProviderPtr provider;
3663 BindInterfaceRegistryForRenderFrameHost(mojo::MakeRequest(&provider), this); 3631 BindInterfaceRegistryForRenderFrameHost(mojo::MakeRequest(&provider), this);
3664 java_interfaces_.reset(new service_manager::InterfaceProvider); 3632 java_interfaces_.reset(new service_manager::InterfaceProvider);
3665 java_interfaces_->Bind(std::move(provider)); 3633 java_interfaces_->Bind(std::move(provider));
3666 } 3634 }
3667 return java_interfaces_.get(); 3635 return java_interfaces_.get();
3668 } 3636 }
3669 #endif 3637 #endif
3670 3638
3671 } // namespace content 3639 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/frame_host/render_frame_host_impl.h ('k') | content/browser/frame_host/render_frame_host_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698