refactor: use helpers for command-line parsing in renderer/init.js (#16239)
This commit is contained in:
parent
baaeb7cece
commit
3f1d22759a
9 changed files with 63 additions and 52 deletions
|
@ -105,6 +105,8 @@ function preloadRequire (module) {
|
|||
throw new Error('module not found')
|
||||
}
|
||||
|
||||
const { hasSwitch } = process.atomBinding('command_line')
|
||||
|
||||
switch (window.location.protocol) {
|
||||
case 'chrome-devtools:': {
|
||||
// Override some inspector APIs.
|
||||
|
@ -113,7 +115,7 @@ switch (window.location.protocol) {
|
|||
}
|
||||
case 'chrome-extension:': {
|
||||
// Inject the chrome.* APIs that chrome extensions require
|
||||
const isBackgroundPage = preloadProcess.argv.includes('--background-page')
|
||||
const isBackgroundPage = hasSwitch('background-page')
|
||||
require('@electron/internal/renderer/chrome-api').injectTo(window.location.hostname, isBackgroundPage, window)
|
||||
break
|
||||
}
|
||||
|
@ -123,7 +125,7 @@ if (binding.guestInstanceId) {
|
|||
process.guestInstanceId = parseInt(binding.guestInstanceId)
|
||||
}
|
||||
|
||||
if (!process.guestInstanceId && preloadProcess.argv.includes('--webview-tag=true')) {
|
||||
if (!process.guestInstanceId && hasSwitch('webview-tag')) {
|
||||
// don't allow recursive `<webview>`
|
||||
require('@electron/internal/renderer/web-view/web-view').setupWebView(window)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue