[email protected] | f786717 | 2012-07-11 07:04:07 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
[email protected] | 90e90855 | 2009-10-05 01:40:12 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
3 | // found in the LICENSE file. | ||||
4 | |||||
[email protected] | 797c355 | 2011-03-17 00:26:18 | [diff] [blame] | 5 | #ifndef CONTENT_RENDERER_ACTIVE_NOTIFICATION_TRACKER_H_ |
6 | #define CONTENT_RENDERER_ACTIVE_NOTIFICATION_TRACKER_H_ | ||||
[email protected] | 90e90855 | 2009-10-05 01:40:12 | [diff] [blame] | 7 | |
8 | #include <map> | ||||
9 | |||||
10 | #include "base/basictypes.h" | ||||
[email protected] | 14c1c23 | 2013-06-11 17:52:44 | [diff] [blame] | 11 | #include "base/containers/hash_tables.h" |
[email protected] | 90e90855 | 2009-10-05 01:40:12 | [diff] [blame] | 12 | #include "base/id_map.h" |
[email protected] | 03ff5e5 | 2011-09-30 00:28:14 | [diff] [blame] | 13 | #include "content/common/content_export.h" |
[email protected] | 2255a933 | 2013-06-17 05:12:31 | [diff] [blame] | 14 | #include "third_party/WebKit/public/web/WebNotification.h" |
[email protected] | 90e90855 | 2009-10-05 01:40:12 | [diff] [blame] | 15 | |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 16 | namespace blink { |
[email protected] | 90e90855 | 2009-10-05 01:40:12 | [diff] [blame] | 17 | class WebNotificationPermissionCallback; |
18 | } | ||||
19 | |||||
[email protected] | 3827e970 | 2012-10-23 06:19:28 | [diff] [blame] | 20 | namespace content { |
21 | |||||
[email protected] | 90e90855 | 2009-10-05 01:40:12 | [diff] [blame] | 22 | // This class manages the set of active Notification objects in either |
23 | // a render or worker process. This class should be accessed only on | ||||
24 | // the main thread. | ||||
[email protected] | 03ff5e5 | 2011-09-30 00:28:14 | [diff] [blame] | 25 | class CONTENT_EXPORT ActiveNotificationTracker { |
[email protected] | 90e90855 | 2009-10-05 01:40:12 | [diff] [blame] | 26 | public: |
[email protected] | 2858bbf | 2010-10-05 23:46:02 | [diff] [blame] | 27 | ActiveNotificationTracker(); |
28 | ~ActiveNotificationTracker(); | ||||
[email protected] | 90e90855 | 2009-10-05 01:40:12 | [diff] [blame] | 29 | |
30 | // Methods for tracking active notification objects. | ||||
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 31 | int RegisterNotification(const blink::WebNotification& notification); |
[email protected] | 90e90855 | 2009-10-05 01:40:12 | [diff] [blame] | 32 | void UnregisterNotification(int id); |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 33 | bool GetId(const blink::WebNotification& notification, int& id); |
34 | bool GetNotification(int id, blink::WebNotification* notification); | ||||
[email protected] | 90e90855 | 2009-10-05 01:40:12 | [diff] [blame] | 35 | |
36 | // Methods for tracking active permission requests. | ||||
37 | int RegisterPermissionRequest( | ||||
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 38 | blink::WebNotificationPermissionCallback* callback); |
[email protected] | 90e90855 | 2009-10-05 01:40:12 | [diff] [blame] | 39 | void OnPermissionRequestComplete(int id); |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 40 | blink::WebNotificationPermissionCallback* GetCallback(int id); |
[email protected] | 90e90855 | 2009-10-05 01:40:12 | [diff] [blame] | 41 | |
[email protected] | 42219753 | 2010-01-25 17:38:23 | [diff] [blame] | 42 | // Clears out all active notifications. Useful on page navigation. |
43 | void Clear(); | ||||
44 | |||||
[email protected] | 90e90855 | 2009-10-05 01:40:12 | [diff] [blame] | 45 | private: |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 46 | typedef std::map<blink::WebNotification, int> ReverseTable; |
[email protected] | 90e90855 | 2009-10-05 01:40:12 | [diff] [blame] | 47 | |
48 | // Tracking maps for active notifications and permission requests. | ||||
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 49 | IDMap<blink::WebNotification> notification_table_; |
[email protected] | 90e90855 | 2009-10-05 01:40:12 | [diff] [blame] | 50 | ReverseTable reverse_notification_table_; |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 51 | IDMap<blink::WebNotificationPermissionCallback> callback_table_; |
[email protected] | 90e90855 | 2009-10-05 01:40:12 | [diff] [blame] | 52 | |
53 | DISALLOW_COPY_AND_ASSIGN(ActiveNotificationTracker); | ||||
54 | }; | ||||
55 | |||||
[email protected] | 3827e970 | 2012-10-23 06:19:28 | [diff] [blame] | 56 | } // namespace content |
57 | |||||
[email protected] | 797c355 | 2011-03-17 00:26:18 | [diff] [blame] | 58 | #endif // CONTENT_RENDERER_ACTIVE_NOTIFICATION_TRACKER_H_ |