feat: add methods to allow customization of save dialog during will-download event (#15497)

* feat: add method to DownloadItem that allows customization of dialog options

* docs: add docs for get/setSaveDialogOptions

* add missing copy constructor for DialogSettings on mac and linux

* fix: don't filter dialog options for mas build, don't return properties

* test: add test for get/setSaveDialogOptions

* fix: remove openDevtools added for debugging

* test: fix failing test because of new event parameter

* docs: use SaveDialogOptions instead of Object
This commit is contained in:
Heilig Benedek 2018-11-08 15:51:06 +01:00 committed by John Kleinschmidt
parent 673004b878
commit ca2d74e118
13 changed files with 203 additions and 49 deletions

View file

@ -161,7 +161,7 @@ app.on('ready', function () {
// For session's download test, listen 'will-download' event in browser, and
// reply the result to renderer for verifying
const downloadFilePath = path.join(__dirname, '..', 'fixtures', 'mock.pdf')
ipcMain.on('set-download-option', function (event, needCancel, preventDefault, filePath = downloadFilePath) {
ipcMain.on('set-download-option', function (event, needCancel, preventDefault, filePath = downloadFilePath, dialogOptions = {}) {
window.webContents.session.once('will-download', function (e, item) {
window.webContents.send('download-created',
item.getState(),
@ -187,6 +187,7 @@ app.on('ready', function () {
item.resume()
} else {
item.setSavePath(filePath)
item.setSaveDialogOptions(dialogOptions)
}
item.on('done', function (e, state) {
window.webContents.send('download-done',
@ -198,6 +199,7 @@ app.on('ready', function () {
item.getContentDisposition(),
item.getFilename(),
item.getSavePath(),
item.getSaveDialogOptions(),
item.getURLChain(),
item.getLastModifiedTime(),
item.getETag())