From: surya.kumar7 Date: Mon, 8 Apr 2019 12:18:51 +0000 (+0530) Subject: Handle Certificate error X-Git-Tag: submit/tizen/20190412.025133~4^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4b44402bce8931a7f635f5b9a38f2248e20ccf31;p=platform%2Fframework%2Fweb%2Fwrtjs.git Handle Certificate error Modified the existing code to handle certificate error as per electron's design Depends on: https://review.tizen.org/gerrit/202994 Change-Id: Ic644227a300854859ceb2a4fc6e8657005cade4f Signed-off-by: surya.kumar7 --- diff --git a/wrt_app/src/web_application.js b/wrt_app/src/web_application.js index b9c9e3a1..213da927 100755 --- a/wrt_app/src/web_application.js +++ b/wrt_app/src/web_application.js @@ -31,6 +31,8 @@ class WebApplication { }); } console.log('mainWindow id : ' + this.mainWindow.id); + this.pendingID = 0; + this.pendingCallbacks = new Map(); this.handleEvents(winopt); this.firstRendered = false; this.backgroundSupport = wrt.getBackgroundSupport(); @@ -87,6 +89,26 @@ class WebApplication { self.suspend(); } }); + wrt.on('permission-response', function(event, id, result) { + let callback = self.pendingCallbacks.get(id); + if (typeof callback === 'function') { + console.log('calling permission response callback'); + callback(result); + self.pendingCallbacks.delete(id); + } + }); + app.on('certificate-error', function(event, webContents, url, error, certificate, callback) { + console.log('A certificate error has occurred'); + event.preventDefault(); + if (certificate.data) { + const id = ++self.pendingID; + self.pendingCallbacks.set(id, callback); + wrt.handleCertificateError(id, webContents, certificate.data, url); + } else { + console.log('Certificate could not be opened'); + callback(false); + } + }); } suspend() { console.log('WebApplication : suspend');