| 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 4535 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4546 | 4546 |
| 4547 RenderFrameHostImpl* rfhi = | 4547 RenderFrameHostImpl* rfhi = |
| 4548 static_cast<RenderFrameHostImpl*>(GetRenderViewHost()->GetMainFrame()); | 4548 static_cast<RenderFrameHostImpl*>(GetRenderViewHost()->GetMainFrame()); |
| 4549 | 4549 |
| 4550 // Ignore renderer unresponsive event if debugger is attached to the tab | 4550 // Ignore renderer unresponsive event if debugger is attached to the tab |
| 4551 // since the event may be a result of the renderer sitting on a breakpoint. | 4551 // since the event may be a result of the renderer sitting on a breakpoint. |
| 4552 // See http://crbug.com/65458 | 4552 // See http://crbug.com/65458 |
| 4553 if (DevToolsAgentHost::IsDebuggerAttached(this)) | 4553 if (DevToolsAgentHost::IsDebuggerAttached(this)) |
| 4554 return; | 4554 return; |
| 4555 | 4555 |
| 4556 if (rfhi->is_waiting_for_beforeunload_ack() || | 4556 // We might have been waiting for both beforeunload and unload ACK. |
| 4557 rfhi->IsWaitingForUnloadACK()) { | 4557 // Check if tab is to be unloaded first. |
| 4558 // Hang occurred while firing the beforeunload/unload handler. | 4558 if (rfhi->IsWaitingForUnloadACK()) { |
| 4559 // Hang occurred while firing the unload handler. |
| 4559 // Pretend the handler fired so tab closing continues as if it had. | 4560 // Pretend the handler fired so tab closing continues as if it had. |
| 4560 GetRenderViewHost()->set_sudden_termination_allowed(true); | 4561 GetRenderViewHost()->set_sudden_termination_allowed(true); |
| 4561 | 4562 |
| 4562 if (!GetRenderManager()->ShouldCloseTabOnUnresponsiveRenderer()) | 4563 if (!GetRenderManager()->ShouldCloseTabOnUnresponsiveRenderer()) |
| 4563 return; | 4564 return; |
| 4564 | 4565 |
| 4565 // If the tab hangs in the beforeunload/unload handler there's really | 4566 // If the tab hangs in the unload handler there's really nothing we can do |
| 4566 // nothing we can do to recover. If the hang is in the beforeunload handler, | 4567 // to recover. Pretend the unload listeners have all fired and close |
| 4567 // pretend the beforeunload listeners have all fired and allow the delegate | |
| 4568 // to continue closing; the user will not have the option of cancelling the | |
| 4569 // close. Otherwise, pretend the unload listeners have all fired and close | |
| 4570 // the tab. | 4568 // the tab. |
| 4571 bool close = true; | 4569 Close(); |
| 4572 if (rfhi->is_waiting_for_beforeunload_ack() && delegate_) { | |
| 4573 delegate_->BeforeUnloadFired(this, true, &close); | |
| 4574 } | |
| 4575 if (close) | |
| 4576 Close(); | |
| 4577 return; | 4570 return; |
| 4578 } | 4571 } |
| 4579 | 4572 |
| 4573 if (rfhi->is_waiting_for_beforeunload_ack()) { |
| 4574 // If the hang is in the beforeunload handler, pretend the beforeunload |
| 4575 // listeners have all fired and allow the delegate to continue closing; |
| 4576 // the user will not have the option of cancelling the close. |
| 4577 rfhi->SimulateBeforeUnloadAck(); |
| 4578 return; |
| 4579 } |
| 4580 |
| 4580 if (!GetRenderViewHost() || !GetRenderViewHost()->IsRenderViewLive()) | 4581 if (!GetRenderViewHost() || !GetRenderViewHost()->IsRenderViewLive()) |
| 4581 return; | 4582 return; |
| 4582 | 4583 |
| 4583 if (delegate_) | 4584 if (delegate_) |
| 4584 delegate_->RendererUnresponsive(this); | 4585 delegate_->RendererUnresponsive(this); |
| 4585 } | 4586 } |
| 4586 | 4587 |
| 4587 void WebContentsImpl::RendererResponsive( | 4588 void WebContentsImpl::RendererResponsive( |
| 4588 RenderWidgetHostImpl* render_widget_host) { | 4589 RenderWidgetHostImpl* render_widget_host) { |
| 4589 if (render_widget_host != GetRenderViewHost()->GetWidget()) | 4590 if (render_widget_host != GetRenderViewHost()->GetWidget()) |
| (...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5033 for (RenderViewHost* render_view_host : render_view_host_set) | 5034 for (RenderViewHost* render_view_host : render_view_host_set) |
| 5034 render_view_host->OnWebkitPreferencesChanged(); | 5035 render_view_host->OnWebkitPreferencesChanged(); |
| 5035 } | 5036 } |
| 5036 | 5037 |
| 5037 void WebContentsImpl::SetJavaScriptDialogManagerForTesting( | 5038 void WebContentsImpl::SetJavaScriptDialogManagerForTesting( |
| 5038 JavaScriptDialogManager* dialog_manager) { | 5039 JavaScriptDialogManager* dialog_manager) { |
| 5039 dialog_manager_ = dialog_manager; | 5040 dialog_manager_ = dialog_manager; |
| 5040 } | 5041 } |
| 5041 | 5042 |
| 5042 } // namespace content | 5043 } // namespace content |
| OLD | NEW |