Current handle sender.tab for background pages

This commit is contained in:
Cheng Zhao 2016-05-29 10:46:48 +09:00
parent dd804d7432
commit 2431d886bf
4 changed files with 51 additions and 24 deletions

View file

@ -41,8 +41,9 @@ electron.ipcRenderer.on('ELECTRON_INTERNAL_RENDERER_ASYNC_WEB_FRAME_METHOD', (ev
})
// Process command line arguments.
var nodeIntegration = 'false'
var preloadScript = null
let nodeIntegration = 'false'
let preloadScript = null
let isBackgroundPage = false
for (let arg of process.argv) {
if (arg.indexOf('--guest-instance-id=') === 0) {
// This is a guest web view.
@ -54,6 +55,8 @@ for (let arg of process.argv) {
nodeIntegration = arg.substr(arg.indexOf('=') + 1)
} else if (arg.indexOf('--preload=') === 0) {
preloadScript = arg.substr(arg.indexOf('=') + 1)
} else if (arg === '--background-page') {
isBackgroundPage = true
}
}
@ -63,7 +66,7 @@ if (window.location.protocol === 'chrome-devtools:') {
nodeIntegration = 'true'
} else if (window.location.protocol === 'chrome-extension:') {
// Add implementations of chrome API.
require('./chrome-api').injectTo(window.location.hostname, window)
require('./chrome-api').injectTo(window.location.hostname, isBackgroundPage, window)
nodeIntegration = 'false'
} else {
// Override default web functions.