Bug 1787004 - Fix notifications not closing when notification.close() is called. r=nalexander,geckoview-reviewers,smaug,jonalmeida
This adds context to `CloseAlert()` such that explicitly closing the notification e.g. `notification.close()` can be differentiated from a tab or window implicitly closing the notification. This is necessary as we want notifications to persist after a tab or window is closed for Windows. This change in behavior is necessary to match user expectations. Users expect notifications to persist in the system tray and do not expect notifications to be lost due to a tab being closed. The content of the message is more important than the interaction in that lens. This change is also necessary for parity with Chrome. Differential Revision: https://phabricator.services.mozilla.com/D161024
This commit is contained in:
@@ -1872,7 +1872,7 @@ void Notification::Close() {
|
||||
}
|
||||
}
|
||||
|
||||
void Notification::CloseInternal() {
|
||||
void Notification::CloseInternal(bool aContextClosed) {
|
||||
AssertIsOnMainThread();
|
||||
// Transfer ownership (if any) to local scope so we can release it at the end
|
||||
// of this function. This is relevant when the call is from
|
||||
@@ -1887,7 +1887,7 @@ void Notification::CloseInternal() {
|
||||
if (alertService) {
|
||||
nsAutoString alertName;
|
||||
GetAlertName(alertName);
|
||||
alertService->CloseAlert(alertName);
|
||||
alertService->CloseAlert(alertName, aContextClosed);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2303,7 +2303,7 @@ Notification::Observe(nsISupports* aSubject, const char* aTopic,
|
||||
obs->RemoveObserver(this, DOM_WINDOW_FROZEN_TOPIC);
|
||||
}
|
||||
|
||||
CloseInternal();
|
||||
CloseInternal(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user