mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
Allow using docked devtools for webview
This commit is contained in:
@@ -895,10 +895,10 @@ void WebContents::DevToolsOpened() {
|
||||
managed_web_contents()->CallClientFunction(
|
||||
"DevToolsAPI.setInspectedTabId", &tab_id, nullptr, nullptr);
|
||||
|
||||
// Inherit owner window in devtools.
|
||||
// Inherit owner window in devtools when it doesn't have one.
|
||||
auto* devtools = managed_web_contents()->GetDevToolsWebContents();
|
||||
if (owner_window() &&
|
||||
!devtools->GetUserData(NativeWindowRelay::UserDataKey()))
|
||||
bool has_window = devtools->GetUserData(NativeWindowRelay::UserDataKey());
|
||||
if (owner_window() && !has_window)
|
||||
handle->SetOwnerWindow(devtools, owner_window());
|
||||
|
||||
Emit("devtools-opened");
|
||||
@@ -1179,7 +1179,8 @@ void WebContents::OpenDevTools(mate::Arguments* args) {
|
||||
std::string state;
|
||||
if (type_ == WEB_VIEW || !owner_window()) {
|
||||
state = "detach";
|
||||
} else if (args && args->Length() == 1) {
|
||||
}
|
||||
if (args && args->Length() == 1) {
|
||||
bool detach = false;
|
||||
mate::Dictionary options;
|
||||
if (args->GetNext(&options)) {
|
||||
|
||||
@@ -1144,6 +1144,9 @@ app.once('ready', () => {
|
||||
|
||||
Opens the devtools.
|
||||
|
||||
When `contents` is a `<webview>` tag, the `mode` would be `detach` by default,
|
||||
explicitly passing an empty `mode` can force using last used dock state.
|
||||
|
||||
#### `contents.closeDevTools()`
|
||||
|
||||
Closes the devtools.
|
||||
|
||||
Reference in New Issue
Block a user