[lacros][webui] Do not DCHECK on tab-drop when LacrosPrimary is disabled
This relaxes the current behavior, by not hitting a DCHECK.
BUG=1236708,1260343
R=oshima@chromium.org
Change-Id: I159db47af92f4a9dce707fafdae3b23c431b4289
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3368343
Reviewed-by: Mitsuru Oshima <oshima@chromium.org>
Commit-Queue: Antonio Gomes <tonikitoo@igalia.com>
Cr-Commit-Position: refs/heads/main@{#957228}
diff --git a/ash/drag_drop/tab_drag_drop_delegate.cc b/ash/drag_drop/tab_drag_drop_delegate.cc
index 72a4399a..a8ea436 100644
--- a/ash/drag_drop/tab_drag_drop_delegate.cc
+++ b/ash/drag_drop/tab_drag_drop_delegate.cc
@@ -4,6 +4,7 @@
#include "ash/drag_drop/tab_drag_drop_delegate.h"
+#include "ash/constants/app_types.h"
#include "ash/constants/ash_features.h"
#include "ash/public/cpp/new_window_delegate.h"
#include "ash/public/cpp/presentation_time_recorder.h"
@@ -18,6 +19,8 @@
#include "ash/wm/tablet_mode/tablet_mode_browser_window_drag_session_windows_hider.h"
#include "base/pickle.h"
#include "base/strings/utf_string_conversions.h"
+#include "chromeos/crosapi/cpp/lacros_startup_state.h"
+#include "ui/aura/client/aura_constants.h"
#include "ui/base/clipboard/clipboard_format_type.h"
#include "ui/base/clipboard/custom_data_helper.h"
#include "ui/base/dragdrop/os_exchange_data.h"
@@ -57,6 +60,12 @@
DEFINE_UI_CLASS_PROPERTY_KEY(bool, kIsSourceWindowForDrag, false)
+bool IsLacrosWindow(const aura::Window* window) {
+ auto app_type =
+ static_cast<AppType>(window->GetProperty(aura::client::kAppType));
+ return app_type == AppType::LACROS;
+}
+
} // namespace
// static
@@ -143,8 +152,17 @@
void TabDragDropDelegate::OnNewBrowserWindowCreated(
const gfx::Point& location_in_screen,
aura::Window* new_window) {
- DCHECK(new_window) << "New browser window creation for tab detaching failed.";
+ 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";
+ return;
+ }
+ DCHECK(new_window) << "New browser window creation for tab detaching failed.";
const gfx::Rect area =
screen_util::GetDisplayWorkAreaBoundsInScreenForActiveDeskContainer(
root_window_);