diff --git a/browser/api/atom_api_window.cc b/browser/api/atom_api_window.cc index d5b6296831..f502425749 100644 --- a/browser/api/atom_api_window.cc +++ b/browser/api/atom_api_window.cc @@ -414,6 +414,12 @@ void Window::InspectElement(const v8::FunctionCallbackInfo& args) { self->window_->InspectElement(x, y); } +// static +void Window::DebugDevTools(const v8::FunctionCallbackInfo& args) { + UNWRAP_WINDOW_AND_CHECK; + self->window_->DebugDevTools(); +} + // static void Window::FocusOnWebView(const v8::FunctionCallbackInfo& args) { UNWRAP_WINDOW_AND_CHECK; @@ -663,6 +669,7 @@ void Window::Initialize(v8::Handle target) { NODE_SET_PROTOTYPE_METHOD(t, "closeDevTools", CloseDevTools); NODE_SET_PROTOTYPE_METHOD(t, "isDevToolsOpened", IsDevToolsOpened); NODE_SET_PROTOTYPE_METHOD(t, "inspectElement", InspectElement); + NODE_SET_PROTOTYPE_METHOD(t, "debugDevTools", DebugDevTools); NODE_SET_PROTOTYPE_METHOD(t, "focusOnWebView", FocusOnWebView); NODE_SET_PROTOTYPE_METHOD(t, "blurWebView", BlurWebView); NODE_SET_PROTOTYPE_METHOD(t, "isWebViewFocused", IsWebViewFocused); diff --git a/browser/api/atom_api_window.h b/browser/api/atom_api_window.h index 1526e4802a..d53affaa7f 100644 --- a/browser/api/atom_api_window.h +++ b/browser/api/atom_api_window.h @@ -86,6 +86,7 @@ class Window : public EventEmitter, static void CloseDevTools(const v8::FunctionCallbackInfo& args); static void IsDevToolsOpened(const v8::FunctionCallbackInfo& args); static void InspectElement(const v8::FunctionCallbackInfo& args); + static void DebugDevTools(const v8::FunctionCallbackInfo& args); static void FocusOnWebView(const v8::FunctionCallbackInfo& args); static void BlurWebView(const v8::FunctionCallbackInfo& args); static void IsWebViewFocused(const v8::FunctionCallbackInfo& args); diff --git a/browser/native_window.cc b/browser/native_window.cc index 603c9db1dd..3afdea5458 100644 --- a/browser/native_window.cc +++ b/browser/native_window.cc @@ -167,8 +167,6 @@ bool NativeWindow::HasModalDialog() { void NativeWindow::OpenDevTools() { inspectable_web_contents()->ShowDevTools(); - - DebugDevTools(); } void NativeWindow::CloseDevTools() { @@ -187,14 +185,16 @@ void NativeWindow::InspectElement(int x, int y) { agent->InspectElement(x, y); } -void NativeWindow::DebugDevTools() { - if (!IsDevToolsOpened()) - return; +scoped_ptr NativeWindow::DebugDevTools() { + scoped_ptr window; + if (IsDevToolsOpened()) { + base::DictionaryValue options; + window.reset(NativeWindow::Create(&options)); + window->devtools_delegate_.reset(new DevToolsDelegate( + window.get(), GetDevToolsWebContents())); + } - base::DictionaryValue options; - NativeWindow* window = NativeWindow::Create(&options); - window->devtools_delegate_.reset(new DevToolsDelegate( - window, GetDevToolsWebContents())); + return window.Pass(); } void NativeWindow::FocusOnWebView() { diff --git a/browser/native_window.h b/browser/native_window.h index 14268ccbd8..d17f41df84 100644 --- a/browser/native_window.h +++ b/browser/native_window.h @@ -128,7 +128,9 @@ class NativeWindow : public brightray::DefaultWebContentsDelegate, virtual void CloseDevTools(); virtual bool IsDevToolsOpened(); virtual void InspectElement(int x, int y); - virtual void DebugDevTools(); + + // Creates a new window to debug the devtools. + virtual scoped_ptr DebugDevTools(); virtual void FocusOnWebView(); virtual void BlurWebView();