From 67a9931b5554501bf5d1021eba7dd7c6e1089cc4 Mon Sep 17 00:00:00 2001 From: deepak1556 Date: Mon, 1 Jun 2015 17:23:44 +0530 Subject: [PATCH] devtools: initialise devtoolsWebContents when opened with inspect* apis --- atom/browser/api/atom_api_window.cc | 4 ++-- atom/browser/api/lib/browser-window.coffee | 8 ++++++++ atom/browser/native_window.cc | 2 -- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/atom/browser/api/atom_api_window.cc b/atom/browser/api/atom_api_window.cc index fb2562e0e07..a016c16da01 100644 --- a/atom/browser/api/atom_api_window.cc +++ b/atom/browser/api/atom_api_window.cc @@ -527,7 +527,7 @@ void Window::BuildPrototype(v8::Isolate* isolate, .SetMethod("_openDevTools", &Window::OpenDevTools) .SetMethod("closeDevTools", &Window::CloseDevTools) .SetMethod("isDevToolsOpened", &Window::IsDevToolsOpened) - .SetMethod("inspectElement", &Window::InspectElement) + .SetMethod("_inspectElement", &Window::InspectElement) .SetMethod("focusOnWebView", &Window::FocusOnWebView) .SetMethod("blurWebView", &Window::BlurWebView) .SetMethod("isWebViewFocused", &Window::IsWebViewFocused) @@ -549,7 +549,7 @@ void Window::BuildPrototype(v8::Isolate* isolate, #endif .SetMethod("_getWebContents", &Window::GetWebContents) .SetMethod("_getDevToolsWebContents", &Window::GetDevToolsWebContents) - .SetMethod("inspectServiceWorker", &Window::InspectServiceWorker); + .SetMethod("_inspectServiceWorker", &Window::InspectServiceWorker); } } // namespace api diff --git a/atom/browser/api/lib/browser-window.coffee b/atom/browser/api/lib/browser-window.coffee index 93e74423388..803fb9207c4 100644 --- a/atom/browser/api/lib/browser-window.coffee +++ b/atom/browser/api/lib/browser-window.coffee @@ -55,6 +55,14 @@ BrowserWindow::openDevTools = (options={}) -> BrowserWindow::toggleDevTools = -> if @isDevToolsOpened() then @closeDevTools() else @openDevTools() +BrowserWindow::inspectElement = (x, y) -> + @openDevTools true + @_inspectElement x, y + +BrowserWindow::inspectServiceWorker = -> + @openDevTools true + @_inspectServiceWorker() + BrowserWindow::getWebContents = -> wrapWebContents @_getWebContents() diff --git a/atom/browser/native_window.cc b/atom/browser/native_window.cc index 7fb0de34447..ab6b08e8d4a 100644 --- a/atom/browser/native_window.cc +++ b/atom/browser/native_window.cc @@ -308,7 +308,6 @@ bool NativeWindow::IsDevToolsOpened() { } void NativeWindow::InspectElement(int x, int y) { - OpenDevTools(true); scoped_refptr agent( content::DevToolsAgentHost::GetOrCreateFor(GetWebContents())); agent->InspectElement(x, y); @@ -318,7 +317,6 @@ void NativeWindow::InspectServiceWorker() { for (const auto& agent_host : content::DevToolsAgentHost::GetOrCreateAll()) { if (agent_host->GetType() == content::DevToolsAgentHost::TYPE_SERVICE_WORKER) { - OpenDevTools(true); inspectable_web_contents()->AttachTo(agent_host); break; }