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

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: Address comments 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 explicit NotificationUIManagerMac(PrefService* local_state);
34 virtual ~NotificationUIManagerMac();
35
36 // NotificationUIManager:
37 virtual void Add(const Notification& notification,
38 Profile* profile) OVERRIDE;
39 virtual bool CancelById(const std::string& notification_id) OVERRIDE;
40 virtual bool CancelAllBySourceOrigin(const GURL& source_origin) OVERRIDE;
41 virtual void CancelAll() OVERRIDE;
42 virtual BalloonCollection* balloon_collection() OVERRIDE;
43 virtual NotificationPrefsManager* prefs_manager() OVERRIDE;
44 virtual void GetQueuedNotificationsForTesting(
45 std::vector<const Notification*>* notifications) OVERRIDE;
46
47 // Returns the corresponding C++ object for the Cocoa notification object,
48 // or NULL if it could not be found.
49 const Notification* FindNotificationWithCocoaNotification(
jianli 2012/04/10 00:54:14 nit: please add const modifier.
Robert Sesek 2012/04/12 17:48:47 Done.
50 id<CrUserNotification> notification);
51
52 NotificationUIManagerImpl* builtin_manager() {
jianli 2012/04/10 00:54:14 ditto.
Robert Sesek 2012/04/12 17:48:47 Done.
53 return builtin_manager_.get();
54 }
55
56 private:
57 typedef std::map<id<CrUserNotification>, Notification*> NotificationMap;
jianli 2012/04/10 00:54:14 Which scenario do we want to optimize for by using
Robert Sesek 2012/04/12 17:48:47 Good insight! I originally used pointer equality,
58
59 // Erases a Cocoa notification from both the application and Notification
60 // Center, and deletes the corresponding C++ object.
61 bool RemoveNotification(id<CrUserNotification> notification);
62
63 // Finds a notification with a given replacement id.
64 id<CrUserNotification> FindNotificationWithReplacementId(
jianli 2012/04/10 00:54:14 ditto.
Robert Sesek 2012/04/12 17:48:47 Done.
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 when
76 // removed from the map, typically done with RemoveNotification.
77 NotificationMap notification_map_;
78
79 DISALLOW_COPY_AND_ASSIGN(NotificationUIManagerMac);
80 };
81
82 #endif // CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_UI_MANAGER_MAC_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698