Support background.page in extension manifest

This commit is contained in:
Jhen 2016-06-30 15:45:03 +08:00
parent 511dceda4e
commit 76f4bd01eb

View file

@ -72,10 +72,15 @@ const backgroundPages = {}
const startBackgroundPages = function (manifest) {
if (backgroundPages[manifest.extensionId] || !manifest.background) return
const scripts = manifest.background.scripts.map((name) => {
return `<script src="${name}"></script>`
}).join('')
const html = new Buffer(`<html><body>${scripts}</body></html>`)
let html
if (manifest.background.page) {
html = fs.readFileSync(path.join(manifest.srcDirectory, manifest.background.page))
} else {
const scripts = manifest.background.scripts.map((name) => {
return `<script src="${name}"></script>`
}).join('')
html = new Buffer(`<html><body>${scripts}</body></html>`)
}
const contents = webContents.create({
isBackgroundPage: true,