chore: disable JS impl when //extensions support is on (#19512)

This commit is contained in:
Jeremy Apthorp 2019-07-31 14:25:41 -07:00 committed by GitHub
parent a5f87cee6b
commit c71cdce0b7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 50 additions and 9 deletions

View file

@ -9,7 +9,6 @@ const eventBinding = process.electronBinding('event')
const clipboard = process.electronBinding('clipboard')
const features = process.electronBinding('features')
const { getContentScripts } = require('@electron/internal/browser/chrome-extension')
const { crashReporterInit } = require('@electron/internal/browser/crash-reporter-init')
const { ipcMainInternal } = require('@electron/internal/browser/ipc-main-internal')
const ipcMainUtils = require('@electron/internal/browser/ipc-main-internal-utils')
@ -526,13 +525,24 @@ const getPreloadScript = async function (preloadPath) {
return { preloadPath, preloadSrc, preloadError }
}
ipcMainUtils.handle('ELECTRON_GET_CONTENT_SCRIPTS', () => getContentScripts())
if (process.electronBinding('features').isExtensionsEnabled()) {
ipcMainUtils.handle('ELECTRON_GET_CONTENT_SCRIPTS', () => [])
} else {
const { getContentScripts } = require('@electron/internal/browser/chrome-extension')
ipcMainUtils.handle('ELECTRON_GET_CONTENT_SCRIPTS', () => getContentScripts())
}
ipcMainUtils.handle('ELECTRON_BROWSER_SANDBOX_LOAD', async function (event) {
const preloadPaths = event.sender._getPreloadPaths()
let contentScripts = []
if (!process.electronBinding('features').isExtensionsEnabled()) {
const { getContentScripts } = require('@electron/internal/browser/chrome-extension')
contentScripts = getContentScripts()
}
return {
contentScripts: getContentScripts(),
contentScripts,
preloadScripts: await Promise.all(preloadPaths.map(path => getPreloadScript(path))),
isRemoteModuleEnabled: isRemoteModuleEnabled(event.sender),
isWebViewTagEnabled: guestViewManager.isWebViewTagEnabled(event.sender),