browser/metro/base/content/helperui/AlertsHelper.js

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     1 /* This Source Code Form is subject to the terms of the Mozilla Public
     2  * License, v. 2.0. If a copy of the MPL was not distributed with this
     3  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     5 var AlertsHelper = {
     6   _listener: null,
     8   showAlertNotification: function ah_show(aImageURL, aTitle, aText, aTextClickable, aCookie, aListener) {
     9     if (aListener) {
    10       Services.obs.addObserver(this, "metro_native_toast_clicked", false);
    11       Services.obs.addObserver(this, "metro_native_toast_dismissed", false);
    12       Services.obs.addObserver(this, "metro_native_toast_shown", false);
    13     }
    14     this._listener = aListener;
    16     if (Services.metro.foreground) {
    17       // Firefox is in the foreground, no need for a notification.
    18       return;
    19     }
    20     Services.metro.showNativeToast(aTitle, aText, aImageURL, aCookie);
    21   },
    23   closeAlert: function ah_close() {
    24     if (this._listener) {
    25       Services.obs.removeObserver(this, "metro_native_toast_shown");
    26       Services.obs.removeObserver(this, "metro_native_toast_clicked");
    27       Services.obs.removeObserver(this, "metro_native_toast_dismissed");
    28       this._listener = null;
    29     }
    30   },
    32   observe: function(aSubject, aTopic, aData) {
    33     switch (aTopic) {
    34       case "metro_native_toast_clicked":
    35         this._listener.observe(null, "alertclickcallback", aData);
    36         break;
    37       case "metro_native_toast_shown":
    38         this._listener.observe(null, "alertshow", aData);
    39         break;
    40       case "metro_native_toast_dismissed":
    41         this._listener.observe(null, "alertfinished", aData);
    42         break;
    43     }
    44   }
    45 };

mercurial