Expose getAllWebContents() API
This commit is contained in:
parent
ba887dbde7
commit
a7badd43d5
1 changed files with 5 additions and 2 deletions
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
const {EventEmitter} = require('events')
|
const {EventEmitter} = require('events')
|
||||||
const {app, ipcMain, session, Menu, NavigationController} = require('electron')
|
const {app, ipcMain, session, Menu, NavigationController} = require('electron')
|
||||||
const {getAllWebContents} = process.atomBinding('web_contents')
|
|
||||||
|
|
||||||
// session is not used here, the purpose is to make sure session is initalized
|
// session is not used here, the purpose is to make sure session is initalized
|
||||||
// before the webContents module.
|
// before the webContents module.
|
||||||
|
@ -249,7 +248,7 @@ module.exports = {
|
||||||
|
|
||||||
getFocusedWebContents () {
|
getFocusedWebContents () {
|
||||||
let focused = null
|
let focused = null
|
||||||
for (let contents of getAllWebContents()) {
|
for (let contents of binding.getAllWebContents()) {
|
||||||
if (!contents.isFocused()) continue
|
if (!contents.isFocused()) continue
|
||||||
if (focused == null) focused = contents
|
if (focused == null) focused = contents
|
||||||
// Return webview web contents which may be embedded inside another
|
// Return webview web contents which may be embedded inside another
|
||||||
|
@ -257,5 +256,9 @@ module.exports = {
|
||||||
if (contents.getType() === 'webview') return contents
|
if (contents.getType() === 'webview') return contents
|
||||||
}
|
}
|
||||||
return focused
|
return focused
|
||||||
|
},
|
||||||
|
|
||||||
|
getAllWebContents () {
|
||||||
|
return binding.getAllWebContents()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue