Merge pull request #6489 from electron/webcontents-static-api
Document static methods on webContents
This commit is contained in:
commit
9eacd07eda
4 changed files with 223 additions and 118 deletions
|
@ -101,16 +101,17 @@ Object.defineProperties(exports, {
|
|||
return require('../tray')
|
||||
}
|
||||
},
|
||||
webContents: {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return require('../web-contents')
|
||||
}
|
||||
},
|
||||
|
||||
// The internal modules, invisible unless you know their names.
|
||||
NavigationController: {
|
||||
get: function () {
|
||||
return require('../navigation-controller')
|
||||
}
|
||||
},
|
||||
webContents: {
|
||||
get: function () {
|
||||
return require('../web-contents')
|
||||
}
|
||||
}
|
||||
})
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
const {EventEmitter} = require('events')
|
||||
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
|
||||
// before the webContents module.
|
||||
|
@ -249,7 +248,7 @@ module.exports = {
|
|||
|
||||
getFocusedWebContents () {
|
||||
let focused = null
|
||||
for (let contents of getAllWebContents()) {
|
||||
for (let contents of binding.getAllWebContents()) {
|
||||
if (!contents.isFocused()) continue
|
||||
if (focused == null) focused = contents
|
||||
// Return webview web contents which may be embedded inside another
|
||||
|
@ -257,5 +256,9 @@ module.exports = {
|
|||
if (contents.getType() === 'webview') return contents
|
||||
}
|
||||
return focused
|
||||
},
|
||||
|
||||
getAllWebContents () {
|
||||
return binding.getAllWebContents()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue