Prevent multiple notification permission popup 31/238731/1 accepted/tizen_5.5_unified accepted/tizen_5.5_unified_wearable_hotfix tizen_5.5_wearable_hotfix accepted/tizen/5.5/unified/20200717.070318 accepted/tizen/5.5/unified/wearable/hotfix/20201027.102828 submit/tizen_5.5/20200717.032452 submit/tizen_5.5_wearable_hotfix/20201026.184306
authorSangYong Park <sy302.park@samsung.com>
Tue, 12 May 2020 01:05:54 +0000 (10:05 +0900)
committerjaekuk, lee <juku1999@samsung.com>
Thu, 16 Jul 2020 23:16:51 +0000 (08:16 +0900)
Keep previous user choice of notification permmision in memory.
and, use it when notification permision is requested.

Change-Id: I7413fef73e0f2bf5eca0ced20de0f508435ee592
Signed-off-by: SangYong Park <sy302.park@samsung.com>
wrt_app/src/web_application.js

index b2ed823..1c7635c 100755 (executable)
@@ -79,9 +79,18 @@ class WebApplication {
             webContents.session.setPermissionRequestHandler(function(webContents, permission, callback) {
                 console.log(`handlePermissionRequests for ${permission}`);
                 if (permission === 'notifications') {
+                    if (!self.notificationPermissionMap)
+                      self.notificationPermissionMap = new Map();
+                    else if (self.notificationPermissionMap.has(webContents)) {
+                      process.nextTick(callback, self.notificationPermissionMap.get(webContents));
+                      return;
+                    }
                     const id = ++self.pendingID;
                     console.log(`Raising a notification permission request with id: ${id}`);
-                    self.pendingCallbacks.set(id, callback);
+                    self.pendingCallbacks.set(id, (result) => {
+                      self.notificationPermissionMap.set(webContents, result);
+                      callback(result);
+                    });
                     wrt.handleNotificationPermissionRequest(id, webContents);
                 } else if (permission === 'media') {
                     const id = ++self.pendingID;