Add a SessionPreferences to manage session related data
By design the BrowserClient should not be aware of the api:: classes.
This commit is contained in:
parent
776e8afa2b
commit
cb3a9c69ab
18 changed files with 190 additions and 94 deletions
|
@ -67,7 +67,7 @@ electron.ipcRenderer.on('ELECTRON_INTERNAL_RENDERER_ASYNC_WEB_FRAME_METHOD', (ev
|
|||
let nodeIntegration = 'false'
|
||||
let webviewTag = 'false'
|
||||
let preloadScript = null
|
||||
const sessionPreloadScripts = []
|
||||
let preloadScripts = []
|
||||
let isBackgroundPage = false
|
||||
let appPath = null
|
||||
for (let arg of process.argv) {
|
||||
|
@ -87,11 +87,16 @@ for (let arg of process.argv) {
|
|||
appPath = arg.substr(arg.indexOf('=') + 1)
|
||||
} else if (arg.indexOf('--webview-tag=') === 0) {
|
||||
webviewTag = arg.substr(arg.indexOf('=') + 1)
|
||||
} else if (arg.indexOf('--session-preload') === 0) {
|
||||
sessionPreloadScripts.push(arg.substr(arg.indexOf('=') + 1))
|
||||
} else if (arg.indexOf('--preload-scripts') === 0) {
|
||||
preloadScripts = arg.substr(arg.indexOf('=') + 1).split(path.delimiter)
|
||||
}
|
||||
}
|
||||
|
||||
// The webContents preload script is loaded after the session preload scripts.
|
||||
if (preloadScript) {
|
||||
preloadScripts.push(preloadScript)
|
||||
}
|
||||
|
||||
if (window.location.protocol === 'chrome-devtools:') {
|
||||
// Override some inspector APIs.
|
||||
require('./inspector')
|
||||
|
@ -174,17 +179,8 @@ if (nodeIntegration === 'true') {
|
|||
})
|
||||
}
|
||||
|
||||
for (const sessionPreloadScript of sessionPreloadScripts) {
|
||||
try {
|
||||
require(sessionPreloadScript)
|
||||
} catch (error) {
|
||||
console.error('Unable to load session preload script: ' + sessionPreloadScript)
|
||||
console.error(error.stack || error.message)
|
||||
}
|
||||
}
|
||||
|
||||
// Load the script specfied by the "preload" attribute.
|
||||
if (preloadScript) {
|
||||
// Load the preload scripts.
|
||||
for (const preloadScript of preloadScripts) {
|
||||
try {
|
||||
require(preloadScript)
|
||||
} catch (error) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue