diff --git a/docs/api/web-contents.md b/docs/api/web-contents.md index bdfa225332567..5eaf7359e2649 100644 --- a/docs/api/web-contents.md +++ b/docs/api/web-contents.md @@ -1635,6 +1635,8 @@ Opens the devtools. When `contents` is a `` tag, the `mode` would be `detach` by default, explicitly passing an empty `mode` can force using last used dock state. +On Windows, if Windows Control Overlay is enabled, Devtools will be opened with `mode: 'detach'`. + #### `contents.closeDevTools()` Closes the devtools. diff --git a/shell/browser/api/electron_api_web_contents.cc b/shell/browser/api/electron_api_web_contents.cc index 32167a4935d8c..d2f184649258f 100644 --- a/shell/browser/api/electron_api_web_contents.cc +++ b/shell/browser/api/electron_api_web_contents.cc @@ -173,6 +173,7 @@ #if BUILDFLAG(IS_WIN) #include "printing/backend/win_helper.h" +#include "shell/browser/native_window_views.h" #endif #endif @@ -2420,6 +2421,14 @@ void WebContents::OpenDevTools(gin::Arguments* args) { } } +#if BUILDFLAG(IS_WIN) + auto* win = static_cast(owner_window()); + // Force a detached state when WCO is enabled to match Chrome + // behavior and prevent occlusion of DevTools. + if (win && win->IsWindowControlsOverlayEnabled()) + state = "detach"; +#endif + DCHECK(inspectable_web_contents_); inspectable_web_contents_->SetDockState(state); inspectable_web_contents_->ShowDevTools(activate);