OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_CHILD_NOTIFICATIONS_NOTIFICATION_MANAGER_H_ | 5 #ifndef CONTENT_CHILD_NOTIFICATIONS_NOTIFICATION_MANAGER_H_ |
6 #define CONTENT_CHILD_NOTIFICATIONS_NOTIFICATION_MANAGER_H_ | 6 #define CONTENT_CHILD_NOTIFICATIONS_NOTIFICATION_MANAGER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 #include <vector> | 10 #include <vector> |
(...skipping 23 matching lines...) Expand all Loading... |
34 // calling this leads to construction. | 34 // calling this leads to construction. |
35 static NotificationManager* ThreadSpecificInstance( | 35 static NotificationManager* ThreadSpecificInstance( |
36 ThreadSafeSender* thread_safe_sender, | 36 ThreadSafeSender* thread_safe_sender, |
37 base::SingleThreadTaskRunner* main_thread_task_runner, | 37 base::SingleThreadTaskRunner* main_thread_task_runner, |
38 NotificationDispatcher* notification_dispatcher); | 38 NotificationDispatcher* notification_dispatcher); |
39 | 39 |
40 // WorkerTaskRunner::Observer implementation. | 40 // WorkerTaskRunner::Observer implementation. |
41 void OnWorkerRunLoopStopped() override; | 41 void OnWorkerRunLoopStopped() override; |
42 | 42 |
43 // blink::WebNotificationManager implementation. | 43 // blink::WebNotificationManager implementation. |
44 virtual void show(const blink::WebSerializedOrigin& origin, | 44 virtual void show(const blink::WebSecurityOrigin& origin, |
45 const blink::WebNotificationData& notification_data, | 45 const blink::WebNotificationData& notification_data, |
46 blink::WebNotificationDelegate* delegate); | 46 blink::WebNotificationDelegate* delegate); |
47 virtual void showPersistent( | 47 virtual void showPersistent( |
48 const blink::WebSerializedOrigin& origin, | 48 const blink::WebSecurityOrigin& origin, |
49 const blink::WebNotificationData& notification_data, | 49 const blink::WebNotificationData& notification_data, |
50 blink::WebServiceWorkerRegistration* service_worker_registration, | 50 blink::WebServiceWorkerRegistration* service_worker_registration, |
51 blink::WebNotificationShowCallbacks* callbacks); | 51 blink::WebNotificationShowCallbacks* callbacks); |
52 virtual void getNotifications( | 52 virtual void getNotifications( |
53 const blink::WebString& filter_tag, | 53 const blink::WebString& filter_tag, |
54 blink::WebServiceWorkerRegistration* service_worker_registration, | 54 blink::WebServiceWorkerRegistration* service_worker_registration, |
55 blink::WebNotificationGetCallbacks* callbacks); | 55 blink::WebNotificationGetCallbacks* callbacks); |
56 virtual void close(blink::WebNotificationDelegate* delegate); | 56 virtual void close(blink::WebNotificationDelegate* delegate); |
57 virtual void closePersistent( | 57 virtual void closePersistent(const blink::WebSecurityOrigin& origin, |
58 const blink::WebSerializedOrigin& origin, | 58 int64_t persistent_notification_id); |
59 int64_t persistent_notification_id); | |
60 virtual void notifyDelegateDestroyed( | 59 virtual void notifyDelegateDestroyed( |
61 blink::WebNotificationDelegate* delegate); | 60 blink::WebNotificationDelegate* delegate); |
62 virtual blink::WebNotificationPermission checkPermission( | 61 virtual blink::WebNotificationPermission checkPermission( |
63 const blink::WebSerializedOrigin& origin); | 62 const blink::WebSecurityOrigin& origin); |
64 | 63 |
65 // Called by the NotificationDispatcher. | 64 // Called by the NotificationDispatcher. |
66 bool OnMessageReceived(const IPC::Message& message); | 65 bool OnMessageReceived(const IPC::Message& message); |
67 | 66 |
68 private: | 67 private: |
69 NotificationManager( | 68 NotificationManager( |
70 ThreadSafeSender* thread_safe_sender, | 69 ThreadSafeSender* thread_safe_sender, |
71 base::SingleThreadTaskRunner* main_thread_task_runner, | 70 base::SingleThreadTaskRunner* main_thread_task_runner, |
72 NotificationDispatcher* notification_dispatcher); | 71 NotificationDispatcher* notification_dispatcher); |
73 | 72 |
74 // IPC message handlers. | 73 // IPC message handlers. |
75 void OnDidShow(int notification_id); | 74 void OnDidShow(int notification_id); |
76 void OnDidShowPersistent(int request_id, bool success); | 75 void OnDidShowPersistent(int request_id, bool success); |
77 void OnDidClose(int notification_id); | 76 void OnDidClose(int notification_id); |
78 void OnDidClick(int notification_id); | 77 void OnDidClick(int notification_id); |
79 void OnDidGetNotifications( | 78 void OnDidGetNotifications( |
80 int request_id, | 79 int request_id, |
81 const std::vector<PersistentNotificationInfo>& notification_infos); | 80 const std::vector<PersistentNotificationInfo>& notification_infos); |
82 | 81 |
83 // To be called when a page notification is ready to be displayed. Will | 82 // To be called when a page notification is ready to be displayed. Will |
84 // inform the browser process about all available data. The |delegate|, | 83 // inform the browser process about all available data. The |delegate|, |
85 // owned by Blink, will be used to feed back events associated with the | 84 // owned by Blink, will be used to feed back events associated with the |
86 // notification to the JavaScript object. | 85 // notification to the JavaScript object. |
87 void DisplayPageNotification( | 86 void DisplayPageNotification( |
88 const blink::WebSerializedOrigin& origin, | 87 const blink::WebSecurityOrigin& origin, |
89 const blink::WebNotificationData& notification_data, | 88 const blink::WebNotificationData& notification_data, |
90 blink::WebNotificationDelegate* delegate, | 89 blink::WebNotificationDelegate* delegate, |
91 const SkBitmap& icon); | 90 const SkBitmap& icon); |
92 | 91 |
93 // To be called when a persistent notification is ready to be displayed. Will | 92 // To be called when a persistent notification is ready to be displayed. Will |
94 // inform the browser process about all available data. The |callbacks| will | 93 // inform the browser process about all available data. The |callbacks| will |
95 // be used to inform the Promise pending in Blink that the notification has | 94 // be used to inform the Promise pending in Blink that the notification has |
96 // been send to the browser process to be displayed. | 95 // been send to the browser process to be displayed. |
97 void DisplayPersistentNotification( | 96 void DisplayPersistentNotification( |
98 const blink::WebSerializedOrigin& origin, | 97 const blink::WebSecurityOrigin& origin, |
99 const blink::WebNotificationData& notification_data, | 98 const blink::WebNotificationData& notification_data, |
100 int64 service_worker_registration_id, | 99 int64 service_worker_registration_id, |
101 scoped_ptr<blink::WebNotificationShowCallbacks> callbacks, | 100 scoped_ptr<blink::WebNotificationShowCallbacks> callbacks, |
102 const SkBitmap& icon); | 101 const SkBitmap& icon); |
103 | 102 |
104 scoped_refptr<ThreadSafeSender> thread_safe_sender_; | 103 scoped_refptr<ThreadSafeSender> thread_safe_sender_; |
105 scoped_refptr<NotificationDispatcher> notification_dispatcher_; | 104 scoped_refptr<NotificationDispatcher> notification_dispatcher_; |
106 | 105 |
107 // Tracker which stores all pending Notifications, both page and persistent | 106 // Tracker which stores all pending Notifications, both page and persistent |
108 // ones, until all their associated resources have been fetched. | 107 // ones, until all their associated resources have been fetched. |
109 PendingNotificationsTracker pending_notifications_; | 108 PendingNotificationsTracker pending_notifications_; |
110 | 109 |
111 // Tracks pending requests for getting a list of notifications. | 110 // Tracks pending requests for getting a list of notifications. |
112 IDMap<blink::WebNotificationGetCallbacks, IDMapOwnPointer> | 111 IDMap<blink::WebNotificationGetCallbacks, IDMapOwnPointer> |
113 pending_get_notification_requests_; | 112 pending_get_notification_requests_; |
114 | 113 |
115 // Tracks pending requests for displaying persistent notifications. | 114 // Tracks pending requests for displaying persistent notifications. |
116 IDMap<blink::WebNotificationShowCallbacks, IDMapOwnPointer> | 115 IDMap<blink::WebNotificationShowCallbacks, IDMapOwnPointer> |
117 pending_show_notification_requests_; | 116 pending_show_notification_requests_; |
118 | 117 |
119 // Map to store the delegate associated with a notification request Id. | 118 // Map to store the delegate associated with a notification request Id. |
120 std::map<int, blink::WebNotificationDelegate*> active_page_notifications_; | 119 std::map<int, blink::WebNotificationDelegate*> active_page_notifications_; |
121 | 120 |
122 DISALLOW_COPY_AND_ASSIGN(NotificationManager); | 121 DISALLOW_COPY_AND_ASSIGN(NotificationManager); |
123 }; | 122 }; |
124 | 123 |
125 } // namespace content | 124 } // namespace content |
126 | 125 |
127 #endif // CONTENT_CHILD_NOTIFICATIONS_NOTIFICATION_MANAGER_H_ | 126 #endif // CONTENT_CHILD_NOTIFICATIONS_NOTIFICATION_MANAGER_H_ |
OLD | NEW |