michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: var AlertsHelper = { michael@0: _listener: null, michael@0: michael@0: showAlertNotification: function ah_show(aImageURL, aTitle, aText, aTextClickable, aCookie, aListener) { michael@0: if (aListener) { michael@0: Services.obs.addObserver(this, "metro_native_toast_clicked", false); michael@0: Services.obs.addObserver(this, "metro_native_toast_dismissed", false); michael@0: Services.obs.addObserver(this, "metro_native_toast_shown", false); michael@0: } michael@0: this._listener = aListener; michael@0: michael@0: if (Services.metro.foreground) { michael@0: // Firefox is in the foreground, no need for a notification. michael@0: return; michael@0: } michael@0: Services.metro.showNativeToast(aTitle, aText, aImageURL, aCookie); michael@0: }, michael@0: michael@0: closeAlert: function ah_close() { michael@0: if (this._listener) { michael@0: Services.obs.removeObserver(this, "metro_native_toast_shown"); michael@0: Services.obs.removeObserver(this, "metro_native_toast_clicked"); michael@0: Services.obs.removeObserver(this, "metro_native_toast_dismissed"); michael@0: this._listener = null; michael@0: } michael@0: }, michael@0: michael@0: observe: function(aSubject, aTopic, aData) { michael@0: switch (aTopic) { michael@0: case "metro_native_toast_clicked": michael@0: this._listener.observe(null, "alertclickcallback", aData); michael@0: break; michael@0: case "metro_native_toast_shown": michael@0: this._listener.observe(null, "alertshow", aData); michael@0: break; michael@0: case "metro_native_toast_dismissed": michael@0: this._listener.observe(null, "alertfinished", aData); michael@0: break; michael@0: } michael@0: } michael@0: };