  void Browser::InProgressDownloadResponse(bool cancel_downloads) {
    if (cancel_downloads) {
      cancel_download_confirmation_state_ = RESPONSE_RECEIVED;
-@@ -2714,6 +2775,22 @@ void Browser::InProgressDownloadResponse
+@@ -2714,6 +2779,22 @@ void Browser::InProgressDownloadResponse
  
    std::move(warn_before_closing_callback_)
        .Run(WarnBeforeClosingResult::kDoNotClose);

   unload_controller_.ResetTryToCloseWindow();
 }
 
@@ -2696,6 +2701,62 @@ bool Browser::CanCloseWithInProgressDown
   return false;
 }
 

+  // If we're not running a full browser process with a profile manager
+  // (testing), it's ok to close the browser.
+  if (!g_browser_process->profile_manager())
+    return true;
+
+  // Figure out how many windows are open total
