Index: chrome/browser/ui/browser.cc |
diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc |
index 2056b53aa9aa3ad4c4a564706690a838d6fa7325..410194c876efed43998f1cbb5a3adcedd684f1f7 100644 |
--- a/chrome/browser/ui/browser.cc |
+++ b/chrome/browser/ui/browser.cc |
@@ -849,6 +849,13 @@ void Browser::UpdateDownloadShelfVisibility(bool visible) { |
// static |
bool Browser::RunUnloadEventsHelper(WebContents* contents) { |
+ // If there's a devtools window attached to the web contents, |
+ // then we would like to run its beforeunload handlers first. |
+ DevToolsWindow* dev_tools_window = |
+ DevToolsWindow::GetInstanceForInspectedTab(contents); |
+ if (dev_tools_window && dev_tools_window->InspectedPageWillClose()) { |
+ return true; |
+ } |
// If the WebContents is not connected yet, then there's no unload |
// handler we can fire even if the WebContents has an unload listener. |
// One case where we hit this is in a tab that has an infinite loop |
@@ -1446,6 +1453,16 @@ gfx::Rect Browser::GetRootWindowResizerRect() const { |
void Browser::BeforeUnloadFired(WebContents* web_contents, |
bool proceed, |
bool* proceed_to_fire_unload) { |
+ if (is_devtools()) { |
+ DevToolsWindow::HandleBeforeUnload(web_contents, |
+ proceed, proceed_to_fire_unload); |
+ return; |
+ } |
+ DevToolsWindow* dev_tools_window = |
+ DevToolsWindow::GetInstanceForInspectedTab(web_contents); |
+ if (dev_tools_window && !proceed) |
+ dev_tools_window->InspectedPageCancelClose(); |
+ |
if (IsFastTabUnloadEnabled()) { |
*proceed_to_fire_unload = |
fast_unload_controller_->BeforeUnloadFired(web_contents, proceed); |