Index: chrome/browser/notifications/notification_ui_manager_mac.h |
diff --git a/chrome/browser/notifications/notification_ui_manager_mac.h b/chrome/browser/notifications/notification_ui_manager_mac.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..edb35c2f9bdc0683432198d6d0b0323c791b7416 |
--- /dev/null |
+++ b/chrome/browser/notifications/notification_ui_manager_mac.h |
@@ -0,0 +1,81 @@ |
+// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_UI_MANAGER_MAC_H_ |
+#define CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_UI_MANAGER_MAC_H_ |
+#pragma once |
+ |
+#import <AppKit/AppKit.h> |
+ |
+#include <map> |
+ |
+#include "base/basictypes.h" |
+#include "base/memory/scoped_nsobject.h" |
+#include "base/memory/scoped_ptr.h" |
+#include "base/string16.h" |
+#include "chrome/browser/notifications/notification_ui_manager.h" |
+ |
+@protocol CrUserNotification; |
+class Notification; |
+@class NotificationCenterDelegate; |
+class NotificationUIManagerImpl; |
+class PrefService; |
+class Profile; |
+ |
+// This class is an implementation of NotificationUIManager that will send |
+// text-only (non-HTML) notifications to Notification Center on 10.8. This |
+// class is only instantiated on 10.8 and above. For HTML notifications, |
+// this class uses an instance of NotificationUIManagerImpl to present |
+// notifications in the typical way. |
+class NotificationUIManagerMac : public NotificationUIManager { |
+ public: |
+ typedef std::map<id<CrUserNotification>, Notification*> NotificationMap; |
Mark Mentovai
2012/04/09 16:39:41
This typedef doesn’t need to be public, does it?
Robert Sesek
2012/04/09 21:36:38
Done.
|
+ |
+ explicit NotificationUIManagerMac(PrefService* local_state); |
+ virtual ~NotificationUIManagerMac(); |
+ |
+ // NotificationUIManager: |
+ virtual void Add(const Notification& notification, |
+ Profile* profile) OVERRIDE; |
+ virtual bool CancelById(const std::string& notification_id) OVERRIDE; |
+ virtual bool CancelAllBySourceOrigin(const GURL& source_origin) OVERRIDE; |
+ virtual void CancelAll() OVERRIDE; |
+ virtual BalloonCollection* balloon_collection() OVERRIDE; |
+ virtual NotificationPrefsManager* prefs_manager() OVERRIDE; |
+ virtual void GetQueuedNotificationsForTesting( |
+ std::vector<const Notification*>* notifications) OVERRIDE; |
+ |
+ // Returns the corresponding C++ object for the Cocoa notification object, |
+ // or NULL if it could not be found. |
+ const Notification* FindNotificationWithCocoaNotification( |
+ id<CrUserNotification> notif); |
Mark Mentovai
2012/04/09 16:39:41
notif -> notification. Same on line 61.
Robert Sesek
2012/04/09 21:36:38
Done * N
|
+ |
+ NotificationUIManagerImpl* builtin_manager() { |
+ return builtin_manager_.get(); |
+ } |
+ |
+ private: |
+ // Erases a Cocoa notification from both the application and Notification |
+ // Center, and deletes the corresponding C++ object. |
+ bool RemoveNotification(id<CrUserNotification> notif); |
+ |
+ // Finds a notification with a given replacement id. |
+ id<CrUserNotification> FindNotificationWithReplacementId( |
+ const string16& replacement_id); |
+ |
+ // The class used to present HTML notifications that can't be sent to |
+ // Notification Center. |
+ scoped_ptr<NotificationUIManagerImpl> builtin_manager_; |
+ |
+ // Cocoa class that receives callbacks from the NSUserNotificationCenter. |
+ scoped_nsobject<NotificationCenterDelegate> delegate_; |
+ |
+ // A mapping between the Cocoa objects and the C++ objects. Both objects are |
+ // owned, so the key must be released and the value must be deleted. |
Mark Mentovai
2012/04/09 16:39:41
key must be released and the value must be deleted
Robert Sesek
2012/04/09 21:36:38
Done.
|
+ NotificationMap notification_map_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(NotificationUIManagerMac); |
+}; |
+ |
+#endif // CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_UI_MANAGER_MAC_H_ |