Bug 910915 - Add capabilities for new notifications to B2G shell/alertservice; r=fabrice
authorKyle Machulis <kyle@nonpolynomial.com>
Tue, 10 Sep 2013 16:49:42 +0200
changeset 159273 576142cafac3c94029f2c19b7e88469f7abf3fa9
parent 159272 114983525d73140b24380fee85bf3e32bea34174
child 159274 3eb0b1c660188dadaa97a227e1f5f04ec829e326
push id2961
push userlsblakk@mozilla.com
push dateMon, 28 Oct 2013 21:59:28 +0000
treeherdermozilla-beta@73ef4f13486f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfabrice
bugs910915
milestone26.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 910915 - Add capabilities for new notifications to B2G shell/alertservice; r=fabrice
b2g/chrome/content/shell.js
b2g/components/AlertsService.js
--- a/b2g/chrome/content/shell.js
+++ b/b2g/chrome/content/shell.js
@@ -722,40 +722,39 @@ var AlertsHelper = {
       topic = "alertclickcallback";
     } else if (detail.type == "desktop-notification-show") {
       topic = "alertshow";
     } else {
       /* desktop-notification-close */
       topic = "alertfinished";
     }
 
-    if (uid.startsWith("app-notif")) {
+    if (uid.startsWith("alert")) {
+      try {
+        listener.observer.observe(null, topic, listener.cookie);
+      } catch (e) { }
+    } else {
       try {
         listener.mm.sendAsyncMessage("app-notification-return", {
           uid: uid,
           topic: topic,
           target: listener.target
         });
-      } catch(e) {
+      } catch (e) {
         // we get an exception if the app is not launched yet
-
         gSystemMessenger.sendMessage("notification", {
             clicked: (detail.type === "desktop-notification-click"),
             title: listener.title,
             body: listener.text,
             imageURL: listener.imageURL
           },
           Services.io.newURI(listener.target, null, null),
           Services.io.newURI(listener.manifestURL, null, null)
         );
       }
-    } else if (uid.startsWith("alert")) {
-      try {
-        listener.observer.observe(null, topic, listener.cookie);
-      } catch (e) { }
     }
 
     // we're done with this notification
     if (topic === "alertfinished") {
       delete this._listeners[uid];
     }
   },
 
--- a/b2g/components/AlertsService.js
+++ b/b2g/components/AlertsService.js
@@ -62,18 +62,19 @@ AlertsService.prototype = {
   },
 
   // nsIAppNotificationService
   showAppNotification: function showAppNotification(aImageURL,
                                                     aTitle,
                                                     aText,
                                                     aTextClickable,
                                                     aManifestURL,
-                                                    aAlertListener) {
-    let uid = "app-notif-" + uuidGenerator.generateUUID();
+                                                    aAlertListener,
+                                                    aId) {
+    let uid = (aId == "") ? "app-notif-" + uuidGenerator.generateUUID() : aId;
 
     this._listeners[uid] = {
       observer: aAlertListener,
       title: aTitle,
       text: aText,
       manifestURL: aManifestURL,
       imageURL: aImageURL
     };