OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #import <AppKit/AppKit.h> | 8 #import <AppKit/AppKit.h> |
9 | 9 |
10 #include <map> | 10 #include <map> |
(...skipping 19 matching lines...) Expand all Loading... |
30 class NotificationUIManagerMac : public NotificationUIManager { | 30 class NotificationUIManagerMac : public NotificationUIManager { |
31 public: | 31 public: |
32 explicit NotificationUIManagerMac(PrefService* local_state); | 32 explicit NotificationUIManagerMac(PrefService* local_state); |
33 virtual ~NotificationUIManagerMac(); | 33 virtual ~NotificationUIManagerMac(); |
34 | 34 |
35 // NotificationUIManager: | 35 // NotificationUIManager: |
36 virtual void Add(const Notification& notification, | 36 virtual void Add(const Notification& notification, |
37 Profile* profile) OVERRIDE; | 37 Profile* profile) OVERRIDE; |
38 virtual bool CancelById(const std::string& notification_id) OVERRIDE; | 38 virtual bool CancelById(const std::string& notification_id) OVERRIDE; |
39 virtual bool CancelAllBySourceOrigin(const GURL& source_origin) OVERRIDE; | 39 virtual bool CancelAllBySourceOrigin(const GURL& source_origin) OVERRIDE; |
| 40 virtual bool CancelAllByProfile(Profile* profile) OVERRIDE; |
40 virtual void CancelAll() OVERRIDE; | 41 virtual void CancelAll() OVERRIDE; |
41 virtual BalloonCollection* balloon_collection() OVERRIDE; | 42 virtual BalloonCollection* balloon_collection() OVERRIDE; |
42 virtual NotificationPrefsManager* prefs_manager() OVERRIDE; | 43 virtual NotificationPrefsManager* prefs_manager() OVERRIDE; |
43 virtual void GetQueuedNotificationsForTesting( | 44 virtual void GetQueuedNotificationsForTesting( |
44 std::vector<const Notification*>* notifications) OVERRIDE; | 45 std::vector<const Notification*>* notifications) OVERRIDE; |
45 | 46 |
46 // Returns the corresponding C++ object for the Cocoa notification object, | 47 // Returns the corresponding C++ object for the Cocoa notification object, |
47 // or NULL if it could not be found. | 48 // or NULL if it could not be found. |
48 const Notification* FindNotificationWithCocoaNotification( | 49 const Notification* FindNotificationWithCocoaNotification( |
49 id<CrUserNotification> notification) const; | 50 id<CrUserNotification> notification) const; |
50 | 51 |
51 NotificationUIManagerImpl* builtin_manager() const { | 52 NotificationUIManagerImpl* builtin_manager() const { |
52 return builtin_manager_.get(); | 53 return builtin_manager_.get(); |
53 } | 54 } |
54 | 55 |
55 private: | 56 private: |
56 // A ControllerNotification links the Cocoa (view) notification to the C++ | 57 // A ControllerNotification links the Cocoa (view) notification to the C++ |
57 // (model) notification. This assumes ownership (i.e. does not retain a_view) | 58 // (model) notification. This assumes ownership (i.e. does not retain a_view) |
58 // of both objects and will delete them on destruction. | 59 // of both objects and will delete them on destruction. |
59 struct ControllerNotification { | 60 struct ControllerNotification { |
60 ControllerNotification(id<CrUserNotification> a_view, | 61 ControllerNotification(Profile* a_profile, |
| 62 id<CrUserNotification> a_view, |
61 Notification* a_model); | 63 Notification* a_model); |
62 ~ControllerNotification(); | 64 ~ControllerNotification(); |
63 | 65 |
| 66 Profile* profile; |
64 id<CrUserNotification> view; | 67 id<CrUserNotification> view; |
65 Notification* model; | 68 Notification* model; |
66 | 69 |
67 private: | 70 private: |
68 DISALLOW_COPY_AND_ASSIGN(ControllerNotification); | 71 DISALLOW_COPY_AND_ASSIGN(ControllerNotification); |
69 }; | 72 }; |
70 typedef std::map<std::string, ControllerNotification*> NotificationMap; | 73 typedef std::map<std::string, ControllerNotification*> NotificationMap; |
71 | 74 |
72 // Erases a Cocoa notification from both the application and Notification | 75 // Erases a Cocoa notification from both the application and Notification |
73 // Center, and deletes the corresponding C++ object. | 76 // Center, and deletes the corresponding C++ object. |
(...skipping 12 matching lines...) Expand all Loading... |
86 | 89 |
87 // Maps notification_ids to ControllerNotifications. The map owns the value, | 90 // Maps notification_ids to ControllerNotifications. The map owns the value, |
88 // so it must be deleted when remvoed from the map. This is typically handled | 91 // so it must be deleted when remvoed from the map. This is typically handled |
89 // in RemoveNotification. | 92 // in RemoveNotification. |
90 NotificationMap notification_map_; | 93 NotificationMap notification_map_; |
91 | 94 |
92 DISALLOW_COPY_AND_ASSIGN(NotificationUIManagerMac); | 95 DISALLOW_COPY_AND_ASSIGN(NotificationUIManagerMac); |
93 }; | 96 }; |
94 | 97 |
95 #endif // CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_UI_MANAGER_MAC_H_ | 98 #endif // CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_UI_MANAGER_MAC_H_ |
OLD | NEW |