OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_PLATFORM_BRIDGE_MAC_H_ | 5 #ifndef CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_PLATFORM_BRIDGE_MAC_H_ |
6 #define CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_PLATFORM_BRIDGE_MAC_H_ | 6 #define CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_PLATFORM_BRIDGE_MAC_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "base/mac/scoped_nsobject.h" | 12 #include "base/mac/scoped_nsobject.h" |
13 #include "base/macros.h" | 13 #include "base/macros.h" |
14 #include "chrome/browser/notifications/notification_common.h" | 14 #include "chrome/browser/notifications/notification_common.h" |
15 #include "chrome/browser/notifications/notification_platform_bridge.h" | 15 #include "chrome/browser/notifications/notification_platform_bridge.h" |
16 | 16 |
17 class Notification; | 17 class Notification; |
18 @class NotificationCenterDelegate; | 18 @class NotificationCenterDelegate; |
19 @class NSDictionary; | 19 @class NSDictionary; |
20 @class NSUserNotificationCenter; | 20 @class NSUserNotificationCenter; |
21 class PrefService; | 21 class PrefService; |
| 22 @class NSXPCConnection; |
| 23 |
| 24 @interface NotificationRemoteDispatcher : NSObject |
| 25 |
| 26 // The connection to the XPC server in charge of delivering alerts |
| 27 @property(readonly) NSXPCConnection* xpcConnection; |
| 28 |
| 29 - (instancetype)init; |
| 30 - (void)dispatchNotification:(NSDictionary*)data; |
| 31 |
| 32 @end |
22 | 33 |
23 // This class is an implementation of NotificationPlatformBridge that will | 34 // This class is an implementation of NotificationPlatformBridge that will |
24 // send platform notifications to the the MacOSX notification center. | 35 // send platform notifications to the the MacOSX notification center. |
25 class NotificationPlatformBridgeMac : public NotificationPlatformBridge { | 36 class NotificationPlatformBridgeMac : public NotificationPlatformBridge { |
26 public: | 37 public: |
27 explicit NotificationPlatformBridgeMac( | 38 explicit NotificationPlatformBridgeMac( |
28 NSUserNotificationCenter* notification_center); | 39 NSUserNotificationCenter* notification_center); |
29 ~NotificationPlatformBridgeMac() override; | 40 ~NotificationPlatformBridgeMac() override; |
30 | 41 |
31 // NotificationPlatformBridge implementation. | 42 // NotificationPlatformBridge implementation. |
(...skipping 10 matching lines...) Expand all Loading... |
42 bool SupportsNotificationCenter() const override; | 53 bool SupportsNotificationCenter() const override; |
43 | 54 |
44 // Validates contents of the |response| dictionary as received from the system | 55 // Validates contents of the |response| dictionary as received from the system |
45 // when a notification gets activated. | 56 // when a notification gets activated. |
46 static bool VerifyNotificationData(NSDictionary* response) WARN_UNUSED_RESULT; | 57 static bool VerifyNotificationData(NSDictionary* response) WARN_UNUSED_RESULT; |
47 | 58 |
48 private: | 59 private: |
49 // Cocoa class that receives callbacks from the NSUserNotificationCenter. | 60 // Cocoa class that receives callbacks from the NSUserNotificationCenter. |
50 base::scoped_nsobject<NotificationCenterDelegate> delegate_; | 61 base::scoped_nsobject<NotificationCenterDelegate> delegate_; |
51 | 62 |
52 // The notification center to use, this can be overriden in tests | 63 // The notification center to use for local banner notifications, |
| 64 // this can be overriden in tests |
53 NSUserNotificationCenter* notification_center_; | 65 NSUserNotificationCenter* notification_center_; |
54 | 66 |
| 67 // The object in charge of dispatching remote notifications |
| 68 base::scoped_nsobject<NotificationRemoteDispatcher> |
| 69 notification_remote_dispatcher_; |
| 70 |
55 DISALLOW_COPY_AND_ASSIGN(NotificationPlatformBridgeMac); | 71 DISALLOW_COPY_AND_ASSIGN(NotificationPlatformBridgeMac); |
56 }; | 72 }; |
57 | 73 |
58 #endif // CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_PLATFORM_BRIDGE_MAC_H_ | 74 #endif // CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_PLATFORM_BRIDGE_MAC_H_ |
OLD | NEW |