Index: openacs-4/packages/chat/www/chat.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/chat/www/chat.adp,v
diff -u -r1.2.2.3 -r1.2.2.4
--- openacs-4/packages/chat/www/chat.adp	2 Apr 2020 18:09:49 -0000	1.2.2.3
+++ openacs-4/packages/chat/www/chat.adp	3 Apr 2020 07:07:29 -0000	1.2.2.4
@@ -7,7 +7,7 @@
 
 <p id=>#chat.active_users#: <span id="active_users"></span></p>
 
-<button id="enableNotifications">#chat.Enable_web_notifications#</button>
+<button id="enableNotifications" style="display: none;">#chat.Enable_web_notifications#</button>
 <p>
     <a href="room-exit?room_id=@room_id@" class="button" title="#chat.exit_msg#">#chat.Log_off#</a> 
     <a href="chat-transcript?room_id=@room_id@" class="button" title="#chat.transcription_msg#">#chat.Transcript#</a>
Index: openacs-4/packages/xowiki/www/resources/chat-common.js
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/xowiki/www/resources/Attic/chat-common.js,v
diff -u -r1.10.2.8 -r1.10.2.9
--- openacs-4/packages/xowiki/www/resources/chat-common.js	2 Apr 2020 18:12:10 -0000	1.10.2.8
+++ openacs-4/packages/xowiki/www/resources/chat-common.js	3 Apr 2020 07:07:29 -0000	1.10.2.9
@@ -25,8 +25,7 @@
     }
     return true;
 }
-function askNotificationPermission() {
-    var notificationBtn = document.getElementById('enableNotifications');
+function askNotificationPermission(notificationBtn) {
     // function to actually ask the permissions
     function handlePermission(permission) {
         // Whatever the user answers, we make sure Chrome stores the information
@@ -35,7 +34,7 @@
         }
 
         // set the button to shown or hidden, depending on what the user answers
-        if(Notification.permission === 'denied' || Notification.permission === 'default') {
+        if(Notification.permission === 'default') {
             notificationBtn.style.display = 'block';
         } else {
             notificationBtn.style.display = 'none';
@@ -59,7 +58,22 @@
     }
 }
 window.onload = function () {
-    document.getElementById('enableNotifications').addEventListener("click", askNotificationPermission);
+    var notificationButton = document.getElementById('enableNotifications');
+    if (notificationButton !== null) {
+        if(!('permission' in Notification)) {
+            Notification.permission = permission;
+        }
+        if(Notification.permission === 'default') {
+            // Add the listener to the button and show it, only if the
+            // notification permission is 'default' (the user has not accepted
+            // or explicitly denied notifications)
+            console.log(Notification.permission);
+            notificationButton.style.display = 'block';
+            notificationButton.addEventListener("click", function() {
+                askNotificationPermission(notificationButton);
+            });
+        }
+    }
 }
 
 // Retrieve user_id