Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(102)

Side by Side Diff: chrome/browser/notifications/notification_ui_manager_mac.h

Issue 10021026: [Mac] Implement a NotificationUIManager that uses Notification Center on 10.8 for text notifications (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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.
4
5 #ifndef CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_UI_MANAGER_MAC_H_
6 #define CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_UI_MANAGER_MAC_H_
7 #pragma once
8
9 #import <AppKit/AppKit.h>
10
11 #include <map>
12
13 #include "base/basictypes.h"
14 #include "base/memory/scoped_nsobject.h"
15 #include "base/memory/scoped_ptr.h"
16 #include "base/string16.h"
17 #include "chrome/browser/notifications/notification_ui_manager.h"
18
19 @protocol CrUserNotification;
20 class Notification;
21 @class NotificationCenterDelegate;
22 class NotificationUIManagerImpl;
23 class PrefService;
24 class Profile;
25
26 // This class is an implementation of NotificationUIManager that will send
27 // text-only (non-HTML) notifications to Notification Center on 10.8. This
28 // class is only instantiated on 10.8 and above. For HTML notifications,
29 // this class uses an instance of NotificationUIManagerImpl to present
30 // notifications in the typical way.
31 class NotificationUIManagerMac : public NotificationUIManager {
32 public:
33 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.
34
35 explicit NotificationUIManagerMac(PrefService* local_state);
36 virtual ~NotificationUIManagerMac();
37
38 // NotificationUIManager:
39 virtual void Add(const Notification& notification,
40 Profile* profile) OVERRIDE;
41 virtual bool CancelById(const std::string& notification_id) OVERRIDE;
42 virtual bool CancelAllBySourceOrigin(const GURL& source_origin) OVERRIDE;
43 virtual void CancelAll() OVERRIDE;
44 virtual BalloonCollection* balloon_collection() OVERRIDE;
45 virtual NotificationPrefsManager* prefs_manager() OVERRIDE;
46 virtual void GetQueuedNotificationsForTesting(
47 std::vector<const Notification*>* notifications) OVERRIDE;
48
49 // Returns the corresponding C++ object for the Cocoa notification object,
50 // or NULL if it could not be found.
51 const Notification* FindNotificationWithCocoaNotification(
52 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
53
54 NotificationUIManagerImpl* builtin_manager() {
55 return builtin_manager_.get();
56 }
57
58 private:
59 // Erases a Cocoa notification from both the application and Notification
60 // Center, and deletes the corresponding C++ object.
61 bool RemoveNotification(id<CrUserNotification> notif);
62
63 // Finds a notification with a given replacement id.
64 id<CrUserNotification> FindNotificationWithReplacementId(
65 const string16& replacement_id);
66
67 // The class used to present HTML notifications that can't be sent to
68 // Notification Center.
69 scoped_ptr<NotificationUIManagerImpl> builtin_manager_;
70
71 // Cocoa class that receives callbacks from the NSUserNotificationCenter.
72 scoped_nsobject<NotificationCenterDelegate> delegate_;
73
74 // A mapping between the Cocoa objects and the C++ objects. Both objects are
75 // 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.
76 NotificationMap notification_map_;
77
78 DISALLOW_COPY_AND_ASSIGN(NotificationUIManagerMac);
79 };
80
81 #endif // CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_UI_MANAGER_MAC_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698