Bug 1031021 - Do not remove popup on dismissal (if it works); r=MattN
authorGregory Szorc <gps@mozilla.com>
Tue, 01 Jul 2014 11:21:17 -0700
changeset 22 d05cf74a0254f3624a6ca1ca550375c411069d92
parent 21 af36fa168fcfd43ff27fda4180c6a71f665cafe2
child 23 fc3c622aff83b8d4153ed57704b7a996cce1e0ed
push id14
push usergszorc@mozilla.com
push dateWed, 02 Jul 2014 17:05:23 +0000
reviewersMattN
bugs1031021
Bug 1031021 - Do not remove popup on dismissal (if it works); r=MattN When the upgrade notification is dismissed, we want an icon to persist in the notifications tray so users are more likely to perform an upgrade. This patch also changes the tray icon to the Firefox logo. Both changes only apply to Firefox 15 and newer due to incompatibilities with the notifications API that were judged to be too difficult to work around. This means that Firefox 10 through 14 will see the default "blue I" icon in the tray and that the tray icon will go away when the notification is dismissed. This effectively means the notification will only be seen on startup.
v20140527.01/content/firefox16.png
v20140527.01/content/notification.css
v20140527.01/resource/update.jsm
new file mode 100644
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..33ebba13ba93f7e27bade4c424b61e16c93f548f
GIT binary patch
literal 829
zc$@(}1H$}?P)<h;3K|Lk000e1NJLTq000mG000mO1^@s6AM^iV00097Nkl<Zc-p0t
zYe>^k7>Bc~7D{R9yeyg9|7=T3@RBQ{Y+82HG_9NwCC*DqVJn+j42cSLR%j%)E+k^5
zc0)5O{GzV1vP4&2Ds@X|kxnJjF6jT)S;R=HPaSwToO52D^S<XYWwyKTfAPnJ;_)Ci
zss3Y8Y~4VgyxzphwZm*|y~(hr;X}UsUbo9X1*UA#7TIO3JmkXTQBqKcfKn}_cl)uv
zb^wxUBLd5GC~oQ)F0VM7`R%!*)g(cm(sO=S5}8nCDkl=N6u5dm3|rKP;C7`Ayjup?
zmAwVGpb<$_+S79%O_j+tlLXZ}#A`cb1ih(37>_d07w`~}o(s2Aw=v^lD{M3^u+Mo2
z?~L0R8PwuauNnhQ_MsNRqgW>YT|9$#`v{CG0{w9hw5P7dnXD8z<TPM`surAs)!@XJ
zKvQ`G7|cfhi)kk<g0?t;QNN48kV4R>BzS+Ck7M!SAgN_=Q&eF=QaNm8=U}rr4;6PV
zf;APQy+&-b2y`;Rc=ryva{_@bS_sv;rC7XOfjKc6%#jtrI#dnoHCeEh?8Wzy60k#u
zQGG$mes6Y~`cv>MLNM_<ilB#P@gzuy(ijPx0#o3&=>S6H@o)%EgRM^@-2G(u(h-Dl
zgAkq97LHmns0?OWbQ=lYZYOvnqnRWUbSp&ArxVn~2@x6|0eew2RLbQTd+3VM#(8Kt
z&b?z1l&m1i#+3wZVFX<=%1(ky!Cr_G`orC00~|fV!1s{iRWTn!*Im(hf`_WD;v*J8
zhM$*1ji2D-)4*SnXj;y0f?JVZNM7a-^#)(`W)ckM2w+HKP!%a+o1>UjlU}06liBvb
zo3Q3g%;lKRq$|dJF7$d681(IBpqDdvxmCc{hw$_Mc*?ZdB|AFj-V_PGHb@Ab2T{=`
zg7$EN&PamRa0WM4FzkLF=RA#d`I}%mWf6atb-I${+<ckO8>?C(U@Lw2Y_a#k&uX#j
z>qw`$g*0Xv#pa*C(Y#3EQp^MCOe?E3w3kr$6kCeb@9{qXvec^Sl9c(a00000NkvXX
Hu0mjfyF7-Q
--- a/v20140527.01/content/notification.css
+++ b/v20140527.01/content/notification.css
@@ -6,8 +6,12 @@
   -moz-binding: url("chrome://firefox-hotfix/content/notification.xml#upgrade-notification");
 }
 
 .upgrade-notification-icon {
   width: 64px;
   height: 64px;
   -moz-margin-end: 10px;
 }
+
+#upgrade-notification-tray-icon {
+  list-style-image: url(chrome://firefox-hotfix/content/firefox16.png);
+}
--- a/v20140527.01/resource/update.jsm
+++ b/v20140527.01/resource/update.jsm
@@ -2030,26 +2030,36 @@ UpgradeManager.prototype = {
       accessKey: bundle.GetStringFromName("install.accesskey"),
       callback: this._onStartInstallClicked.bind(this),
     };
 
     // We don't need to set because "Not Now" is the default message and it
     // should already be translated.
     let secondaryActions = null;
 
+    // Dismissing the notification to the tray doesn't work in Firefox <15 due
+    // to incompatibilities between our CSS/XBL and legacy versions of the
+    // pop-up notifications feature. See bug 1031021.
+    let anchorID = "upgrade-notification-tray-icon";
+    let removeOnDismissal = false;
+    if (Services.vc.compare(Services.appinfo.version, "14.*") <= 0) {
+      anchorID = null;
+      removeOnDismissal = true;
+    }
+
     let us = this;
     let options = {
       // Persist forever. We avoid really large values because it may overflow
       // JavaScript's Date type. 2^36 in milliseconds corresponds to ~795 days.
       timeout: Math.pow(2, 36),
 
       // Keep showing during location changes. Upgrades are important!
       persistWhileVisible: true,
 
-      removeOnDismissal: true,
+      removeOnDismissal: removeOnDismissal,
 
       eventCallback: function (action) {
         switch (action) {
           case "dismissed":
             us._onNotifyDismissed();
             return;
 
           case "removed":
@@ -2067,17 +2077,17 @@ UpgradeManager.prototype = {
     if (window.switchToTabHavingURI(this.NEW_TAB_URL, true)) {
       this._log.warn("Showing notification on existing tab.");
     } else {
       this._log.warn("Opening a new tab to show notification.");
     }
 
     try {
       window.PopupNotifications.show(window.gBrowser.selectedBrowser, "upgrade",
-                                     message, null, mainAction,
+                                     message, anchorID, mainAction,
                                      secondaryActions, options);
     } catch (e) {
       this._log.error("Error showing notification: " + e);
     }
   },
 
   // -----------------------------
   // BEGIN FORENSIC UPLOADING CODE
@@ -2822,16 +2832,25 @@ let windowListener = {
 function injectCSS(window) {
   let doc = window.document;
 
   let pi = doc.createProcessingInstruction(
     "xml-stylesheet",
     'id="upgrade-notification-css" href="chrome://firefox-hotfix/content/notification.css" type="text/css"');
 
   doc.insertBefore(pi, doc.getElementById('main-window'));
+
+  let image = doc.createElement("image");
+  image.setAttribute("id", "upgrade-notification-tray-icon");
+  image.setAttribute("class", "notification-anchor-icon");
+  image.setAttribute("role", "button");
+  let el = doc.getElementById("notification-popup-box");
+  if (el) {
+    el.appendChild(image);
+  }
 }
 
 function removeCSS(window) {
   let nodes = window.document.childNodes;
   let toDelete = [];
 
   for (let i = 0; i < nodes.length; i++) {
     let node = nodes[i];
@@ -2842,9 +2861,14 @@ function removeCSS(window) {
     if (node.data.indexOf('id="upgrade-notification-css"') != -1) {
       toDelete.push(node);
     }
   }
 
   for each (let node in toDelete) {
     node.parentNode.removeChild(node);
   }
+
+  let el = window.document.getElementById("upgrade-notification-tray-icon");
+  if (el) {
+    el.parentNode.removeChild(el);
+  }
 }