diff --git a/docs/api/dialog.md b/docs/api/dialog.md index 71224b69cd4..17aa7341bb5 100644 --- a/docs/api/dialog.md +++ b/docs/api/dialog.md @@ -175,11 +175,12 @@ it is usually used to report errors in early stage of startup. If called before the app `ready`event on Linux, the message will be emitted to stderr, and no GUI dialog will appear. -### `dialog.showCertificateTrustDialog(browserWindow, certificate, message, callback)` _macOS_ +### `dialog.showCertificateTrustDialog(browserWindow, options, callback)` _macOS_ * `browserWindow` BrowserWindow -* `certificate` [Certificate](structures/certificate.md) - The certificate to trust/import. -* `message` String - The message to display to the user. +* `options` Object + * `certificate` [Certificate](structures/certificate.md) - The certificate to trust/import. + * `message` String - The message to display to the user. * `callback` Function * `result` Boolean - Whether the user chose to cancel or continue. diff --git a/lib/browser/api/dialog.js b/lib/browser/api/dialog.js index 814a8a2af57..908ffaf670f 100644 --- a/lib/browser/api/dialog.js +++ b/lib/browser/api/dialog.js @@ -282,8 +282,23 @@ module.exports = { return binding.showErrorBox(...args) }, - showCertificateTrustDialog: function (...args) { - return binding.showCertificateTrustDialog(...args) + showCertificateTrustDialog: function (window, options, callback) { + if (options == null || typeof options !== 'object') { + throw new TypeError('options must be an object') + } + + let {certificate, message} = options + if (certificate == null || typeof options !== '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') + } + + return binding.showCertificateTrustDialog(window, certificate, message, callback) } }