Chromium Code Reviews| 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 if (rfhi->is_waiting_for_beforeunload_ack()) { |
| 4557 rfhi->IsWaitingForUnloadACK()) { | 4557 // If the hang is in the beforeunload handler, |
|
Charlie Reis
2016/05/19 22:11:56
nit: Fix line wrap.
| |
| 4558 // pretend the beforeunload listeners have all fired and allow the delegate | |
| 4559 // to continue closing; the user will not have the option of cancelling the | |
| 4560 // close. | |
| 4561 rfhi->ForceBeforeUnloadAck(); | |
| 4562 return; | |
| 4563 } | |
| 4564 | |
| 4565 if (rfhi->IsWaitingForUnloadACK()) { | |
| 4558 // Hang occurred while firing the beforeunload/unload handler. | 4566 // Hang occurred while firing the beforeunload/unload handler. |
|
Charlie Reis
2016/05/19 22:11:56
nit: Drop "beforeunload/"
| |
| 4559 // Pretend the handler fired so tab closing continues as if it had. | 4567 // Pretend the handler fired so tab closing continues as if it had. |
| 4560 GetRenderViewHost()->set_sudden_termination_allowed(true); | 4568 GetRenderViewHost()->set_sudden_termination_allowed(true); |
| 4561 | 4569 |
| 4562 if (!GetRenderManager()->ShouldCloseTabOnUnresponsiveRenderer()) | 4570 if (!GetRenderManager()->ShouldCloseTabOnUnresponsiveRenderer()) |
| 4563 return; | 4571 return; |
| 4564 | 4572 |
| 4565 // If the tab hangs in the beforeunload/unload handler there's really | 4573 // 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, | 4574 // 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. | 4575 // the tab. |
| 4571 bool close = true; | 4576 Close(); |
| 4572 if (rfhi->is_waiting_for_beforeunload_ack() && delegate_) { | |
| 4573 delegate_->BeforeUnloadFired(this, true, &close); | |
| 4574 } | |
| 4575 if (close) | |
| 4576 Close(); | |
| 4577 return; | 4577 return; |
| 4578 } | 4578 } |
| 4579 | 4579 |
| 4580 if (!GetRenderViewHost() || !GetRenderViewHost()->IsRenderViewLive()) | 4580 if (!GetRenderViewHost() || !GetRenderViewHost()->IsRenderViewLive()) |
| 4581 return; | 4581 return; |
| 4582 | 4582 |
| 4583 if (delegate_) | 4583 if (delegate_) |
| 4584 delegate_->RendererUnresponsive(this); | 4584 delegate_->RendererUnresponsive(this); |
| 4585 } | 4585 } |
| 4586 | 4586 |
| (...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5033 for (RenderViewHost* render_view_host : render_view_host_set) | 5033 for (RenderViewHost* render_view_host : render_view_host_set) |
| 5034 render_view_host->OnWebkitPreferencesChanged(); | 5034 render_view_host->OnWebkitPreferencesChanged(); |
| 5035 } | 5035 } |
| 5036 | 5036 |
| 5037 void WebContentsImpl::SetJavaScriptDialogManagerForTesting( | 5037 void WebContentsImpl::SetJavaScriptDialogManagerForTesting( |
| 5038 JavaScriptDialogManager* dialog_manager) { | 5038 JavaScriptDialogManager* dialog_manager) { |
| 5039 dialog_manager_ = dialog_manager; | 5039 dialog_manager_ = dialog_manager; |
| 5040 } | 5040 } |
| 5041 | 5041 |
| 5042 } // namespace content | 5042 } // namespace content |
| OLD | NEW |