Load dev tools extensions in webviews
This commit is contained in:
parent
19787544b5
commit
4f46f75d8f
2 changed files with 15 additions and 5 deletions
|
@ -81,8 +81,8 @@ const removeBackgroundPages = function (manifest) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dispatch tabs events.
|
// Dispatch tabs events.
|
||||||
const hookWindowForTabEvents = function (win) {
|
const hookWindowForTabEvents = function (win, webContents) {
|
||||||
const tabId = win.webContents.id
|
const tabId = webContents.id
|
||||||
for (const page of objectValues(backgroundPages)) {
|
for (const page of objectValues(backgroundPages)) {
|
||||||
page.webContents.sendToAll('CHROME_TABS_ONCREATED', tabId)
|
page.webContents.sendToAll('CHROME_TABS_ONCREATED', tabId)
|
||||||
}
|
}
|
||||||
|
@ -301,6 +301,7 @@ app.once('ready', function () {
|
||||||
return manifest.name
|
return manifest.name
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BrowserWindow.removeDevToolsExtension = function (name) {
|
BrowserWindow.removeDevToolsExtension = function (name) {
|
||||||
const manifest = manifestNameMap[name]
|
const manifest = manifestNameMap[name]
|
||||||
if (!manifest) return
|
if (!manifest) return
|
||||||
|
@ -315,9 +316,13 @@ app.once('ready', function () {
|
||||||
const init = BrowserWindow.prototype._init
|
const init = BrowserWindow.prototype._init
|
||||||
BrowserWindow.prototype._init = function () {
|
BrowserWindow.prototype._init = function () {
|
||||||
init.call(this)
|
init.call(this)
|
||||||
hookWindowForTabEvents(this)
|
this._loadDevToolsExtensions(this.webContents)
|
||||||
this.webContents.on('devtools-opened', () => {
|
}
|
||||||
loadDevToolsExtensions(this, objectValues(manifestMap))
|
|
||||||
|
BrowserWindow.prototype._loadDevToolsExtensions = function (webContents) {
|
||||||
|
hookWindowForTabEvents(this, webContents)
|
||||||
|
webContents.on('devtools-opened', function () {
|
||||||
|
loadDevToolsExtensions(webContents, objectValues(manifestMap))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
'use strict'
|
'use strict'
|
||||||
|
|
||||||
|
const BrowserWindow = require('electron').BrowserWindow
|
||||||
const ipcMain = require('electron').ipcMain
|
const ipcMain = require('electron').ipcMain
|
||||||
const webContents = require('electron').webContents
|
const webContents = require('electron').webContents
|
||||||
|
|
||||||
|
@ -150,6 +151,10 @@ const createGuest = function (embedder, params) {
|
||||||
embedder.send.apply(embedder, ['ELECTRON_GUEST_VIEW_INTERNAL_SIZE_CHANGED-' + guest.viewInstanceId].concat(args))
|
embedder.send.apply(embedder, ['ELECTRON_GUEST_VIEW_INTERNAL_SIZE_CHANGED-' + guest.viewInstanceId].concat(args))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// Enable DevTools extensions in guest view
|
||||||
|
const window = BrowserWindow.fromWebContents(embedder)
|
||||||
|
if (window) window._loadDevToolsExtensions(guest)
|
||||||
|
|
||||||
return id
|
return id
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue