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.
|
||||
const hookWindowForTabEvents = function (win) {
|
||||
const tabId = win.webContents.id
|
||||
const hookWindowForTabEvents = function (win, webContents) {
|
||||
const tabId = webContents.id
|
||||
for (const page of objectValues(backgroundPages)) {
|
||||
page.webContents.sendToAll('CHROME_TABS_ONCREATED', tabId)
|
||||
}
|
||||
|
@ -301,6 +301,7 @@ app.once('ready', function () {
|
|||
return manifest.name
|
||||
}
|
||||
}
|
||||
|
||||
BrowserWindow.removeDevToolsExtension = function (name) {
|
||||
const manifest = manifestNameMap[name]
|
||||
if (!manifest) return
|
||||
|
@ -315,9 +316,13 @@ app.once('ready', function () {
|
|||
const init = BrowserWindow.prototype._init
|
||||
BrowserWindow.prototype._init = function () {
|
||||
init.call(this)
|
||||
hookWindowForTabEvents(this)
|
||||
this.webContents.on('devtools-opened', () => {
|
||||
loadDevToolsExtensions(this, objectValues(manifestMap))
|
||||
this._loadDevToolsExtensions(this.webContents)
|
||||
}
|
||||
|
||||
BrowserWindow.prototype._loadDevToolsExtensions = function (webContents) {
|
||||
hookWindowForTabEvents(this, webContents)
|
||||
webContents.on('devtools-opened', function () {
|
||||
loadDevToolsExtensions(webContents, objectValues(manifestMap))
|
||||
})
|
||||
}
|
||||
})
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
'use strict'
|
||||
|
||||
const BrowserWindow = require('electron').BrowserWindow
|
||||
const ipcMain = require('electron').ipcMain
|
||||
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))
|
||||
})
|
||||
|
||||
// Enable DevTools extensions in guest view
|
||||
const window = BrowserWindow.fromWebContents(embedder)
|
||||
if (window) window._loadDevToolsExtensions(guest)
|
||||
|
||||
return id
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue