mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-03 10:33:33 +00:00
Bug 782211 - Part 6: Updated the B2G notifications to implement the Notification API. r=etienne
This commit is contained in:
parent
aef5b50861
commit
c6b39fedf9
@ -636,6 +636,7 @@ var CustomEventManager = {
|
||||
dump('XXX FIXME : Got a mozContentEvent: ' + detail.type + "\n");
|
||||
|
||||
switch(detail.type) {
|
||||
case 'desktop-notification-show':
|
||||
case 'desktop-notification-click':
|
||||
case 'desktop-notification-close':
|
||||
AlertsHelper.handleEvent(detail);
|
||||
@ -673,8 +674,16 @@ var AlertsHelper = {
|
||||
if (!listener)
|
||||
return;
|
||||
|
||||
let topic = detail.type == "desktop-notification-click" ? "alertclickcallback"
|
||||
/* desktop-notification-close */ : "alertfinished";
|
||||
let topic;
|
||||
if (detail.type == "desktop-notification-click") {
|
||||
topic = "alertclickcallback";
|
||||
} else if (detail.type == "desktop-notification-show") {
|
||||
topic = "alertshow";
|
||||
} else {
|
||||
/* desktop-notification-close */
|
||||
topic = "alertfinished";
|
||||
}
|
||||
|
||||
if (uid.startsWith("app-notif")) {
|
||||
try {
|
||||
listener.mm.sendAsyncMessage("app-notification-return", {
|
||||
@ -707,10 +716,8 @@ var AlertsHelper = {
|
||||
}
|
||||
},
|
||||
|
||||
registerListener: function alert_registerListener(cookie, alertListener) {
|
||||
let uid = "alert" + this._count++;
|
||||
this._listeners[uid] = { observer: alertListener, cookie: cookie };
|
||||
return uid;
|
||||
registerListener: function alert_registerListener(alertId, cookie, alertListener) {
|
||||
this._listeners[alertId] = { observer: alertListener, cookie: cookie };
|
||||
},
|
||||
|
||||
registerAppListener: function alert_registerAppListener(uid, listener) {
|
||||
@ -745,7 +752,8 @@ var AlertsHelper = {
|
||||
textClickable,
|
||||
cookie,
|
||||
uid,
|
||||
name,
|
||||
bidi,
|
||||
lang,
|
||||
manifestUrl) {
|
||||
function send(appName, appIcon) {
|
||||
shell.sendChromeEvent({
|
||||
@ -754,6 +762,8 @@ var AlertsHelper = {
|
||||
icon: imageUrl,
|
||||
title: title,
|
||||
text: text,
|
||||
bidi: bidi,
|
||||
lang: lang,
|
||||
appName: appName,
|
||||
appIcon: appIcon,
|
||||
manifestURL: manifestUrl
|
||||
@ -779,10 +789,24 @@ var AlertsHelper = {
|
||||
textClickable,
|
||||
cookie,
|
||||
alertListener,
|
||||
name) {
|
||||
let uid = this.registerListener(null, alertListener);
|
||||
name,
|
||||
bidi,
|
||||
lang) {
|
||||
let currentListener = this._listeners[name];
|
||||
if (currentListener) {
|
||||
currentListener.observer.observe(null, "alertfinished", currentListener.cookie);
|
||||
}
|
||||
|
||||
this.registerListener(name, cookie, alertListener);
|
||||
this.showNotification(imageUrl, title, text, textClickable, cookie,
|
||||
uid, name, null);
|
||||
name, bidi, lang, null);
|
||||
},
|
||||
|
||||
closeAlert: function alert_closeAlert(name) {
|
||||
shell.sendChromeEvent({
|
||||
type: "desktop-notification-close",
|
||||
id: name
|
||||
});
|
||||
},
|
||||
|
||||
receiveMessage: function alert_receiveMessage(aMessage) {
|
||||
@ -804,7 +828,7 @@ var AlertsHelper = {
|
||||
|
||||
this.showNotification(data.imageURL, data.title, data.text,
|
||||
data.textClickable, null,
|
||||
data.uid, null, data.manifestURL);
|
||||
data.uid, null, null, data.manifestURL);
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -46,11 +46,19 @@ AlertsService.prototype = {
|
||||
aTextClickable,
|
||||
aCookie,
|
||||
aAlertListener,
|
||||
aName) {
|
||||
aName,
|
||||
aBidi,
|
||||
aLang) {
|
||||
let browser = Services.wm.getMostRecentWindow("navigator:browser");
|
||||
browser.AlertsHelper.showAlertNotification(aImageUrl, aTitle, aText,
|
||||
aTextClickable, aCookie,
|
||||
aAlertListener, aName);
|
||||
aAlertListener, aName, aBidi,
|
||||
aLang);
|
||||
},
|
||||
|
||||
closeAlert: function(aName) {
|
||||
let browser = Services.wm.getMostRecentWindow("navigator:browser");
|
||||
browser.AlertsHelper.closeAlert(aName);
|
||||
},
|
||||
|
||||
// nsIAppNotificationService
|
||||
|
Loading…
Reference in New Issue
Block a user