Bug 1264815 - Add a 'showPersistentNotification' method to nsIAlertService. r=kcambridge
authorSUN Haitao <sunhaitao@devtaste.com>
Thu, 12 May 2016 23:58:18 +0800
changeset 302076 92af6b44d00045f7a9c89926bd4eeae6552baff4
parent 302075 62e7c9ec49bce83b46724bc6063e50a3c848bab3
child 302077 88fd1577bab5f8fee9faf91d065e0fc9ee4a9dde
push id19713
push usercbook@mozilla.com
push dateTue, 21 Jun 2016 07:47:34 +0000
treeherderfx-team@be179bb8c58f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskcambridge
bugs1264815
milestone50.0a1
Bug 1264815 - Add a 'showPersistentNotification' method to nsIAlertService. r=kcambridge
dom/tests/mochitest/notification/MockServices.js
toolkit/components/alerts/nsAlertsService.cpp
toolkit/components/alerts/nsIAlertsService.idl
toolkit/components/alerts/nsXULAlerts.cpp
toolkit/system/gnome/nsSystemAlertsService.cpp
widget/cocoa/OSXNotificationCenter.mm
--- a/dom/tests/mochitest/notification/MockServices.js
+++ b/dom/tests/mochitest/notification/MockServices.js
@@ -24,16 +24,20 @@ var MockServices = (function () {
         delete activeAlertNotifications[alertName];
         delete activeAppNotifications[alertName];
         return;
       }
     }
   });
 
   var mockAlertsService = {
+    showPersistentNotification: function(persistentData, alert, alertListener) {
+      this.showAlert(alert, alertListener);
+    },
+
     showAlert: function(alert, alertListener) {
       var listener = SpecialPowers.wrap(alertListener);
       activeAlertNotifications[alert.name] = {
         listener: listener,
         cookie: alert.cookie,
         title: alert.title
       };
 
--- a/toolkit/components/alerts/nsAlertsService.cpp
+++ b/toolkit/components/alerts/nsAlertsService.cpp
@@ -203,16 +203,23 @@ NS_IMETHODIMP nsAlertsService::ShowAlert
   NS_ENSURE_SUCCESS(rv, rv);
   return ShowAlert(alert, aAlertListener);
 }
 
 
 NS_IMETHODIMP nsAlertsService::ShowAlert(nsIAlertNotification * aAlert,
                                          nsIObserver * aAlertListener)
 {
+  return ShowPersistentNotification(EmptyString(), aAlert, aAlertListener);
+}
+
+NS_IMETHODIMP nsAlertsService::ShowPersistentNotification(const nsAString & aPersistentData,
+                                                          nsIAlertNotification * aAlert,
+                                                          nsIObserver * aAlertListener)
+{
   NS_ENSURE_ARG(aAlert);
 
   nsAutoString cookie;
   nsresult rv = aAlert->GetCookie(cookie);
   NS_ENSURE_SUCCESS(rv, rv);
 
   if (XRE_IsContentProcess()) {
     ContentChild* cpc = ContentChild::GetSingleton();
--- a/toolkit/components/alerts/nsIAlertsService.idl
+++ b/toolkit/components/alerts/nsIAlertsService.idl
@@ -110,16 +110,20 @@ interface nsIAlertNotification : nsISupp
    * is not actionable.
    */
   readonly attribute AString source;
 };
 
 [scriptable, uuid(f7a36392-d98b-4141-a7d7-4e46642684e3)]
 interface nsIAlertsService : nsISupports
 {
+  void showPersistentNotification(in AString persistentData,
+                                  in nsIAlertNotification alert,
+                                  [optional] in nsIObserver alertListener);
+
   void showAlert(in nsIAlertNotification alert,
                  [optional] in nsIObserver alertListener);
   /**
    * Initializes and shows an |nsIAlertNotification| with the given parameters.
    *
    * @param alertListener  Used for callbacks. May be null if the caller
    *                       doesn't care about callbacks.
    * @see nsIAlertNotification for descriptions of all other parameters.
--- a/toolkit/components/alerts/nsXULAlerts.cpp
+++ b/toolkit/components/alerts/nsXULAlerts.cpp
@@ -86,16 +86,24 @@ nsXULAlerts::ShowAlertNotification(const
                             aAlertText, aAlertTextClickable,
                             aAlertCookie, aBidi, aLang, aData,
                             aPrincipal, aInPrivateBrowsing);
   NS_ENSURE_SUCCESS(rv, rv);
   return ShowAlert(alert, aAlertListener);
 }
 
 NS_IMETHODIMP
+nsXULAlerts::ShowPersistentNotification(const nsAString& aPersistentData,
+                                        nsIAlertNotification* aAlert,
+                                        nsIObserver* aAlertListener)
+{
+  return ShowAlert(aAlert, aAlertListener);
+}
+
+NS_IMETHODIMP
 nsXULAlerts::ShowAlert(nsIAlertNotification* aAlert,
                        nsIObserver* aAlertListener)
 {
   return ShowAlertWithIconURI(aAlert, aAlertListener, nullptr);
 }
 
 NS_IMETHODIMP
 nsXULAlerts::ShowAlertWithIconURI(nsIAlertNotification* aAlert,
--- a/toolkit/system/gnome/nsSystemAlertsService.cpp
+++ b/toolkit/system/gnome/nsSystemAlertsService.cpp
@@ -47,16 +47,23 @@ NS_IMETHODIMP nsSystemAlertsService::Sho
   nsresult rv = alert->Init(aAlertName, aImageUrl, aAlertTitle,
                             aAlertText, aAlertTextClickable,
                             aAlertCookie, aBidi, aLang, aData,
                             aPrincipal, aInPrivateBrowsing);
   NS_ENSURE_SUCCESS(rv, rv);
   return ShowAlert(alert, aAlertListener);
 }
 
+NS_IMETHODIMP nsSystemAlertsService::ShowPersistentNotification(const nsAString& aPersistentData,
+                                                                nsIAlertNotification* aAlert,
+                                                                nsIObserver* aAlertListener)
+{
+  return ShowAlert(aAlert, aAlertListener);
+}
+
 NS_IMETHODIMP nsSystemAlertsService::ShowAlert(nsIAlertNotification* aAlert,
                                                nsIObserver* aAlertListener)
 {
   NS_ENSURE_ARG(aAlert);
 
   nsAutoString alertName;
   nsresult rv = aAlert->GetName(alertName);
   NS_ENSURE_SUCCESS(rv, rv);
--- a/widget/cocoa/OSXNotificationCenter.mm
+++ b/widget/cocoa/OSXNotificationCenter.mm
@@ -249,16 +249,24 @@ OSXNotificationCenter::ShowAlertNotifica
                             aAlertText, aAlertTextClickable,
                             aAlertCookie, aBidi, aLang, aData,
                             aPrincipal, aInPrivateBrowsing);
   NS_ENSURE_SUCCESS(rv, rv);
   return ShowAlert(alert, aAlertListener);
 }
 
 NS_IMETHODIMP
+OSXNotificationCenter::ShowPersistentNotification(const nsAString& aPersistentData,
+                                                  nsIAlertNotification* aAlert,
+                                                  nsIObserver* aAlertListener)
+{
+  return ShowAlert(aAlert, aAlertListener);
+}
+
+NS_IMETHODIMP
 OSXNotificationCenter::ShowAlert(nsIAlertNotification* aAlert,
                                  nsIObserver* aAlertListener)
 {
   return ShowAlertWithIconData(aAlert, aAlertListener, 0, nullptr);
 }
 
 NS_IMETHODIMP
 OSXNotificationCenter::ShowAlertWithIconData(nsIAlertNotification* aAlert,