WebUI tab strip: fix crash when the dragging WebContents closes itself
during drag session
When WebUI tab strip is enabled, it's possible the dragging tab is
closed during a drag session. This CL prevents this scenario leading to
a crash.
Bug: 1286203
Change-Id: I800da37146058c5a01c7bb92eb8331a8ddc4d5c9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3539212
Commit-Queue: Yuheng Huang <yuhengh@chromium.org>
Reviewed-by: Mitsuru Oshima <oshima@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1002699}
diff --git a/ash/drag_drop/tab_drag_drop_delegate.cc b/ash/drag_drop/tab_drag_drop_delegate.cc
index ad06a46..9b00c7b 100644
--- a/ash/drag_drop/tab_drag_drop_delegate.cc
+++ b/ash/drag_drop/tab_drag_drop_delegate.cc
@@ -167,16 +167,20 @@
const gfx::Point& location_in_screen,
aura::Window* new_window) {
auto is_lacros = IsLacrosWindow(source_window_);
- if (!new_window && is_lacros &&
- !crosapi::lacros_startup_state::IsLacrosPrimaryEnabled()) {
- LOG(ERROR)
- << "New browser window creation for tab detaching failed.\n"
- << "Check whether about:flags#lacros-primary is enabled or "
- << "--enable-features=LacrosPrimary is passed in when launching Ash";
+
+ // https://crbug.com/1286203:
+ // It's possible new window is created when the dragged WebContents
+ // closes itself during the drag session.
+ if (!new_window) {
+ if (is_lacros && !crosapi::lacros_startup_state::IsLacrosPrimaryEnabled()) {
+ LOG(ERROR)
+ << "New browser window creation for tab detaching failed.\n"
+ << "Check whether about:flags#lacros-primary is enabled or "
+ << "--enable-features=LacrosPrimary is passed in when launching Ash";
+ }
return;
}
- DCHECK(new_window) << "New browser window creation for tab detaching failed.";
const gfx::Rect area =
screen_util::GetDisplayWorkAreaBoundsInScreenForActiveDeskContainer(
root_window_);