1 /* -*- Mode: C++; tab-width: 2; 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/. */
5 
6 #ifndef OSXNotificationCenter_h
7 #define OSXNotificationCenter_h
8 
9 #import <Foundation/Foundation.h>
10 #include "nsIAlertsService.h"
11 #include "nsTArray.h"
12 #include "mozilla/RefPtr.h"
13 
14 // mozNotificationCenterDelegate is used to access the macOS notification
15 // center. It is not related to the DesktopNotificationCenter object, which was
16 // removed in bug 952453. While there are no direct references to this class
17 // elsewhere, removing this will cause push notifications on macOS to stop
18 // working.
19 @class mozNotificationCenterDelegate;
20 
21 namespace mozilla {
22 
23 class OSXNotificationInfo;
24 
25 class OSXNotificationCenter : public nsIAlertsService,
26                               public nsIAlertsIconData,
27                               public nsIAlertsDoNotDisturb,
28                               public nsIAlertNotificationImageListener {
29  public:
30   NS_DECL_ISUPPORTS
31   NS_DECL_NSIALERTSSERVICE
32   NS_DECL_NSIALERTSICONDATA
33   NS_DECL_NSIALERTSDONOTDISTURB
34   NS_DECL_NSIALERTNOTIFICATIONIMAGELISTENER
35 
36   OSXNotificationCenter();
37 
38   nsresult Init();
39   void CloseAlertCocoaString(NSString* aAlertName);
40   void OnActivate(NSString* aAlertName, NSUserNotificationActivationType aActivationType,
41                   unsigned long long aAdditionalActionIndex);
42   void ShowPendingNotification(OSXNotificationInfo* osxni);
43 
44  protected:
45   virtual ~OSXNotificationCenter();
46 
47  private:
48   mozNotificationCenterDelegate* mDelegate;
49   nsTArray<RefPtr<OSXNotificationInfo> > mActiveAlerts;
50   nsTArray<RefPtr<OSXNotificationInfo> > mPendingAlerts;
51   bool mSuppressForScreenSharing;
52 };
53 
54 }  // namespace mozilla
55 
56 #endif  // OSXNotificationCenter_h
57