Skip to content

Commit

Permalink
Bug 1264815 - Add a 'showPersistentNotification' method to nsIAlertSe…
Browse files Browse the repository at this point in the history
…rvice. r=kcambridge
  • Loading branch information
sunhaitao committed May 12, 2016
1 parent 746f6d3 commit fa3fb17
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 0 deletions.
4 changes: 4 additions & 0 deletions dom/tests/mochitest/notification/MockServices.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ var MockServices = (function () {
});

var mockAlertsService = {
showPersistentNotification: function(persistentData, alert, alertListener) {
this.showAlert(alert, alertListener);
},

showAlert: function(alert, alertListener) {
var listener = SpecialPowers.wrap(alertListener);
activeAlertNotifications[alert.name] = {
Expand Down
7 changes: 7 additions & 0 deletions toolkit/components/alerts/nsAlertsService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,13 @@ NS_IMETHODIMP nsAlertsService::ShowAlertNotification(const nsAString & aImageUrl

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);

Expand Down
4 changes: 4 additions & 0 deletions toolkit/components/alerts/nsIAlertsService.idl
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ interface nsIAlertNotification : nsISupports
[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);
/**
Expand Down
8 changes: 8 additions & 0 deletions toolkit/components/alerts/nsXULAlerts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,14 @@ nsXULAlerts::ShowAlertNotification(const nsAString& aImageUrl, const nsAString&
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)
Expand Down
7 changes: 7 additions & 0 deletions toolkit/system/gnome/nsSystemAlertsService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@ NS_IMETHODIMP nsSystemAlertsService::ShowAlertNotification(const nsAString & aIm
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)
{
Expand Down
8 changes: 8 additions & 0 deletions widget/cocoa/OSXNotificationCenter.mm
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,14 @@ - (void)userNotificationCenter:(id<FakeNSUserNotificationCenter>)center
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)
Expand Down

0 comments on commit fa3fb17

Please sign in to comment.