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 CONTENT_RENDERER_ACTIVE_NOTIFICATION_TRACKER_H_ | 5 #ifndef CONTENT_RENDERER_ACTIVE_NOTIFICATION_TRACKER_H_ |
6 #define CONTENT_RENDERER_ACTIVE_NOTIFICATION_TRACKER_H_ | 6 #define CONTENT_RENDERER_ACTIVE_NOTIFICATION_TRACKER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/containers/hash_tables.h" | 11 #include "base/containers/hash_tables.h" |
12 #include "base/id_map.h" | 12 #include "base/id_map.h" |
13 #include "content/common/content_export.h" | 13 #include "content/common/content_export.h" |
14 #include "third_party/WebKit/public/web/WebNotification.h" | 14 #include "third_party/WebKit/public/web/WebNotification.h" |
15 | 15 |
16 namespace blink { | |
17 class WebNotificationPermissionCallback; | |
18 } | |
19 | |
20 namespace content { | 16 namespace content { |
21 | 17 |
22 // This class manages the set of active Notification objects in either | 18 // This class manages the set of active Notification objects in either |
23 // a render or worker process. This class should be accessed only on | 19 // a render or worker process. This class should be accessed only on |
24 // the main thread. | 20 // the main thread. |
25 class CONTENT_EXPORT ActiveNotificationTracker { | 21 class CONTENT_EXPORT ActiveNotificationTracker { |
26 public: | 22 public: |
27 ActiveNotificationTracker(); | 23 ActiveNotificationTracker(); |
28 ~ActiveNotificationTracker(); | 24 ~ActiveNotificationTracker(); |
29 | 25 |
30 // Methods for tracking active notification objects. | 26 // Methods for tracking active notification objects. |
31 int RegisterNotification(const blink::WebNotification& notification); | 27 int RegisterNotification(const blink::WebNotification& notification); |
32 void UnregisterNotification(int id); | 28 void UnregisterNotification(int id); |
33 bool GetId(const blink::WebNotification& notification, int& id); | 29 bool GetId(const blink::WebNotification& notification, int& id); |
34 bool GetNotification(int id, blink::WebNotification* notification); | 30 bool GetNotification(int id, blink::WebNotification* notification); |
35 | 31 |
36 // Methods for tracking active permission requests. | |
37 int RegisterPermissionRequest( | |
38 blink::WebNotificationPermissionCallback* callback); | |
39 void OnPermissionRequestComplete(int id); | |
40 blink::WebNotificationPermissionCallback* GetCallback(int id); | |
41 | |
42 // Clears out all active notifications. Useful on page navigation. | 32 // Clears out all active notifications. Useful on page navigation. |
43 void Clear(); | 33 void Clear(); |
44 | 34 |
45 private: | 35 private: |
46 typedef std::map<blink::WebNotification, int> ReverseTable; | 36 typedef std::map<blink::WebNotification, int> ReverseTable; |
47 | 37 |
48 // Tracking maps for active notifications and permission requests. | 38 // Tracking maps for active notifications. |
49 IDMap<blink::WebNotification> notification_table_; | 39 IDMap<blink::WebNotification> notification_table_; |
50 ReverseTable reverse_notification_table_; | 40 ReverseTable reverse_notification_table_; |
51 IDMap<blink::WebNotificationPermissionCallback> callback_table_; | |
52 | 41 |
53 DISALLOW_COPY_AND_ASSIGN(ActiveNotificationTracker); | 42 DISALLOW_COPY_AND_ASSIGN(ActiveNotificationTracker); |
54 }; | 43 }; |
55 | 44 |
56 } // namespace content | 45 } // namespace content |
57 | 46 |
58 #endif // CONTENT_RENDERER_ACTIVE_NOTIFICATION_TRACKER_H_ | 47 #endif // CONTENT_RENDERER_ACTIVE_NOTIFICATION_TRACKER_H_ |
OLD | NEW |