1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef ToastNotification_h__
7 #define ToastNotification_h__
9 #include "mozilla/Maybe.h"
10 #include "mozilla/MozPromise.h"
11 #include "nsIAlertsService.h"
12 #include "nsIObserver.h"
13 #include "nsIThread.h"
14 #include "nsIWindowsAlertsService.h"
15 #include "nsRefPtrHashtable.h"
20 struct ToastHandledResolve
{
21 const nsString launchUrl
;
22 const nsString privilegedName
;
24 using ToastHandledPromise
= MozPromise
<ToastHandledResolve
, bool, true>;
26 class ToastNotificationHandler
;
28 class ToastNotification final
: public nsIWindowsAlertsService
,
29 public nsIAlertsDoNotDisturb
,
32 NS_DECL_NSIALERTSSERVICE
33 NS_DECL_NSIWINDOWSALERTSSERVICE
34 NS_DECL_NSIALERTSDONOTDISTURB
42 bool IsActiveHandler(const nsAString
& aAlertName
,
43 ToastNotificationHandler
* aHandler
);
44 void RemoveHandler(const nsAString
& aAlertName
,
45 ToastNotificationHandler
* aHandler
);
47 nsresult
BackgroundDispatch(nsIRunnable
* runnable
);
50 virtual ~ToastNotification();
51 bool EnsureAumidRegistered();
53 static bool AssignIfMsixAumid(Maybe
<nsAutoString
>& aAumid
);
54 static bool AssignIfNsisAumid(nsAutoString
& aInstallHash
,
55 Maybe
<nsAutoString
>& aAumid
);
56 static bool RegisterRuntimeAumid(nsAutoString
& aInstallHash
,
57 Maybe
<nsAutoString
>& aAumid
);
59 RefPtr
<ToastHandledPromise
> VerifyTagPresentOrFallback(
60 const nsAString
& aWindowsTag
);
61 static void SignalComNotificationHandled(const nsAString
& aWindowsTag
);
63 nsRefPtrHashtable
<nsStringHashKey
, ToastNotificationHandler
> mActiveHandlers
;
64 Maybe
<nsAutoString
> mAumid
;
65 bool mSuppressForScreenSharing
= false;
69 } // namespace mozilla