Bug 1524619 - Part 3 - Support requiring user gestures for push notifications on Fennec. r=snorp a=pascalc
authorJohann Hofmann <jhofmann@mozilla.com>
Fri, 15 Mar 2019 11:47:06 +0100
changeset 526320 eea064bfc1d35f1bfab2d12e2273a63cbc346d5f
parent 526319 9df7dbd02a5f46d9c4a149fea1b3e28dfa3f9023
child 526321 fa0ac55df425d5393b8e30ce34cb21bb7da3ff85
push id2032
push userffxbld-merge
push dateMon, 13 May 2019 09:36:57 +0000
treeherdermozilla-release@455c1065dcbe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssnorp, pascalc
bugs1524619
milestone67.0
Bug 1524619 - Part 3 - Support requiring user gestures for push notifications on Fennec. r=snorp a=pascalc Differential Revision: https://phabricator.services.mozilla.com/D23648
mobile/android/components/ContentPermissionPrompt.js
--- a/mobile/android/components/ContentPermissionPrompt.js
+++ b/mobile/android/components/ContentPermissionPrompt.js
@@ -85,16 +85,23 @@ ContentPermissionPrompt.prototype = {
       request.allow();
     };
 
     // Returns true if the request was handled
     if (this.handleExistingPermission(request, perm.type, isApp, callback)) {
        return;
     }
 
+    if (perm.type === "desktop-notification" &&
+        Services.prefs.getBoolPref("dom.webnotifications.requireuserinteraction", false) &&
+        !request.isHandlingUserInput) {
+      request.cancel();
+      return;
+    }
+
     let browserBundle = Services.strings.createBundle("chrome://browser/locale/browser.properties");
     let entityName = kEntities[perm.type];
 
     let buttons = [{
       label: browserBundle.GetStringFromName(entityName + ".dontAllow"),
       callback: function(aChecked) {
         // If the user checked "Don't ask again" or this is a desktopNotification, make a permanent exception
         if (aChecked || entityName == "desktopNotification2")