🐛 add isDevToolsFocused to WebContents to fix #3928, add devtools-[focused|open|close] events to WebView to fix #3783.

This commit is contained in:
leethomas 2015-12-31 21:11:21 -08:00
parent 8aced2c31e
commit 96d68b9285
5 changed files with 16 additions and 0 deletions

View file

@ -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",

View file

@ -79,6 +79,7 @@ class WebContents : public mate::TrackableObject<WebContents>,
void OpenDevTools(mate::Arguments* args);
void CloseDevTools();
bool IsDevToolsOpened();
bool IsDevToolsFocused();
void ToggleDevTools();
void EnableDeviceEmulation(const blink::WebDeviceEmulationParams& params);
void DisableDeviceEmulation();

View file

@ -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()

View file

@ -13,6 +13,9 @@ supportedWebViewEvents = [
'did-get-redirect-request'
'dom-ready'
'console-message'
'devtools-opened'
'devtools-closed'
'devtools-focused'
'new-window'
'close'
'crashed'

View file

@ -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': []