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

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

Issue 2812743002: Revert of Keep track in the browser of which frames have onunload and onbeforeunload handlers. (Closed)
Patch Set: manual merge 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 354 matching lines...) Expand 10 before | Expand all | Expand 10 after
747 OnDidFailLoadWithError) 745 OnDidFailLoadWithError)
748 IPC_MESSAGE_HANDLER_GENERIC(FrameHostMsg_DidCommitProvisionalLoad, 746 IPC_MESSAGE_HANDLER_GENERIC(FrameHostMsg_DidCommitProvisionalLoad,
749 OnDidCommitProvisionalLoad(msg)) 747 OnDidCommitProvisionalLoad(msg))
750 IPC_MESSAGE_HANDLER(FrameHostMsg_UpdateState, OnUpdateState) 748 IPC_MESSAGE_HANDLER(FrameHostMsg_UpdateState, OnUpdateState)
751 IPC_MESSAGE_HANDLER(FrameHostMsg_OpenURL, OnOpenURL) 749 IPC_MESSAGE_HANDLER(FrameHostMsg_OpenURL, OnOpenURL)
752 IPC_MESSAGE_HANDLER(FrameHostMsg_CancelInitialHistoryLoad, 750 IPC_MESSAGE_HANDLER(FrameHostMsg_CancelInitialHistoryLoad,
753 OnCancelInitialHistoryLoad) 751 OnCancelInitialHistoryLoad)
754 IPC_MESSAGE_HANDLER(FrameHostMsg_DocumentOnLoadCompleted, 752 IPC_MESSAGE_HANDLER(FrameHostMsg_DocumentOnLoadCompleted,
755 OnDocumentOnLoadCompleted) 753 OnDocumentOnLoadCompleted)
756 IPC_MESSAGE_HANDLER(FrameHostMsg_BeforeUnload_ACK, OnBeforeUnloadACK) 754 IPC_MESSAGE_HANDLER(FrameHostMsg_BeforeUnload_ACK, OnBeforeUnloadACK)
757 IPC_MESSAGE_HANDLER(FrameHostMsg_BeforeUnloadHandlersPresent,
758 OnBeforeUnloadHandlersPresent)
759 IPC_MESSAGE_HANDLER(FrameHostMsg_UnloadHandlersPresent,
760 OnUnloadHandlersPresent)
761 IPC_MESSAGE_HANDLER(FrameHostMsg_SwapOut_ACK, OnSwapOutACK) 755 IPC_MESSAGE_HANDLER(FrameHostMsg_SwapOut_ACK, OnSwapOutACK)
762 IPC_MESSAGE_HANDLER(FrameHostMsg_ContextMenu, OnContextMenu) 756 IPC_MESSAGE_HANDLER(FrameHostMsg_ContextMenu, OnContextMenu)
763 IPC_MESSAGE_HANDLER(FrameHostMsg_JavaScriptExecuteResponse, 757 IPC_MESSAGE_HANDLER(FrameHostMsg_JavaScriptExecuteResponse,
764 OnJavaScriptExecuteResponse) 758 OnJavaScriptExecuteResponse)
765 IPC_MESSAGE_HANDLER(FrameHostMsg_VisualStateResponse, 759 IPC_MESSAGE_HANDLER(FrameHostMsg_VisualStateResponse,
766 OnVisualStateResponse) 760 OnVisualStateResponse)
767 IPC_MESSAGE_HANDLER(FrameHostMsg_SmartClipDataExtracted, 761 IPC_MESSAGE_HANDLER(FrameHostMsg_SmartClipDataExtracted,
768 OnSmartClipDataExtracted) 762 OnSmartClipDataExtracted)
769 IPC_MESSAGE_HANDLER_DELAY_REPLY(FrameHostMsg_RunJavaScriptDialog, 763 IPC_MESSAGE_HANDLER_DELAY_REPLY(FrameHostMsg_RunJavaScriptDialog,
770 OnRunJavaScriptDialog) 764 OnRunJavaScriptDialog)
(...skipping 1619 matching lines...) Expand 10 before | Expand all | Expand 10 after
2390 delegate_->OnFocusedElementChangedInFrame( 2384 delegate_->OnFocusedElementChangedInFrame(
2391 this, gfx::Rect(GetView()->TransformPointToRootCoordSpace( 2385 this, gfx::Rect(GetView()->TransformPointToRootCoordSpace(
2392 bounds_in_frame_widget.origin()), 2386 bounds_in_frame_widget.origin()),
2393 bounds_in_frame_widget.size())); 2387 bounds_in_frame_widget.size()));
2394 } 2388 }
2395 2389
2396 void RenderFrameHostImpl::OnSetHasReceivedUserGesture() { 2390 void RenderFrameHostImpl::OnSetHasReceivedUserGesture() {
2397 frame_tree_node_->OnSetHasReceivedUserGesture(); 2391 frame_tree_node_->OnSetHasReceivedUserGesture();
2398 } 2392 }
2399 2393
2400 void RenderFrameHostImpl::OnBeforeUnloadHandlersPresent(bool present) {
2401 has_beforeunload_handlers_ = present;
2402 }
2403
2404 void RenderFrameHostImpl::OnUnloadHandlersPresent(bool present) {
2405 has_unload_handlers_ = present;
2406 }
2407
2408 #if BUILDFLAG(USE_EXTERNAL_POPUP_MENU) 2394 #if BUILDFLAG(USE_EXTERNAL_POPUP_MENU)
2409 void RenderFrameHostImpl::OnShowPopup( 2395 void RenderFrameHostImpl::OnShowPopup(
2410 const FrameHostMsg_ShowPopup_Params& params) { 2396 const FrameHostMsg_ShowPopup_Params& params) {
2411 RenderViewHostDelegateView* view = 2397 RenderViewHostDelegateView* view =
2412 render_view_host_->delegate_->GetDelegateView(); 2398 render_view_host_->delegate_->GetDelegateView();
2413 if (view) { 2399 if (view) {
2414 gfx::Point original_point(params.bounds.x(), params.bounds.y()); 2400 gfx::Point original_point(params.bounds.x(), params.bounds.y());
2415 gfx::Point transformed_point = 2401 gfx::Point transformed_point =
2416 static_cast<RenderWidgetHostViewBase*>(GetView()) 2402 static_cast<RenderWidgetHostViewBase*>(GetView())
2417 ->TransformPointToRootCoordSpace(original_point); 2403 ->TransformPointToRootCoordSpace(original_point);
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
2729 } 2715 }
2730 } 2716 }
2731 2717
2732 void RenderFrameHostImpl::SimulateBeforeUnloadAck() { 2718 void RenderFrameHostImpl::SimulateBeforeUnloadAck() {
2733 DCHECK(is_waiting_for_beforeunload_ack_); 2719 DCHECK(is_waiting_for_beforeunload_ack_);
2734 base::TimeTicks approx_renderer_start_time = send_before_unload_start_time_; 2720 base::TimeTicks approx_renderer_start_time = send_before_unload_start_time_;
2735 OnBeforeUnloadACK(true, approx_renderer_start_time, base::TimeTicks::Now()); 2721 OnBeforeUnloadACK(true, approx_renderer_start_time, base::TimeTicks::Now());
2736 } 2722 }
2737 2723
2738 bool RenderFrameHostImpl::ShouldDispatchBeforeUnload() { 2724 bool RenderFrameHostImpl::ShouldDispatchBeforeUnload() {
2739 if (!IsRenderFrameLive()) 2725 return IsRenderFrameLive();
2740 return false;
2741
2742 for (FrameTreeNode* node : frame_tree_->SubtreeNodes(frame_tree_node_)) {
2743 if (node->current_frame_host()->has_beforeunload_handlers_)
2744 return true;
2745 }
2746 return false;
2747 }
2748
2749 bool RenderFrameHostImpl::ShouldDispatchUnload() {
2750 if (!IsRenderFrameLive())
2751 return false;
2752
2753 for (FrameTreeNode* node : frame_tree_->SubtreeNodes(frame_tree_node_)) {
2754 if (node->current_frame_host()->has_unload_handlers_)
2755 return true;
2756 }
2757 return false;
2758 } 2726 }
2759 2727
2760 void RenderFrameHostImpl::UpdateOpener() { 2728 void RenderFrameHostImpl::UpdateOpener() {
2761 // This frame (the frame whose opener is being updated) might not have had 2729 // This frame (the frame whose opener is being updated) might not have had
2762 // proxies for the new opener chain in its SiteInstance. Make sure they 2730 // proxies for the new opener chain in its SiteInstance. Make sure they
2763 // exist. 2731 // exist.
2764 if (frame_tree_node_->opener()) { 2732 if (frame_tree_node_->opener()) {
2765 frame_tree_node_->opener()->render_manager()->CreateOpenerProxies( 2733 frame_tree_node_->opener()->render_manager()->CreateOpenerProxies(
2766 GetSiteInstance(), frame_tree_node_); 2734 GetSiteInstance(), frame_tree_node_);
2767 } 2735 }
(...skipping 926 matching lines...) Expand 10 before | Expand all | Expand 10 after
3694 } 3662 }
3695 3663
3696 void RenderFrameHostImpl::ForwardGetInterfaceToRenderFrame( 3664 void RenderFrameHostImpl::ForwardGetInterfaceToRenderFrame(
3697 const std::string& interface_name, 3665 const std::string& interface_name,
3698 mojo::ScopedMessagePipeHandle pipe) { 3666 mojo::ScopedMessagePipeHandle pipe) {
3699 GetRemoteInterfaces()->GetInterface(interface_name, std::move(pipe)); 3667 GetRemoteInterfaces()->GetInterface(interface_name, std::move(pipe));
3700 } 3668 }
3701 #endif 3669 #endif
3702 3670
3703 } // namespace content 3671 } // 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