Only add extensions to windows and webviews
This commit is contained in:
parent
f29801ad2b
commit
ee09c7534a
1 changed files with 7 additions and 2 deletions
|
@ -19,6 +19,11 @@ const generateExtensionIdFromName = function (name) {
|
||||||
return name.replace(/[\W_]+/g, '-').toLowerCase()
|
return name.replace(/[\W_]+/g, '-').toLowerCase()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const isWindowOrWebView = function (webContents) {
|
||||||
|
const type = webContents.getType()
|
||||||
|
return type === 'window' || type === 'webview'
|
||||||
|
}
|
||||||
|
|
||||||
// Create or get manifest object from |srcDirectory|.
|
// Create or get manifest object from |srcDirectory|.
|
||||||
const getManifestFromPath = function (srcDirectory) {
|
const getManifestFromPath = function (srcDirectory) {
|
||||||
let manifest
|
let manifest
|
||||||
|
@ -238,7 +243,7 @@ const loadDevToolsExtensions = function (win, manifests) {
|
||||||
}
|
}
|
||||||
|
|
||||||
app.on('web-contents-created', function (event, webContents) {
|
app.on('web-contents-created', function (event, webContents) {
|
||||||
if (webContents.getType() === 'remote') return
|
if (!isWindowOrWebView(webContents)) return
|
||||||
|
|
||||||
hookWebContentsForTabEvents(webContents)
|
hookWebContentsForTabEvents(webContents)
|
||||||
webContents.on('devtools-opened', function () {
|
webContents.on('devtools-opened', function () {
|
||||||
|
@ -323,7 +328,7 @@ app.once('ready', function () {
|
||||||
const manifest = getManifestFromPath(srcDirectory)
|
const manifest = getManifestFromPath(srcDirectory)
|
||||||
if (manifest) {
|
if (manifest) {
|
||||||
for (const webContents of getAllWebContents()) {
|
for (const webContents of getAllWebContents()) {
|
||||||
if (webContents.getType() !== 'remote') {
|
if (isWindowOrWebView(webContents)) {
|
||||||
loadDevToolsExtensions(webContents, [manifest])
|
loadDevToolsExtensions(webContents, [manifest])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue