Bug 1368277 - Use a notification bar for geolocation and add an artifical checkbox for backend code. r=frg,IanN a=IanN SEA_COMM510_20170330_RELBRANCH
authorIsaac Schemm <isaacschemm@gmail.com>
Sat, 24 Jun 2017 15:51:39 +0200
branchSEA_COMM510_20170330_RELBRANCH
changeset 31417 ab1049e98f0ec11c740c434d52b5508dd1f94018
parent 31416 37c3d0aea1854db2d276cd6b3834940bc0dfa26d
child 31418 00de3083c5db2fcb1544d5f9edd8bdae5e039b03
push id1
push userclokep@gmail.com
push dateMon, 07 May 2018 22:45:56 +0000
treeherdercomm-esr60@57eacde5ef40 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfrg, IanN, IanN
bugs1368277
Bug 1368277 - Use a notification bar for geolocation and add an artifical checkbox for backend code. r=frg,IanN a=IanN
suite/common/bindings/notification.xml
--- a/suite/common/bindings/notification.xml
+++ b/suite/common/bindings/notification.xml
@@ -1500,56 +1500,77 @@
         <parameter name="cancelCallback"/>
         <body>
           <![CDATA[
             var type = "geolocation";
             if (this.getNotificationWithValue(type))
               return;
 
             var buttons = [{
+              label: this._stringBundle.GetStringFromName(type + ".alwaysShareForSite"),
+              accessKey: this._stringBundle.GetStringFromName(type + ".alwaysShareForSite.accesskey"),
+              popup: null,
+              callback: function (aNotificationBox, aButton) {
+                aNotificationBox.checkbox.checked = true;
+                allowCallback(aNotificationBox.checkbox.checked);
+              }
+            }, {
+              label: this._stringBundle.GetStringFromName(type + ".neverShareForSite"),
+              accessKey: this._stringBundle.GetStringFromName(type + ".neverShareForSite.accesskey"),
+              popup: null,
+              callback: function (aNotificationBox, aButton) {
+                aNotificationBox.checkbox.checked = true;
+                cancelCallback(aNotificationBox.checkbox.checked);
+              }
+            }, {
+              label: this._stringBundle.GetStringFromName(type + ".dontShareThisRequest"),
+              accessKey: this._stringBundle.GetStringFromName(type + ".dontShareThisRequest.accesskey"),
+              popup: null,
+              callback: function (aNotificationBox, aButton) {
+                aNotificationBox.checkbox.checked = false;
+                cancelCallback(aNotificationBox.checkbox.checked);
+              }
+            }];
+
+            var buttonsPrivate = [{
               label: this._stringBundle.GetStringFromName(type + ".shareLocation"),
               accessKey: this._stringBundle.GetStringFromName(type + ".shareLocation.accesskey"),
               popup: null,
               callback: function (aNotificationBox, aButton) {
+                aNotificationBox.checkbox.checked = false;
                 allowCallback(aNotificationBox.checkbox.checked);
               }
             }, {
               label: this._stringBundle.GetStringFromName(type + ".dontShareThisRequest"),
               accessKey: this._stringBundle.GetStringFromName(type + ".dontShareThisRequest.accesskey"),
               popup: null,
               callback: function (aNotificationBox, aButton) {
+                aNotificationBox.checkbox.checked = false;
                 cancelCallback(aNotificationBox.checkbox.checked);
               }
             }];
+
             var message;
             if (site)
               message = this._stringBundle
                             .formatStringFromName(type + ".siteWantsToKnow",
                                                   [site], 1);
             else
               message = this._stringBundle
                             .formatStringFromName(type + ".fileWantsToKnow",
                                                   [file], 1);
             var box = this.appendNotification(message, type, null,
-                                              this.PRIORITY_INFO_HIGH, buttons);
+                                              this.PRIORITY_INFO_HIGH,
+                                              site && !this.usePrivateBrowsing ? buttons : buttonsPrivate);
             // Force a style flush, so that we ensure the binding is attached.
             box.clientTop;
 
-            // Create a dummy checkbox so file requests don't try to remember.
+            // Create a dummy checkbox for backend Mozilla code.
             box.checkbox = { checked: false };
 
-            // Don't offer action in Private Browsing mode if the action
-            // remembers permission for more than a session.
-            if (site && !this.usePrivateBrowsing) {
-              box.checkbox = document.createElement("checkbox");
-              box.checkbox.className = "rememberChoice";
-              box.checkbox.setAttribute("label", this._stringBundle.GetStringFromName(type + ".remember"));
-              box.appendChild(box.checkbox);
-            }
-
             var link = document.createElement("label");
             link.className = "text-link";
             link.setAttribute("value", this._stringBundle.GetStringFromName(type + ".learnMore"));
             link.setAttribute("href", this._urlFormatter.formatURLPref("browser." + type + ".warning.infoURL"));
             document.getAnonymousElementByAttribute(box, "anonid", "messageText").appendChild(link);
           ]]>
         </body>
       </method>
@@ -2705,69 +2726,86 @@
       <method name="showGeolocationPrompt">
         <parameter name="file"/>
         <parameter name="site"/>
         <parameter name="allowCallback"/>
         <parameter name="cancelCallback"/>
         <body>
           <![CDATA[
             var type = "geolocation";
-            var mainAction = {
-              label: this._stringBundle.GetStringFromName(type + ".shareLocation"),
-              accessKey: this._stringBundle.GetStringFromName(type + ".shareLocation.accesskey"),
-              callback: function(aNotification) {
-                allowCallback(false);
-              }
-            };
-
-            var secondaryActions = [{
-              label: this._stringBundle.GetStringFromName(type + ".dontShareThisRequest"),
-              accessKey: this._stringBundle.GetStringFromName(type + ".dontShareThisRequest.accesskey"),
-              callback: function (aNotification) {
-                cancelCallback(false);
-              }
-            }, {
+            if (this.getNotificationWithValue(type))
+              return;
+
+            var buttons = [{
               label: this._stringBundle.GetStringFromName(type + ".alwaysShareForSite"),
               accessKey: this._stringBundle.GetStringFromName(type + ".alwaysShareForSite.accesskey"),
-              callback: function (aNotification) {
-                allowCallback(true);
+              popup: null,
+              callback: function (aNotificationBox, aButton) {
+                aNotificationBox.checkbox.checked = true;
+                allowCallback(aNotificationBox.checkbox.checked);
               }
             }, {
               label: this._stringBundle.GetStringFromName(type + ".neverShareForSite"),
               accessKey: this._stringBundle.GetStringFromName(type + ".neverShareForSite.accesskey"),
-              callback: function (aNotification) {
-                cancelCallback(true);
+              popup: null,
+              callback: function (aNotificationBox, aButton) {
+                aNotificationBox.checkbox.checked = true;
+                cancelCallback(aNotificationBox.checkbox.checked);
+              }
+            }, {
+              label: this._stringBundle.GetStringFromName(type + ".dontShareThisRequest"),
+              accessKey: this._stringBundle.GetStringFromName(type + ".dontShareThisRequest.accesskey"),
+              popup: null,
+              callback: function (aNotificationBox, aButton) {
+                aNotificationBox.checkbox.checked = false;
+                cancelCallback(aNotificationBox.checkbox.checked);
               }
             }];
 
-            // Don't offer action in Private Browsing mode if the action
-            // remembers permission for more than a session.
-            if (file || this.usePrivateBrowsing)
-              secondaryActions.length = 1;
+            var buttonsPrivate = [{
+              label: this._stringBundle.GetStringFromName(type + ".shareLocation"),
+              accessKey: this._stringBundle.GetStringFromName(type + ".shareLocation.accesskey"),
+              popup: null,
+              callback: function (aNotificationBox, aButton) {
+                aNotificationBox.checkbox.checked = false;
+                allowCallback(aNotificationBox.checkbox.checked);
+              }
+            }, {
+              label: this._stringBundle.GetStringFromName(type + ".dontShareThisRequest"),
+              accessKey: this._stringBundle.GetStringFromName(type + ".dontShareThisRequest.accesskey"),
+              popup: null,
+              callback: function (aNotificationBox, aButton) {
+                aNotificationBox.checkbox.checked = false;
+                cancelCallback(aNotificationBox.checkbox.checked);
+              }
+            }];
 
             var message;
-            if (site) {
+            if (site)
               message = this._stringBundle
                             .formatStringFromName(type + ".siteWantsToKnow",
                                                   [site], 1);
-            } else {
+            else
               message = this._stringBundle
                             .formatStringFromName(type + ".fileWantsToKnow",
                                                   [file], 1);
-            }
-
-            var options = {
-              value: this._stringBundle.GetStringFromName(type + ".learnMore"),
-              href: this._urlFormatter.formatURLPref("browser." + type + ".warning.infoURL")
-            };
-
-            PopupNotifications.show(this.activeBrowser,
-                                    "geolocation", message,
-                                    "geo-notification-icon", mainAction,
-                                    secondaryActions, options);
+            var box = this.appendNotification(message, type, null,
+                                              this.PRIORITY_INFO_HIGH,
+                                              site && !this.usePrivateBrowsing ? buttons : buttonsPrivate);
+            // Force a style flush, so that we ensure the binding is attached.
+            box.clientTop;
+
+            // Create a dummy checkbox for backend Mozilla code.
+            box.checkbox = { checked: false };
+
+            var link = document.createElement("label");
+            link.className = "text-link";
+            link.setAttribute("value", this._stringBundle.GetStringFromName(type + ".learnMore"));
+            link.setAttribute("href", this._urlFormatter.formatURLPref("browser." + type + ".warning.infoURL"));
+            document.getAnonymousElementByAttribute(box, "anonid", "messageText").appendChild(link);
           ]]>
         </body>
       </method>
 
       <method name="showWebNotificationPrompt">
         <parameter name="site"/>
         <parameter name="allowCallback"/>
         <parameter name="cancelCallback"/>