Commit 33d84f98 authored by Dmitry Gozman's avatar Dmitry Gozman Committed by Commit Bot

[DevTools] Close created browser windows on shutdown

When we have created incognito profiles managed by DevToolsBrowserContextManager
and did not explicitly close them before shutdown, we keep these profiles and
their browser windows open. This leads to forceful renderer process terminations
and crash notifications shown to the user.

To fix this, we manually close all browser windows when original profile is gone.

Bug: none
Change-Id: I3befc91e6c8ed6ab7baf9b4af0ef92377bf38ad1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2001262Reviewed-by: default avatarAndrey Kosyakov <caseq@chromium.org>
Commit-Queue: Dmitry Gozman <dgozman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#732484}
parent d77e027c
......@@ -9,6 +9,7 @@
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/browser_window.h"
DevToolsBrowserContextManager::DevToolsBrowserContextManager() {}
......@@ -101,9 +102,17 @@ void DevToolsBrowserContextManager::DisposeBrowserContext(
void DevToolsBrowserContextManager::OnOriginalProfileDestroyed(
Profile* profile) {
base::EraseIf(registrations_, [&profile](const auto& it) {
return it.second->profile()->GetOriginalProfile() == profile;
});
// This is likely happening during shutdown. We'll immediately
// close all browser windows for our profile without unload handling.
BrowserList::BrowserVector browsers_to_close;
for (auto* browser : *BrowserList::GetInstance()) {
if (browser->profile() == profile)
browsers_to_close.push_back(browser);
}
for (auto* browser : browsers_to_close)
browser->window()->Close();
std::string context_id = profile->UniqueId();
registrations_.erase(context_id);
}
void DevToolsBrowserContextManager::OnBrowserRemoved(Browser* browser) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment