        override_bounds_(params.initial_bounds),
        initial_show_state_(params.initial_show_state),
        initial_workspace_(params.initial_workspace),
-@@ -852,12 +855,14 @@ bool Browser::TryToCloseWindow(
-     bool skip_beforeunload,
-     const base::RepeatingCallback<void(bool)>& on_close_confirmed) {
-   cancel_download_confirmation_state_ = RESPONSE_RECEIVED;
-+  close_multitab_confirmation_state_ = RESPONSE_RECEIVED;
-   return unload_controller_.TryToCloseWindow(skip_beforeunload,
-                                              on_close_confirmed);
- }
+@@ -828,7 +831,7 @@ Browser::WarnBeforeClosingResult Browser
+   // If the browser can close right away (there are no pending downloads we need
+   // to prompt about) then there's no need to warn. In the future, we might need
+   // to check other conditions as well.
+-  if (CanCloseWithInProgressDownloads())
++  if (CanCloseWithInProgressDownloads() && CanCloseWithMultipleTabs())
+     return WarnBeforeClosingResult::kOkToClose;
+ 
+   DCHECK(!warn_before_closing_callback_)
+@@ -858,6 +861,7 @@ bool Browser::TryToCloseWindow(
  
  void Browser::ResetTryToCloseWindow() {
    cancel_download_confirmation_state_ = NOT_PROMPTED;

   unload_controller_.ResetTryToCloseWindow();
 }
 
@@ -1741,6 +1746,13 @@ void Browser::BeforeUnloadFired(WebConte
   if (is_type_devtools() && DevToolsWindow::HandleBeforeUnload(
                                 web_contents, proceed, proceed_to_fire_unload))
     return;
+  if (proceed &&
+      (IsAttemptingToCloseBrowser() || this->tab_strip_model()->count() <= 1) &&
+      !CanCloseWithMultipleTabs()) {
+    proceed = false;
+    warn_before_closing_callback_ = base::BindOnce(
+        &Browser::FinishWarnBeforeClosing, weak_factory_.GetWeakPtr());
+  }
 
   *proceed_to_fire_unload =
       unload_controller_.BeforeUnloadFired(web_contents, proceed);
@@ -2696,6 +2708,59 @@ bool Browser::CanCloseWithInProgressDown
   return false;
 }
 

+  if (show_confirmation_last_window) {
+    if (total_window_count >= 1 || this->tab_strip_model()->count() <= 1)
+      return true;
+  } else {
+    if (total_window_count == 0 && this->tab_strip_model()->count() <= 1) 
+      return true;
+    if (this->tab_strip_model()->count() == 0)
+      tab_strip_model_delegate_->AddTabAt(GURL(), -1, true);
+  }
+
+  close_multitab_confirmation_state_ = WAITING_FOR_RESPONSE;
