Fix build break
[chromium-blink-merge.git] / chrome / browser / notifications / notification_ui_manager_mac.h
blob6b95ee29e26fc0e0b7d68b0cac32b3091c838559
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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_UI_MANAGER_MAC_H_
6 #define CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_UI_MANAGER_MAC_H_
8 #import <AppKit/AppKit.h>
10 #include <map>
12 #include "base/basictypes.h"
13 #include "base/memory/scoped_nsobject.h"
14 #include "base/memory/scoped_ptr.h"
15 #include "base/string16.h"
16 #include "chrome/browser/notifications/balloon_notification_ui_manager.h"
18 @protocol CrUserNotification;
19 class Notification;
20 @class NotificationCenterDelegate;
21 class PrefService;
22 class Profile;
24 // This class is an implementation of BalloonNotificationUIManager that will
25 // send text-only (non-HTML) notifications to Notification Center on 10.8. This
26 // class is only instantiated on 10.8 and above. For HTML notifications,
27 // this class delegates to the base class.
28 class NotificationUIManagerMac : public BalloonNotificationUIManager {
29 public:
30 explicit NotificationUIManagerMac(PrefService* local_state);
31 virtual ~NotificationUIManagerMac();
33 // NotificationUIManager:
34 virtual void Add(const Notification& notification,
35 Profile* profile) OVERRIDE;
36 virtual bool CancelById(const std::string& notification_id) OVERRIDE;
37 virtual bool CancelAllBySourceOrigin(const GURL& source_origin) OVERRIDE;
38 virtual bool CancelAllByProfile(Profile* profile) OVERRIDE;
39 virtual void CancelAll() OVERRIDE;
41 // Returns the corresponding C++ object for the Cocoa notification object,
42 // or NULL if it could not be found.
43 const Notification* FindNotificationWithCocoaNotification(
44 id<CrUserNotification> notification) const;
46 private:
47 // A ControllerNotification links the Cocoa (view) notification to the C++
48 // (model) notification. This assumes ownership (i.e. does not retain a_view)
49 // of both objects and will delete them on destruction.
50 struct ControllerNotification {
51 ControllerNotification(Profile* a_profile,
52 id<CrUserNotification> a_view,
53 Notification* a_model);
54 ~ControllerNotification();
56 Profile* profile;
57 id<CrUserNotification> view;
58 Notification* model;
60 private:
61 DISALLOW_COPY_AND_ASSIGN(ControllerNotification);
63 typedef std::map<std::string, ControllerNotification*> NotificationMap;
65 // Erases a Cocoa notification from both the application and Notification
66 // Center, and deletes the corresponding C++ object.
67 bool RemoveNotification(id<CrUserNotification> notification);
69 // Finds a notification with a given replacement id.
70 id<CrUserNotification> FindNotificationWithReplacementId(
71 const string16& replacement_id) const;
73 // Cocoa class that receives callbacks from the NSUserNotificationCenter.
74 scoped_nsobject<NotificationCenterDelegate> delegate_;
76 // Maps notification_ids to ControllerNotifications. The map owns the value,
77 // so it must be deleted when remvoed from the map. This is typically handled
78 // in RemoveNotification.
79 NotificationMap notification_map_;
81 DISALLOW_COPY_AND_ASSIGN(NotificationUIManagerMac);
84 #endif // CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_UI_MANAGER_MAC_H_