feat: add webPreferences.enableRemoteModule option (#13028)
This commit is contained in:
parent
72db5ed7cb
commit
d3efc52745
36 changed files with 303 additions and 45 deletions
|
@ -2,15 +2,29 @@
|
|||
|
||||
if (process.platform === 'linux' && process.type === 'renderer') {
|
||||
// On Linux we could not access clipboard in renderer process.
|
||||
module.exports = require('electron').remote.clipboard
|
||||
const { getRemoteForUsage } = require('@electron/internal/renderer/remote')
|
||||
module.exports = getRemoteForUsage('clipboard').clipboard
|
||||
} else {
|
||||
const clipboard = process.atomBinding('clipboard')
|
||||
|
||||
// Read/write to find pasteboard over IPC since only main process is notified
|
||||
// of changes
|
||||
if (process.platform === 'darwin' && process.type === 'renderer') {
|
||||
clipboard.readFindText = require('electron').remote.clipboard.readFindText
|
||||
clipboard.writeFindText = require('electron').remote.clipboard.writeFindText
|
||||
const ipcRenderer = require('@electron/internal/renderer/ipc-renderer-internal')
|
||||
const errorUtils = require('@electron/internal/common/error-utils')
|
||||
|
||||
const invoke = function (command, ...args) {
|
||||
const [ error, result ] = ipcRenderer.sendSync(command, ...args)
|
||||
|
||||
if (error) {
|
||||
throw errorUtils.deserialize(error)
|
||||
} else {
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
||||
clipboard.readFindText = (...args) => invoke('ELECTRON_BROWSER_CLIPBOARD_READ_FIND_TEXT', ...args)
|
||||
clipboard.writeFindText = (...args) => invoke('ELECTRON_BROWSER_CLIPBOARD_WRITE_FIND_TEXT', ...args)
|
||||
}
|
||||
|
||||
module.exports = clipboard
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue