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

Side by Side Diff: content/browser/web_contents/web_contents_impl.cc

Issue 2782443002: Revert of Move beforeunload hang timer duties to its own timer.
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
« no previous file with comments | « content/browser/web_contents/web_contents_impl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/web_contents/web_contents_impl.h" 5 #include "content/browser/web_contents/web_contents_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <cmath> 9 #include <cmath>
10 #include <utility> 10 #include <utility>
(...skipping 4208 matching lines...) Expand 10 before | Expand all | Expand 10 after
4219 static_cast<RenderFrameHostImpl*>(render_frame_host); 4219 static_cast<RenderFrameHostImpl*>(render_frame_host);
4220 if (delegate_) 4220 if (delegate_)
4221 delegate_->WillRunBeforeUnloadConfirm(); 4221 delegate_->WillRunBeforeUnloadConfirm();
4222 4222
4223 bool suppress_this_message = 4223 bool suppress_this_message =
4224 !rfhi->is_active() || 4224 !rfhi->is_active() ||
4225 ShowingInterstitialPage() || !delegate_ || 4225 ShowingInterstitialPage() || !delegate_ ||
4226 delegate_->ShouldSuppressDialogs(this) || 4226 delegate_->ShouldSuppressDialogs(this) ||
4227 !delegate_->GetJavaScriptDialogManager(this); 4227 !delegate_->GetJavaScriptDialogManager(this);
4228 if (suppress_this_message) { 4228 if (suppress_this_message) {
4229 rfhi->JavaScriptDialogClosed(reply_msg, true, base::string16(), true); 4229 rfhi->JavaScriptDialogClosed(reply_msg, true, base::string16(),
4230 /*is_before_unload_dialog=*/true,
4231 /*dialog_was_suppressed=*/true);
4230 return; 4232 return;
4231 } 4233 }
4232 4234
4233 is_showing_before_unload_dialog_ = true; 4235 is_showing_before_unload_dialog_ = true;
4234 dialog_manager_ = delegate_->GetJavaScriptDialogManager(this); 4236 dialog_manager_ = delegate_->GetJavaScriptDialogManager(this);
4235 dialog_manager_->RunBeforeUnloadDialog( 4237 dialog_manager_->RunBeforeUnloadDialog(
4236 this, is_reload, 4238 this, is_reload,
4237 base::Bind(&WebContentsImpl::OnDialogClosed, base::Unretained(this), 4239 base::Bind(&WebContentsImpl::OnDialogClosed, base::Unretained(this),
4238 render_frame_host->GetProcess()->GetID(), 4240 render_frame_host->GetProcess()->GetID(),
4239 render_frame_host->GetRoutingID(), reply_msg, 4241 render_frame_host->GetRoutingID(), reply_msg,
(...skipping 597 matching lines...) Expand 10 before | Expand all | Expand 10 after
4837 for (auto& observer : observers_) 4839 for (auto& observer : observers_)
4838 observer.OnRendererUnresponsive(render_widget_host); 4840 observer.OnRendererUnresponsive(render_widget_host);
4839 4841
4840 // Don't show hung renderer dialog for a swapped out RVH. 4842 // Don't show hung renderer dialog for a swapped out RVH.
4841 if (render_widget_host != GetRenderViewHost()->GetWidget()) 4843 if (render_widget_host != GetRenderViewHost()->GetWidget())
4842 return; 4844 return;
4843 4845
4844 if (ShouldIgnoreUnresponsiveRenderer()) 4846 if (ShouldIgnoreUnresponsiveRenderer())
4845 return; 4847 return;
4846 4848
4849 RenderFrameHostImpl* rfhi =
4850 static_cast<RenderFrameHostImpl*>(GetRenderViewHost()->GetMainFrame());
4851 if (rfhi->is_waiting_for_beforeunload_ack()) {
4852 // If the hang is in the beforeunload handler, pretend the beforeunload
4853 // listeners have all fired and allow the delegate to continue closing;
4854 // the user will not have the option of cancelling the close.
4855 rfhi->SimulateBeforeUnloadAck();
4856 return;
4857 }
4858
4847 if (!GetRenderViewHost() || !GetRenderViewHost()->IsRenderViewLive()) 4859 if (!GetRenderViewHost() || !GetRenderViewHost()->IsRenderViewLive())
4848 return; 4860 return;
4849 4861
4850 if (delegate_) { 4862 if (delegate_) {
4851 WebContentsUnresponsiveState unresponsive_state; 4863 WebContentsUnresponsiveState unresponsive_state;
4852 unresponsive_state.outstanding_ack_count = 4864 unresponsive_state.outstanding_ack_count =
4853 render_widget_host->in_flight_event_count(); 4865 render_widget_host->in_flight_event_count();
4854 unresponsive_state.outstanding_event_type = 4866 unresponsive_state.outstanding_event_type =
4855 render_widget_host->hang_monitor_event_type(); 4867 render_widget_host->hang_monitor_event_type();
4856 unresponsive_state.last_event_type = render_widget_host->last_event_type(); 4868 unresponsive_state.last_event_type = render_widget_host->last_event_type();
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
5098 rfh->frame_tree_node()->BeforeUnloadCanceled(); 5110 rfh->frame_tree_node()->BeforeUnloadCanceled();
5099 controller_.DiscardNonCommittedEntries(); 5111 controller_.DiscardNonCommittedEntries();
5100 } 5112 }
5101 5113
5102 for (auto& observer : observers_) 5114 for (auto& observer : observers_)
5103 observer.BeforeUnloadDialogCancelled(); 5115 observer.BeforeUnloadDialogCancelled();
5104 } 5116 }
5105 5117
5106 if (rfh) { 5118 if (rfh) {
5107 rfh->JavaScriptDialogClosed(reply_msg, success, user_input, 5119 rfh->JavaScriptDialogClosed(reply_msg, success, user_input,
5120 is_showing_before_unload_dialog_,
5108 dialog_was_suppressed); 5121 dialog_was_suppressed);
5109 } else { 5122 } else {
5110 // Don't leak the sync IPC reply if the RFH or process is gone. 5123 // Don't leak the sync IPC reply if the RFH or process is gone.
5111 delete reply_msg; 5124 delete reply_msg;
5112 } 5125 }
5113 5126
5114 is_showing_javascript_dialog_ = false; 5127 is_showing_javascript_dialog_ = false;
5115 is_showing_before_unload_dialog_ = false; 5128 is_showing_before_unload_dialog_ = false;
5116 } 5129 }
5117 5130
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
5390 RenderViewHost* render_view_host = RenderViewHost::From(render_widget_host); 5403 RenderViewHost* render_view_host = RenderViewHost::From(render_widget_host);
5391 if (!render_view_host) 5404 if (!render_view_host)
5392 continue; 5405 continue;
5393 render_view_host_set.insert(render_view_host); 5406 render_view_host_set.insert(render_view_host);
5394 } 5407 }
5395 for (RenderViewHost* render_view_host : render_view_host_set) 5408 for (RenderViewHost* render_view_host : render_view_host_set)
5396 render_view_host->OnWebkitPreferencesChanged(); 5409 render_view_host->OnWebkitPreferencesChanged();
5397 } 5410 }
5398 5411
5399 } // namespace content 5412 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/web_contents/web_contents_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698