Index: chrome/browser/lifetime/browser_close_manager.cc |
diff --git a/chrome/browser/lifetime/browser_close_manager.cc b/chrome/browser/lifetime/browser_close_manager.cc |
index d8a943c1ab55a4172d9b0c66e9a8de2909183c1c..484a1f3bf0a4cc5dee0e90797e7bd4694e84b924 100644 |
--- a/chrome/browser/lifetime/browser_close_manager.cc |
+++ b/chrome/browser/lifetime/browser_close_manager.cc |
@@ -72,13 +72,16 @@ void BrowserCloseManager::TryToCloseBrowsers() { |
// OnBrowserReportCloseable with the result. If the user confirms the close, |
// this will trigger TryToCloseBrowsers to try again. |
for (auto* browser : *BrowserList::GetInstance()) { |
+ // Set current_browser_ here since if there are no unload handlers, it might |
+ // get used synchronously inside TryToCloseWindow. |
+ current_browser_ = browser; |
if (browser->TryToCloseWindow( |
false, |
base::Bind(&BrowserCloseManager::OnBrowserReportCloseable, this))) { |
- current_browser_ = browser; |
return; |
} |
} |
+ current_browser_ = NULL; |
CheckForDownloadsInProgress(); |
} |