Only add extensions to windows and webviews

This commit is contained in:
Kevin Sawicki 2016-06-14 09:30:06 -07:00
parent f29801ad2b
commit ee09c7534a

View file

@ -19,6 +19,11 @@ const generateExtensionIdFromName = function (name) {
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|.
const getManifestFromPath = function (srcDirectory) {
let manifest
@ -238,7 +243,7 @@ const loadDevToolsExtensions = function (win, manifests) {
}
app.on('web-contents-created', function (event, webContents) {
if (webContents.getType() === 'remote') return
if (!isWindowOrWebView(webContents)) return
hookWebContentsForTabEvents(webContents)
webContents.on('devtools-opened', function () {
@ -323,7 +328,7 @@ app.once('ready', function () {
const manifest = getManifestFromPath(srcDirectory)
if (manifest) {
for (const webContents of getAllWebContents()) {
if (webContents.getType() !== 'remote') {
if (isWindowOrWebView(webContents)) {
loadDevToolsExtensions(webContents, [manifest])
}
}