refactor: use async invoke to get webPreferences in security-warnings.ts (#18821)
This commit is contained in:
parent
5a08522b98
commit
c9bca78a7a
1 changed files with 5 additions and 5 deletions
|
@ -1,5 +1,5 @@
|
||||||
import { webFrame } from 'electron'
|
import { webFrame } from 'electron'
|
||||||
import { invokeSync } from '@electron/internal/renderer/ipc-renderer-internal-utils'
|
import { invoke } from '@electron/internal/renderer/ipc-renderer-internal-utils'
|
||||||
|
|
||||||
let shouldLog: boolean | null = null
|
let shouldLog: boolean | null = null
|
||||||
|
|
||||||
|
@ -262,18 +262,18 @@ const logSecurityWarnings = function (
|
||||||
warnAboutAllowedPopups()
|
warnAboutAllowedPopups()
|
||||||
}
|
}
|
||||||
|
|
||||||
const getWebPreferences = function () {
|
const getWebPreferences = async function () {
|
||||||
try {
|
try {
|
||||||
return invokeSync('ELECTRON_BROWSER_GET_LAST_WEB_PREFERENCES')
|
return invoke<Electron.WebPreferences>('ELECTRON_BROWSER_GET_LAST_WEB_PREFERENCES')
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.warn(`getLastWebPreferences() failed: ${error}`)
|
console.warn(`getLastWebPreferences() failed: ${error}`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function securityWarnings (nodeIntegration: boolean) {
|
export function securityWarnings (nodeIntegration: boolean) {
|
||||||
const loadHandler = function () {
|
const loadHandler = async function () {
|
||||||
if (shouldLogSecurityWarnings()) {
|
if (shouldLogSecurityWarnings()) {
|
||||||
const webPreferences = getWebPreferences()
|
const webPreferences = await getWebPreferences()
|
||||||
logSecurityWarnings(webPreferences, nodeIntegration)
|
logSecurityWarnings(webPreferences, nodeIntegration)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue