feat: promisify dialog.showCertificateTrustDialog() (#17181)

* feat: promisify dialog.showCertificateTrustDialog()

* update promisification doc
This commit is contained in:
Shelley Vohr 2019-03-14 17:02:50 -07:00 committed by Cheng Zhao
parent f15d0b1ed7
commit 961c9a88a8
6 changed files with 77 additions and 53 deletions

View file

@ -223,31 +223,27 @@ module.exports = {
return binding.showErrorBox(...args)
},
showCertificateTrustDialog: function (...args) {
const [window, options, callback] = parseArgs(...args)
showCertificateTrustDialog: function (window, options) {
if (window && window.constructor !== BrowserWindow) options = window
if (options == null || typeof options !== 'object') {
throw new TypeError('options must be an object')
}
let { certificate, message } = options
const { certificate, message = '' } = options
if (certificate == null || typeof certificate !== 'object') {
throw new TypeError('certificate must be an object')
}
if (message == null) {
message = ''
} else if (typeof message !== 'string') {
throw new TypeError('message must be a string')
}
if (typeof message !== 'string') throw new TypeError('message must be a string')
return binding.showCertificateTrustDialog(window, certificate, message, callback)
return binding.showCertificateTrustDialog(window, certificate, message)
}
}
module.exports.showMessageBox = deprecate.promisify(module.exports.showMessageBox)
module.exports.showOpenDialog = deprecate.promisify(module.exports.showOpenDialog)
module.exports.showSaveDialog = deprecate.promisify(module.exports.showSaveDialog)
module.exports.showCertificateTrustDialog = deprecate.promisify(module.exports.showCertificateTrustDialog)
// Mark standard asynchronous functions.
v8Util.setHiddenValue(module.exports.showMessageBox, 'asynchronous', true)