Only add extensions to windows and webviews
authorKevin Sawicki <kevinsawicki@gmail.com>
Tue, 14 Jun 2016 16:30:06 +0000 (09:30 -0700)
committerKevin Sawicki <kevinsawicki@gmail.com>
Tue, 14 Jun 2016 22:47:33 +0000 (15:47 -0700)
lib/browser/chrome-extension.js

index 78d6516..9a5e8e9 100644 (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])
         }
       }