Index: chrome/browser/ui/unload_controller.cc |
diff --git a/chrome/browser/ui/unload_controller.cc b/chrome/browser/ui/unload_controller.cc |
index fab4eb76d245679c9559e4763ceeb6c1f03b3ca6..8791f7056ebab71a2aa608d4d66f070b0be60a79 100644 |
--- a/chrome/browser/ui/unload_controller.cc |
+++ b/chrome/browser/ui/unload_controller.cc |
@@ -300,7 +300,13 @@ void UnloadController::ProcessPendingTabs() { |
ClearUnloadState(web_contents, true); |
} |
} else if (is_calling_before_unload_handlers()) { |
- on_close_confirmed_.Run(true); |
+ base::Callback<void(bool)> on_close_confirmed = on_close_confirmed_; |
+ // Reset |on_close_confirmed_| in case the callback tests |
+ // |is_calling_before_unload_handlers()|, we want to return that calling |
+ // is complete. |
+ if (tabs_needing_unload_fired_.empty()) |
+ on_close_confirmed_.Reset(); |
+ on_close_confirmed.Run(true); |
} else if (!tabs_needing_unload_fired_.empty()) { |
// We've finished firing all beforeunload events and can proceed with unload |
// events. |