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_UI_MANAGER_MAC_H_ | 5 #ifndef CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_UI_MANAGER_MAC_H_ |
6 #define CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_UI_MANAGER_MAC_H_ | 6 #define CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_UI_MANAGER_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_ui_manager.h" | 13 #include "chrome/browser/notifications/notification_platform_bridge.h" |
14 | 14 |
15 class Notification; | 15 class Notification; |
16 @class NotificationCenterDelegate; | 16 @class NotificationCenterDelegate; |
| 17 @class NSUserNotificationCenter; |
17 class PrefService; | 18 class PrefService; |
18 class Profile; | |
19 | 19 |
20 // This class is an implementation of NotificationUIManager that will | 20 // This class is an implementation of NotificationPlatfrormBridge that will |
21 // send platform notifications to the Notification Center on 10.8 and above. | 21 // send platform notifications to the the MacOSX notification center. |
22 // 10.7 and below don't offer native notification support so chrome | 22 class NotificationUIManagerMac : public NotificationPlatformBridge { |
23 // notifications are still used there. | |
24 class NotificationUIManagerMac : public NotificationUIManager { | |
25 public: | 23 public: |
26 NotificationUIManagerMac(); | 24 explicit NotificationUIManagerMac( |
| 25 NSUserNotificationCenter* notification_center); |
27 ~NotificationUIManagerMac() override; | 26 ~NotificationUIManagerMac() override; |
28 | 27 |
29 // NotificationUIManager implementation | 28 // NotificationPlatformBridge implementation. |
30 void Add(const Notification& notification, Profile* profile) override; | 29 void Display(const std::string& notification_id, |
31 bool Update(const Notification& notification, Profile* profile) override; | 30 const std::string& profile_id, |
32 | 31 bool incognito, |
33 // |delegate_id| need to reference a PersistentNotificationDelegate | 32 const Notification& notification) override; |
34 const Notification* FindById(const std::string& delegate_id, | 33 void Close(const std::string& profile_id, |
35 ProfileID profile_id) const override; | 34 const std::string& notification_id) override; |
36 | 35 bool GetDisplayed(const std::string& profile_id, |
37 // |delegate_id| need to reference a PersistentNotificationDelegate | 36 bool incognito, |
38 bool CancelById(const std::string& delegate_id, | 37 std::set<std::string>* notifications) const override; |
39 ProfileID profile_id) override; | 38 bool SupportsNotificationCenter() const override; |
40 std::set<std::string> GetAllIdsByProfileAndSourceOrigin( | |
41 ProfileID profile_id, | |
42 const GURL& source) override; | |
43 std::set<std::string> GetAllIdsByProfile(ProfileID profile_id) override; | |
44 bool CancelAllBySourceOrigin(const GURL& source_origin) override; | |
45 bool CancelAllByProfile(ProfileID profile_id) override; | |
46 void CancelAll() override; | |
47 | 39 |
48 private: | 40 private: |
49 // Cocoa class that receives callbacks from the NSUserNotificationCenter. | 41 // Cocoa class that receives callbacks from the NSUserNotificationCenter. |
50 base::scoped_nsobject<NotificationCenterDelegate> delegate_; | 42 base::scoped_nsobject<NotificationCenterDelegate> delegate_; |
51 | 43 |
| 44 // The notification center to use, this can be overriden in tests |
| 45 NSUserNotificationCenter* notification_center_; |
| 46 |
52 DISALLOW_COPY_AND_ASSIGN(NotificationUIManagerMac); | 47 DISALLOW_COPY_AND_ASSIGN(NotificationUIManagerMac); |
53 }; | 48 }; |
54 | 49 |
55 #endif // CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_UI_MANAGER_MAC_H_ | 50 #endif // CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_UI_MANAGER_MAC_H_ |
OLD | NEW |