Bug 1799258 - Fix constexpr issue on base toolchain builds. r=gfx-reviewers,lsalzman
[gecko.git] / widget / windows / ToastNotification.h
blob23f4941125f7a8ee57604cf0feb6d93c67af7c65
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"
17 namespace mozilla {
18 namespace widget {
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,
30 public nsIObserver {
31 public:
32 NS_DECL_NSIALERTSSERVICE
33 NS_DECL_NSIWINDOWSALERTSSERVICE
34 NS_DECL_NSIALERTSDONOTDISTURB
35 NS_DECL_NSIOBSERVER
36 NS_DECL_ISUPPORTS
38 ToastNotification();
40 nsresult Init();
42 bool IsActiveHandler(const nsAString& aAlertName,
43 ToastNotificationHandler* aHandler);
44 void RemoveHandler(const nsAString& aAlertName,
45 ToastNotificationHandler* aHandler);
47 nsresult BackgroundDispatch(nsIRunnable* runnable);
49 protected:
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;
68 } // namespace widget
69 } // namespace mozilla
71 #endif