| 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 4199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4210 static_cast<RenderFrameHostImpl*>(render_frame_host); | 4210 static_cast<RenderFrameHostImpl*>(render_frame_host); |
| 4211 if (delegate_) | 4211 if (delegate_) |
| 4212 delegate_->WillRunBeforeUnloadConfirm(); | 4212 delegate_->WillRunBeforeUnloadConfirm(); |
| 4213 | 4213 |
| 4214 bool suppress_this_message = | 4214 bool suppress_this_message = |
| 4215 !rfhi->is_active() || | 4215 !rfhi->is_active() || |
| 4216 ShowingInterstitialPage() || !delegate_ || | 4216 ShowingInterstitialPage() || !delegate_ || |
| 4217 delegate_->ShouldSuppressDialogs(this) || | 4217 delegate_->ShouldSuppressDialogs(this) || |
| 4218 !delegate_->GetJavaScriptDialogManager(this); | 4218 !delegate_->GetJavaScriptDialogManager(this); |
| 4219 if (suppress_this_message) { | 4219 if (suppress_this_message) { |
| 4220 rfhi->JavaScriptDialogClosed(reply_msg, true, base::string16(), | 4220 rfhi->JavaScriptDialogClosed(reply_msg, true, base::string16(), true); |
| 4221 /*is_before_unload_dialog=*/true, | |
| 4222 /*dialog_was_suppressed=*/true); | |
| 4223 return; | 4221 return; |
| 4224 } | 4222 } |
| 4225 | 4223 |
| 4226 is_showing_before_unload_dialog_ = true; | 4224 is_showing_before_unload_dialog_ = true; |
| 4227 dialog_manager_ = delegate_->GetJavaScriptDialogManager(this); | 4225 dialog_manager_ = delegate_->GetJavaScriptDialogManager(this); |
| 4228 dialog_manager_->RunBeforeUnloadDialog( | 4226 dialog_manager_->RunBeforeUnloadDialog( |
| 4229 this, is_reload, | 4227 this, is_reload, |
| 4230 base::Bind(&WebContentsImpl::OnDialogClosed, base::Unretained(this), | 4228 base::Bind(&WebContentsImpl::OnDialogClosed, base::Unretained(this), |
| 4231 render_frame_host->GetProcess()->GetID(), | 4229 render_frame_host->GetProcess()->GetID(), |
| 4232 render_frame_host->GetRoutingID(), reply_msg, | 4230 render_frame_host->GetRoutingID(), reply_msg, |
| (...skipping 597 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4830 for (auto& observer : observers_) | 4828 for (auto& observer : observers_) |
| 4831 observer.OnRendererUnresponsive(render_widget_host); | 4829 observer.OnRendererUnresponsive(render_widget_host); |
| 4832 | 4830 |
| 4833 // Don't show hung renderer dialog for a swapped out RVH. | 4831 // Don't show hung renderer dialog for a swapped out RVH. |
| 4834 if (render_widget_host != GetRenderViewHost()->GetWidget()) | 4832 if (render_widget_host != GetRenderViewHost()->GetWidget()) |
| 4835 return; | 4833 return; |
| 4836 | 4834 |
| 4837 if (ShouldIgnoreUnresponsiveRenderer()) | 4835 if (ShouldIgnoreUnresponsiveRenderer()) |
| 4838 return; | 4836 return; |
| 4839 | 4837 |
| 4840 RenderFrameHostImpl* rfhi = | |
| 4841 static_cast<RenderFrameHostImpl*>(GetRenderViewHost()->GetMainFrame()); | |
| 4842 if (rfhi->is_waiting_for_beforeunload_ack()) { | |
| 4843 // If the hang is in the beforeunload handler, pretend the beforeunload | |
| 4844 // listeners have all fired and allow the delegate to continue closing; | |
| 4845 // the user will not have the option of cancelling the close. | |
| 4846 rfhi->SimulateBeforeUnloadAck(); | |
| 4847 return; | |
| 4848 } | |
| 4849 | |
| 4850 if (!GetRenderViewHost() || !GetRenderViewHost()->IsRenderViewLive()) | 4838 if (!GetRenderViewHost() || !GetRenderViewHost()->IsRenderViewLive()) |
| 4851 return; | 4839 return; |
| 4852 | 4840 |
| 4853 if (delegate_) { | 4841 if (delegate_) { |
| 4854 WebContentsUnresponsiveState unresponsive_state; | 4842 WebContentsUnresponsiveState unresponsive_state; |
| 4855 unresponsive_state.outstanding_ack_count = | 4843 unresponsive_state.outstanding_ack_count = |
| 4856 render_widget_host->in_flight_event_count(); | 4844 render_widget_host->in_flight_event_count(); |
| 4857 unresponsive_state.outstanding_event_type = | 4845 unresponsive_state.outstanding_event_type = |
| 4858 render_widget_host->hang_monitor_event_type(); | 4846 render_widget_host->hang_monitor_event_type(); |
| 4859 unresponsive_state.last_event_type = render_widget_host->last_event_type(); | 4847 unresponsive_state.last_event_type = render_widget_host->last_event_type(); |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5101 rfh->frame_tree_node()->BeforeUnloadCanceled(); | 5089 rfh->frame_tree_node()->BeforeUnloadCanceled(); |
| 5102 controller_.DiscardNonCommittedEntries(); | 5090 controller_.DiscardNonCommittedEntries(); |
| 5103 } | 5091 } |
| 5104 | 5092 |
| 5105 for (auto& observer : observers_) | 5093 for (auto& observer : observers_) |
| 5106 observer.BeforeUnloadDialogCancelled(); | 5094 observer.BeforeUnloadDialogCancelled(); |
| 5107 } | 5095 } |
| 5108 | 5096 |
| 5109 if (rfh) { | 5097 if (rfh) { |
| 5110 rfh->JavaScriptDialogClosed(reply_msg, success, user_input, | 5098 rfh->JavaScriptDialogClosed(reply_msg, success, user_input, |
| 5111 is_showing_before_unload_dialog_, | |
| 5112 dialog_was_suppressed); | 5099 dialog_was_suppressed); |
| 5113 } else { | 5100 } else { |
| 5114 // Don't leak the sync IPC reply if the RFH or process is gone. | 5101 // Don't leak the sync IPC reply if the RFH or process is gone. |
| 5115 delete reply_msg; | 5102 delete reply_msg; |
| 5116 } | 5103 } |
| 5117 | 5104 |
| 5118 is_showing_javascript_dialog_ = false; | 5105 is_showing_javascript_dialog_ = false; |
| 5119 is_showing_before_unload_dialog_ = false; | 5106 is_showing_before_unload_dialog_ = false; |
| 5120 } | 5107 } |
| 5121 | 5108 |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5394 RenderViewHost* render_view_host = RenderViewHost::From(render_widget_host); | 5381 RenderViewHost* render_view_host = RenderViewHost::From(render_widget_host); |
| 5395 if (!render_view_host) | 5382 if (!render_view_host) |
| 5396 continue; | 5383 continue; |
| 5397 render_view_host_set.insert(render_view_host); | 5384 render_view_host_set.insert(render_view_host); |
| 5398 } | 5385 } |
| 5399 for (RenderViewHost* render_view_host : render_view_host_set) | 5386 for (RenderViewHost* render_view_host : render_view_host_set) |
| 5400 render_view_host->OnWebkitPreferencesChanged(); | 5387 render_view_host->OnWebkitPreferencesChanged(); |
| 5401 } | 5388 } |
| 5402 | 5389 |
| 5403 } // namespace content | 5390 } // namespace content |
| OLD | NEW |