Handle Certificate error 96/202996/3
authorsurya.kumar7 <surya.kumar7@samsung.com>
Mon, 8 Apr 2019 12:18:51 +0000 (17:48 +0530)
committerSurya Kumar <surya.kumar7@samsung.com>
Mon, 8 Apr 2019 14:38:02 +0000 (14:38 +0000)
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 <surya.kumar7@samsung.com>
wrt_app/src/web_application.js

index b9c9e3a13fcb8c6be700c75c8dcc8ade2fc696df..213da9272ad504e133aa85d9698bc7a573e42d1d 100755 (executable)
@@ -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');