Bug 1638417 - Implement some of nsIAlertsDoNotDisturb for the GNOME system alerts service. r=MattN

Differential Revision: https://phabricator.services.mozilla.com/D76385
This commit is contained in:
Mike Conley 2020-05-21 22:50:29 +00:00
Родитель e6a9e27a19
Коммит 21c4e2a2dc
2 изменённых файлов: 33 добавлений и 1 удалений

Просмотреть файл

@ -14,6 +14,7 @@ NS_IMPL_RELEASE(nsSystemAlertsService)
NS_INTERFACE_MAP_BEGIN(nsSystemAlertsService)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIAlertsService)
NS_INTERFACE_MAP_ENTRY(nsIAlertsService)
NS_INTERFACE_MAP_ENTRY(nsIAlertsDoNotDisturb)
NS_INTERFACE_MAP_END
nsSystemAlertsService::nsSystemAlertsService() = default;
@ -58,6 +59,11 @@ NS_IMETHODIMP nsSystemAlertsService::ShowAlert(nsIAlertNotification* aAlert,
new nsAlertsIconListener(this, alertName);
if (!alertListener) return NS_ERROR_OUT_OF_MEMORY;
if (mSuppressForScreenSharing) {
alertListener->SendClosed();
return NS_OK;
}
AddListener(alertName, alertListener);
return alertListener->InitAlertAsync(aAlert, aAlertListener);
}
@ -72,6 +78,27 @@ NS_IMETHODIMP nsSystemAlertsService::CloseAlert(const nsAString& aAlertName,
return listener->Close();
}
NS_IMETHODIMP nsSystemAlertsService::GetManualDoNotDisturb(bool* aRetVal) {
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsSystemAlertsService::SetManualDoNotDisturb(bool aDoNotDisturb) {
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsSystemAlertsService::GetSuppressForScreenSharing(
bool* aRetVal) {
NS_ENSURE_ARG(aRetVal);
*aRetVal = mSuppressForScreenSharing;
return NS_OK;
}
NS_IMETHODIMP nsSystemAlertsService::SetSuppressForScreenSharing(
bool aSuppress) {
mSuppressForScreenSharing = aSuppress;
return NS_OK;
}
bool nsSystemAlertsService::IsActiveListener(const nsAString& aAlertName,
nsAlertsIconListener* aListener) {
return mActiveListeners.Get(aAlertName) == aListener;

Просмотреть файл

@ -12,9 +12,11 @@
class nsAlertsIconListener;
class nsSystemAlertsService : public nsIAlertsService {
class nsSystemAlertsService : public nsIAlertsService,
public nsIAlertsDoNotDisturb {
public:
NS_DECL_NSIALERTSSERVICE
NS_DECL_NSIALERTSDONOTDISTURB
NS_DECL_ISUPPORTS
nsSystemAlertsService();
@ -33,6 +35,9 @@ class nsSystemAlertsService : public nsIAlertsService {
nsAlertsIconListener* aListener);
nsDataHashtable<nsStringHashKey, nsAlertsIconListener*> mActiveListeners;
private:
bool mSuppressForScreenSharing = false;
};
#endif /* nsSystemAlertsService_h__ */