diff --git a/atom/browser/api/atom_api_window.cc b/atom/browser/api/atom_api_window.cc index ce9f584f74a..d3b1c5f8511 100644 --- a/atom/browser/api/atom_api_window.cc +++ b/atom/browser/api/atom_api_window.cc @@ -322,8 +322,8 @@ bool Window::IsKiosk() { return window_->IsKiosk(); } -void Window::OpenDevTools() { - window_->OpenDevTools(); +void Window::OpenDevTools(bool dock) { + window_->OpenDevTools(!dock); } void Window::CloseDevTools() { diff --git a/atom/browser/api/atom_api_window.h b/atom/browser/api/atom_api_window.h index b6805c83d89..1b2c43d701d 100644 --- a/atom/browser/api/atom_api_window.h +++ b/atom/browser/api/atom_api_window.h @@ -105,7 +105,7 @@ class Window : public mate::EventEmitter, void SetSkipTaskbar(bool skip); void SetKiosk(bool kiosk); bool IsKiosk(); - void OpenDevTools(); + void OpenDevTools(bool dock); void CloseDevTools(); bool IsDevToolsOpened(); void InspectElement(int x, int y); diff --git a/atom/browser/api/lib/browser-window.coffee b/atom/browser/api/lib/browser-window.coffee index 9c8e5a914f3..2892746e1e2 100644 --- a/atom/browser/api/lib/browser-window.coffee +++ b/atom/browser/api/lib/browser-window.coffee @@ -40,8 +40,9 @@ BrowserWindow::_init = -> @once 'closed', => BrowserWindow.windows.remove @id if BrowserWindow.windows.has @id -BrowserWindow::openDevTools = -> - @_openDevTools() +BrowserWindow::openDevTools = (options={}) -> + options.detach ?= false + @_openDevTools(options.detach) # Force devToolsWebContents to be created. @devToolsWebContents = @getDevToolsWebContents() diff --git a/atom/browser/native_window.cc b/atom/browser/native_window.cc index b01c9a4d4ed..9384ffb0696 100644 --- a/atom/browser/native_window.cc +++ b/atom/browser/native_window.cc @@ -284,7 +284,9 @@ bool NativeWindow::HasModalDialog() { return has_dialog_attached_; } -void NativeWindow::OpenDevTools() { +void NativeWindow::OpenDevTools(bool dock) { + if (!dock) + inspectable_web_contents()->SetCanDock(false); inspectable_web_contents()->ShowDevTools(); } @@ -297,7 +299,7 @@ bool NativeWindow::IsDevToolsOpened() { } void NativeWindow::InspectElement(int x, int y) { - OpenDevTools(); + OpenDevTools(true); scoped_refptr agent( content::DevToolsAgentHost::GetOrCreateFor(GetWebContents())); agent->InspectElement(x, y); diff --git a/atom/browser/native_window.h b/atom/browser/native_window.h index 2495259d82d..f229bba7831 100644 --- a/atom/browser/native_window.h +++ b/atom/browser/native_window.h @@ -146,7 +146,7 @@ class NativeWindow : public brightray::DefaultWebContentsDelegate, const std::string& description) = 0; virtual bool IsClosed() const { return is_closed_; } - virtual void OpenDevTools(); + virtual void OpenDevTools(bool dock); virtual void CloseDevTools(); virtual bool IsDevToolsOpened(); virtual void InspectElement(int x, int y); diff --git a/atom/browser/native_window_mac.mm b/atom/browser/native_window_mac.mm index 6c3a4e26841..8703a648704 100644 --- a/atom/browser/native_window_mac.mm +++ b/atom/browser/native_window_mac.mm @@ -190,7 +190,7 @@ static const CGFloat kAtomWindowCornerRadius = 4.0; } - (IBAction)showDevTools:(id)sender { - shell_->OpenDevTools(); + shell_->OpenDevTools(true); } // Returns an empty array for AXChildren attribute, this will force the diff --git a/docs/api/browser-window.md b/docs/api/browser-window.md index 938c07f352e..3b4ca60ce6f 100644 --- a/docs/api/browser-window.md +++ b/docs/api/browser-window.md @@ -457,7 +457,10 @@ Whether the window's document has been edited. __Note__: This API is available only on OS X. -### BrowserWindow.openDevTools() +### BrowserWindow.openDevTools([options]) + +* `options` Object + * `detach` Boolean - opens devtools in a new window Opens the developer tools.