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/mac/scoped_nsobject.h" | 11 #include "base/mac/scoped_nsobject.h" |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "chrome/browser/notifications/notification_operation_common.h" |
13 #include "chrome/browser/notifications/notification_platform_bridge.h" | 14 #include "chrome/browser/notifications/notification_platform_bridge.h" |
14 | 15 |
15 class Notification; | 16 class Notification; |
16 @class NotificationCenterDelegate; | 17 @class NotificationCenterDelegate; |
| 18 @class NSDictionary; |
17 @class NSUserNotificationCenter; | 19 @class NSUserNotificationCenter; |
18 class PrefService; | 20 class PrefService; |
19 | 21 |
20 // This class is an implementation of NotificationPlatformBridge that will | 22 // This class is an implementation of NotificationPlatformBridge that will |
21 // send platform notifications to the the MacOSX notification center. | 23 // send platform notifications to the the MacOSX notification center. |
22 class NotificationPlatformBridgeMac : public NotificationPlatformBridge { | 24 class NotificationPlatformBridgeMac : public NotificationPlatformBridge { |
23 public: | 25 public: |
24 explicit NotificationPlatformBridgeMac( | 26 explicit NotificationPlatformBridgeMac( |
25 NSUserNotificationCenter* notification_center); | 27 NSUserNotificationCenter* notification_center); |
26 ~NotificationPlatformBridgeMac() override; | 28 ~NotificationPlatformBridgeMac() override; |
27 | 29 |
28 // NotificationPlatformBridge implementation. | 30 // NotificationPlatformBridge implementation. |
29 void Display(const std::string& notification_id, | 31 void Display( |
30 const std::string& profile_id, | 32 notification_operation_common::NotificationHandlerType notification_type, |
31 bool incognito, | 33 const std::string& notification_id, |
32 const Notification& notification) override; | 34 const std::string& profile_id, |
| 35 bool incognito, |
| 36 const Notification& notification) override; |
33 void Close(const std::string& profile_id, | 37 void Close(const std::string& profile_id, |
34 const std::string& notification_id) override; | 38 const std::string& notification_id) override; |
35 bool GetDisplayed(const std::string& profile_id, | 39 bool GetDisplayed(const std::string& profile_id, |
36 bool incognito, | 40 bool incognito, |
37 std::set<std::string>* notifications) const override; | 41 std::set<std::string>* notifications) const override; |
38 bool SupportsNotificationCenter() const override; | 42 bool SupportsNotificationCenter() const override; |
39 | 43 |
| 44 // Perform some sanity checks on the returned values. Since the notification |
| 45 // data comes from outside of Chrome it's better to do real production checks |
| 46 // than just DCHECKS. |
| 47 // Returns true if all the checks pass, false otherwise. |
| 48 static bool VerifyNotificationData(NSDictionary* response); |
| 49 |
40 private: | 50 private: |
41 // Cocoa class that receives callbacks from the NSUserNotificationCenter. | 51 // Cocoa class that receives callbacks from the NSUserNotificationCenter. |
42 base::scoped_nsobject<NotificationCenterDelegate> delegate_; | 52 base::scoped_nsobject<NotificationCenterDelegate> delegate_; |
43 | 53 |
44 // The notification center to use, this can be overriden in tests | 54 // The notification center to use, this can be overriden in tests |
45 NSUserNotificationCenter* notification_center_; | 55 NSUserNotificationCenter* notification_center_; |
46 | 56 |
47 DISALLOW_COPY_AND_ASSIGN(NotificationPlatformBridgeMac); | 57 DISALLOW_COPY_AND_ASSIGN(NotificationPlatformBridgeMac); |
48 }; | 58 }; |
49 | 59 |
50 #endif // CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_PLATFORM_BRIDGE_MAC_H_ | 60 #endif // CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_PLATFORM_BRIDGE_MAC_H_ |
OLD | NEW |