diff --git a/atom/browser/api/atom_api_web_contents.cc b/atom/browser/api/atom_api_web_contents.cc index 461a66c4b2f1..08f159c34723 100644 --- a/atom/browser/api/atom_api_web_contents.cc +++ b/atom/browser/api/atom_api_web_contents.cc @@ -780,6 +780,13 @@ bool WebContents::IsDevToolsOpened() { return managed_web_contents()->IsDevToolsViewShowing(); } +bool WebContents::IsDevToolsFocused() { + if (type_ == REMOTE) + return false; + + return managed_web_contents()->GetView()->IsDevToolsViewFocused(); +} + void WebContents::EnableDeviceEmulation( const blink::WebDeviceEmulationParams& params) { if (type_ == REMOTE) @@ -1080,6 +1087,7 @@ void WebContents::BuildPrototype(v8::Isolate* isolate, .SetMethod("openDevTools", &WebContents::OpenDevTools) .SetMethod("closeDevTools", &WebContents::CloseDevTools) .SetMethod("isDevToolsOpened", &WebContents::IsDevToolsOpened) + .SetMethod("isDevToolsFocused", &WebContents::IsDevToolsFocused) .SetMethod("enableDeviceEmulation", &WebContents::EnableDeviceEmulation) .SetMethod("disableDeviceEmulation", diff --git a/atom/browser/api/atom_api_web_contents.h b/atom/browser/api/atom_api_web_contents.h index 52a244eb896f..bd7149e38a93 100644 --- a/atom/browser/api/atom_api_web_contents.h +++ b/atom/browser/api/atom_api_web_contents.h @@ -79,6 +79,7 @@ class WebContents : public mate::TrackableObject, void OpenDevTools(mate::Arguments* args); void CloseDevTools(); bool IsDevToolsOpened(); + bool IsDevToolsFocused(); void ToggleDevTools(); void EnableDeviceEmulation(const blink::WebDeviceEmulationParams& params); void DisableDeviceEmulation(); diff --git a/atom/browser/api/lib/browser-window.coffee b/atom/browser/api/lib/browser-window.coffee index 07b4191d7c7b..92a230ba45af 100644 --- a/atom/browser/api/lib/browser-window.coffee +++ b/atom/browser/api/lib/browser-window.coffee @@ -83,6 +83,7 @@ BrowserWindow::send = -> @webContents.send.apply @webContents, arguments BrowserWindow::openDevTools = -> @webContents.openDevTools.apply @webContents, arguments BrowserWindow::closeDevTools = -> @webContents.closeDevTools() BrowserWindow::isDevToolsOpened = -> @webContents.isDevToolsOpened() +BrowserWindow::isDevToolsFocused = -> @webContents.isDevToolsFocused() BrowserWindow::toggleDevTools = -> @webContents.toggleDevTools() BrowserWindow::inspectElement = -> @webContents.inspectElement.apply @webContents, arguments BrowserWindow::inspectServiceWorker = -> @webContents.inspectServiceWorker() diff --git a/atom/browser/lib/guest-view-manager.coffee b/atom/browser/lib/guest-view-manager.coffee index b0ba82eef3cb..83ad70676988 100644 --- a/atom/browser/lib/guest-view-manager.coffee +++ b/atom/browser/lib/guest-view-manager.coffee @@ -13,6 +13,9 @@ supportedWebViewEvents = [ 'did-get-redirect-request' 'dom-ready' 'console-message' + 'devtools-opened' + 'devtools-closed' + 'devtools-focused' 'new-window' 'close' 'crashed' diff --git a/atom/renderer/lib/web-view/guest-view-internal.coffee b/atom/renderer/lib/web-view/guest-view-internal.coffee index 55e0c49a1aae..76037971198f 100644 --- a/atom/renderer/lib/web-view/guest-view-internal.coffee +++ b/atom/renderer/lib/web-view/guest-view-internal.coffee @@ -15,6 +15,9 @@ WEB_VIEW_EVENTS = 'did-get-redirect-request': ['oldURL', 'newURL', 'isMainFrame'] 'dom-ready': [] 'console-message': ['level', 'message', 'line', 'sourceId'] + 'devtools-opened': [] + 'devtools-closed': [] + 'devtools-focused': [] 'new-window': ['url', 'frameName', 'disposition', 'options'] 'close': [] 'crashed': []