Bug 1605997: Unregister notifications that are replaced by a new notification with the same name. r=jmathies

Showing a new notification with the same name of an existing notification
replaces the old notification so we must unregister it from Windows at that
point.

Differential Revision: https://phabricator.services.mozilla.com/D58270

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Dave Townsend 2020-01-06 13:08:14 +00:00
parent 2ca21259af
commit 3f0c6ba8fc

View File

@ -146,6 +146,8 @@ ToastNotification::ShowAlert(nsIAlertNotification* aAlert,
return rv;
}
RefPtr<ToastNotificationHandler> oldHandler = mActiveHandlers.Get(name);
RefPtr<ToastNotificationHandler> handler = new ToastNotificationHandler(
this, aAlertListener, name, cookie, title, text, hostPort, textClickable);
mActiveHandlers.Put(name, handler);
@ -157,6 +159,11 @@ ToastNotification::ShowAlert(nsIAlertNotification* aAlert,
return rv;
}
// If there was a previous handler with the same name then unregister it.
if (oldHandler) {
oldHandler->UnregisterHandler();
}
return NS_OK;
}