Bug 607926 - Feedback notification should be be close if there is no prefs change [r=mfinkle]
authorVivien Nicolas <21@vingtetun.org>
Thu, 04 Nov 2010 18:16:25 +0100
changeset 66958 9c29b2460fbcb42c14c054517e755c05e9e61707
parent 66957 12519ea0d2d981c39b58b61c91a4d22bcbc72434
child 66959 bc8a18af0cebb63192ff7cc1095a7e54386fd878
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmfinkle
bugs607926
Bug 607926 - Feedback notification should be be close if there is no prefs change [r=mfinkle]
mobile/app/profile/extensions/feedback@mobile.mozilla.org/content/overlay.js
mobile/themes/core/notification.css
--- a/mobile/app/profile/extensions/feedback@mobile.mozilla.org/content/overlay.js
+++ b/mobile/app/profile/extensions/feedback@mobile.mozilla.org/content/overlay.js
@@ -31,23 +31,35 @@
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 var Feedback = {
+  _prefs: [],
+
   init: function(aEvent) {
     let appInfo = Cc["@mozilla.org/xre/app-info;1"].getService(Ci.nsIXULAppInfo);
     document.getElementById("feedback-about").setAttribute("desc", appInfo.version);
 
     // A simple frame script to fill in the referrer page
     messageManager.loadFrameScript("data:,addMessageListener('Feedback:InitPage', function(m) { content.document.getElementById('id_url').value = m.json.referrer; });", true);
 
+    let feedbackPrefs = document.getElementById("feedback-tools").childNodes;
+    for (let i = 0; i < feedbackPrefs.length; i++) {
+      let pref = feedbackPrefs[i].getAttribute("pref");
+      if (!pref)
+        continue;
+
+      let value = Services.prefs.getPrefType(pref) == Ci.nsIPrefBranch.PREF_INVALID ? false : Services.prefs.getBoolPref(pref);
+      Feedback._prefs.push({ "name": pref, "value": value });
+    }
+
     // Delay the widget initialization during startup.
     window.addEventListener("UIReadyDelayed", function(aEvent) {
       window.removeEventListener(aEvent.type, arguments.callee, false);
       document.getElementById("feedback-container").hidden = false;
     }, false);
   },
 
   openFeedback: function(aURL) {
@@ -69,22 +81,32 @@ var Feedback = {
 
   updateRestart: function updateRestart() {
     let msg = document.getElementById("feedback-messages");
     if (msg) {
       let strings = Elements.browserBundle;
 
       let value = "restart-app";
       let notification = msg.getNotificationWithValue(value);
-      if (notification)
+      if (notification) {
+        // Check if the prefs are back to the initial state dismiss the restart
+        // notification because if does not make sense anymore
+        for each (let pref in this._prefs) {
+          let value = Services.prefs.getPrefType(pref.name) == Ci.nsIPrefBranch.PREF_INVALID ? false : Services.prefs.getBoolPref(pref.name);
+          if (value != pref.value)
+            return;
+        }
+
+        notification.close();
         return;
+      }
   
       let restartCallback = function(aNotification, aDescription) {
         // Notify all windows that an application quit has been requested
-        var cancelQuit = Cc["@mozilla.org/supports-PRBool;1"].createInstance(Ci.nsISupportsPRBool);
+        let cancelQuit = Cc["@mozilla.org/supports-PRBool;1"].createInstance(Ci.nsISupportsPRBool);
         Services.obs.notifyObservers(cancelQuit, "quit-application-requested", "restart");
   
         // If nothing aborted, quit the app
         if (cancelQuit.data == false) {
           let appStartup = Cc["@mozilla.org/toolkit/app-startup;1"].getService(Ci.nsIAppStartup);
           appStartup.quit(Ci.nsIAppStartup.eRestart | Ci.nsIAppStartup.eAttemptQuit);
         }
       };
--- a/mobile/themes/core/notification.css
+++ b/mobile/themes/core/notification.css
@@ -7,16 +7,20 @@ notification, notification[type="warning
 }
 
 notification .messageCloseButton {
   list-style-image: url("chrome://browser/skin/images/close-default-hdpi.png");
   -moz-image-region: -moz-initial;
   -moz-box-align: start;
 }
 
+notification .messageCloseButton:-moz-focusring {
+  outline: 0 !important;
+}
+
 notification .messageCloseButton:hover:active {
   list-style-image: url("chrome://browser/skin/images/close-active-hdpi.png");
 }
 
 notification .outset {
   border-color: #4756aa !important;
 }