OLD | NEW |
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 Loading... |
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(), | 4229 rfhi->JavaScriptDialogClosed(reply_msg, true, base::string16(), true); |
4230 /*is_before_unload_dialog=*/true, | |
4231 /*dialog_was_suppressed=*/true); | |
4232 return; | 4230 return; |
4233 } | 4231 } |
4234 | 4232 |
4235 is_showing_before_unload_dialog_ = true; | 4233 is_showing_before_unload_dialog_ = true; |
4236 dialog_manager_ = delegate_->GetJavaScriptDialogManager(this); | 4234 dialog_manager_ = delegate_->GetJavaScriptDialogManager(this); |
4237 dialog_manager_->RunBeforeUnloadDialog( | 4235 dialog_manager_->RunBeforeUnloadDialog( |
4238 this, is_reload, | 4236 this, is_reload, |
4239 base::Bind(&WebContentsImpl::OnDialogClosed, base::Unretained(this), | 4237 base::Bind(&WebContentsImpl::OnDialogClosed, base::Unretained(this), |
4240 render_frame_host->GetProcess()->GetID(), | 4238 render_frame_host->GetProcess()->GetID(), |
4241 render_frame_host->GetRoutingID(), reply_msg, | 4239 render_frame_host->GetRoutingID(), reply_msg, |
(...skipping 597 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4839 for (auto& observer : observers_) | 4837 for (auto& observer : observers_) |
4840 observer.OnRendererUnresponsive(render_widget_host); | 4838 observer.OnRendererUnresponsive(render_widget_host); |
4841 | 4839 |
4842 // Don't show hung renderer dialog for a swapped out RVH. | 4840 // Don't show hung renderer dialog for a swapped out RVH. |
4843 if (render_widget_host != GetRenderViewHost()->GetWidget()) | 4841 if (render_widget_host != GetRenderViewHost()->GetWidget()) |
4844 return; | 4842 return; |
4845 | 4843 |
4846 if (ShouldIgnoreUnresponsiveRenderer()) | 4844 if (ShouldIgnoreUnresponsiveRenderer()) |
4847 return; | 4845 return; |
4848 | 4846 |
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 | |
4859 if (!GetRenderViewHost() || !GetRenderViewHost()->IsRenderViewLive()) | 4847 if (!GetRenderViewHost() || !GetRenderViewHost()->IsRenderViewLive()) |
4860 return; | 4848 return; |
4861 | 4849 |
4862 if (delegate_) { | 4850 if (delegate_) { |
4863 WebContentsUnresponsiveState unresponsive_state; | 4851 WebContentsUnresponsiveState unresponsive_state; |
4864 unresponsive_state.outstanding_ack_count = | 4852 unresponsive_state.outstanding_ack_count = |
4865 render_widget_host->in_flight_event_count(); | 4853 render_widget_host->in_flight_event_count(); |
4866 unresponsive_state.outstanding_event_type = | 4854 unresponsive_state.outstanding_event_type = |
4867 render_widget_host->hang_monitor_event_type(); | 4855 render_widget_host->hang_monitor_event_type(); |
4868 unresponsive_state.last_event_type = render_widget_host->last_event_type(); | 4856 unresponsive_state.last_event_type = render_widget_host->last_event_type(); |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5110 rfh->frame_tree_node()->BeforeUnloadCanceled(); | 5098 rfh->frame_tree_node()->BeforeUnloadCanceled(); |
5111 controller_.DiscardNonCommittedEntries(); | 5099 controller_.DiscardNonCommittedEntries(); |
5112 } | 5100 } |
5113 | 5101 |
5114 for (auto& observer : observers_) | 5102 for (auto& observer : observers_) |
5115 observer.BeforeUnloadDialogCancelled(); | 5103 observer.BeforeUnloadDialogCancelled(); |
5116 } | 5104 } |
5117 | 5105 |
5118 if (rfh) { | 5106 if (rfh) { |
5119 rfh->JavaScriptDialogClosed(reply_msg, success, user_input, | 5107 rfh->JavaScriptDialogClosed(reply_msg, success, user_input, |
5120 is_showing_before_unload_dialog_, | |
5121 dialog_was_suppressed); | 5108 dialog_was_suppressed); |
5122 } else { | 5109 } else { |
5123 // Don't leak the sync IPC reply if the RFH or process is gone. | 5110 // Don't leak the sync IPC reply if the RFH or process is gone. |
5124 delete reply_msg; | 5111 delete reply_msg; |
5125 } | 5112 } |
5126 | 5113 |
5127 is_showing_javascript_dialog_ = false; | 5114 is_showing_javascript_dialog_ = false; |
5128 is_showing_before_unload_dialog_ = false; | 5115 is_showing_before_unload_dialog_ = false; |
5129 } | 5116 } |
5130 | 5117 |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5403 RenderViewHost* render_view_host = RenderViewHost::From(render_widget_host); | 5390 RenderViewHost* render_view_host = RenderViewHost::From(render_widget_host); |
5404 if (!render_view_host) | 5391 if (!render_view_host) |
5405 continue; | 5392 continue; |
5406 render_view_host_set.insert(render_view_host); | 5393 render_view_host_set.insert(render_view_host); |
5407 } | 5394 } |
5408 for (RenderViewHost* render_view_host : render_view_host_set) | 5395 for (RenderViewHost* render_view_host : render_view_host_set) |
5409 render_view_host->OnWebkitPreferencesChanged(); | 5396 render_view_host->OnWebkitPreferencesChanged(); |
5410 } | 5397 } |
5411 | 5398 |
5412 } // namespace content | 5399 } // namespace content |
OLD | NEW |