Commit 148f599b authored by Rohit Agarwal's avatar Rohit Agarwal Committed by Commit Bot

Enable |skip_beforeunload| for incognito dev_tools browser type.

Incognito window did not close after clicking on "exit incognito"
button for the first time, when a DevTools detached window was open.

The |skip_beforeunload| was set to true for incognito profile
types for faster exit. However, this resulted in devtools not
being informed the main window is closing.

The fix is to add BeforeUnloadhandlers checks in the incognito
mode if devtools windows are open.

Bug: 953217
Change-Id: I3bf0a0b3b4986faab639db073ae093fbcde8406d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1774635
Commit-Queue: Rohit Agarwal <roagarwal@chromium.org>
Reviewed-by: default avatarElly Fong-Jones <ellyjones@chromium.org>
Reviewed-by: default avatarRamin Halavati <rhalavati@chromium.org>
Cr-Commit-Position: refs/heads/master@{#693615}
parent 633cd1bc
...@@ -175,9 +175,17 @@ void BrowserList::CloseAllBrowsersWithIncognitoProfile( ...@@ -175,9 +175,17 @@ void BrowserList::CloseAllBrowsersWithIncognitoProfile(
const CloseCallback& on_close_aborted, const CloseCallback& on_close_aborted,
bool skip_beforeunload) { bool skip_beforeunload) {
DCHECK(profile->IsOffTheRecord()); DCHECK(profile->IsOffTheRecord());
TryToCloseBrowserList(GetIncognitoBrowsersToClose(profile), on_close_success, BrowserList::BrowserVector browsers_to_close =
on_close_aborted, profile->GetPath(), GetIncognitoBrowsersToClose(profile);
skip_beforeunload); auto it =
std::find_if(browsers_to_close.begin(), browsers_to_close.end(),
[](auto* browser) { return browser->is_type_devtools(); });
// When closing devtools browser related to incognito browser, do not skip
// calling before unload handlers.
skip_beforeunload = skip_beforeunload && (it == browsers_to_close.end());
TryToCloseBrowserList(browsers_to_close, on_close_success, on_close_aborted,
profile->GetPath(), skip_beforeunload);
} }
// static // static
......
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