| 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 <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| 11 #include <map> | 11 #include <map> |
| 12 #include <set> | 12 #include <set> |
| 13 #include <vector> | 13 #include <vector> |
| 14 | 14 |
| 15 #include "base/id_map.h" | 15 #include "base/id_map.h" |
| 16 #include "base/macros.h" | 16 #include "base/macros.h" |
| 17 #include "base/memory/ref_counted.h" | 17 #include "base/memory/ref_counted.h" |
| 18 #include "base/single_thread_task_runner.h" | 18 #include "base/single_thread_task_runner.h" |
| 19 #include "content/child/notifications/notification_dispatcher.h" | 19 #include "content/child/notifications/notification_dispatcher.h" |
| 20 #include "content/child/notifications/pending_notifications_tracker.h" | 20 #include "content/child/notifications/pending_notifications_tracker.h" |
| 21 #include "content/common/platform_notification_messages.h" | 21 #include "content/common/platform_notification_messages.h" |
| 22 #include "content/public/child/worker_thread.h" | 22 #include "content/public/child/worker_thread.h" |
| 23 #include "third_party/WebKit/public/platform/modules/notifications/WebNotificati
onManager.h" | 23 #include "third_party/WebKit/public/platform/modules/notifications/WebNotificati
onManager.h" |
| 24 | 24 |
| 25 class SkBitmap; | |
| 26 | |
| 27 namespace content { | 25 namespace content { |
| 28 | 26 |
| 27 struct NotificationResources; |
| 29 struct PlatformNotificationData; | 28 struct PlatformNotificationData; |
| 30 class ThreadSafeSender; | 29 class ThreadSafeSender; |
| 31 | 30 |
| 32 class NotificationManager : public blink::WebNotificationManager, | 31 class NotificationManager : public blink::WebNotificationManager, |
| 33 public WorkerThread::Observer { | 32 public WorkerThread::Observer { |
| 34 public: | 33 public: |
| 35 ~NotificationManager() override; | 34 ~NotificationManager() override; |
| 36 | 35 |
| 37 // |thread_safe_sender| and |notification_dispatcher| are used if | 36 // |thread_safe_sender| and |notification_dispatcher| are used if |
| 38 // calling this leads to construction. | 37 // calling this leads to construction. |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 const std::vector<PersistentNotificationInfo>& notification_infos); | 83 const std::vector<PersistentNotificationInfo>& notification_infos); |
| 85 | 84 |
| 86 // To be called when a page notification is ready to be displayed. Will | 85 // To be called when a page notification is ready to be displayed. Will |
| 87 // inform the browser process about all available data. The |delegate|, | 86 // inform the browser process about all available data. The |delegate|, |
| 88 // owned by Blink, will be used to feed back events associated with the | 87 // owned by Blink, will be used to feed back events associated with the |
| 89 // notification to the JavaScript object. | 88 // notification to the JavaScript object. |
| 90 void DisplayPageNotification( | 89 void DisplayPageNotification( |
| 91 const blink::WebSecurityOrigin& origin, | 90 const blink::WebSecurityOrigin& origin, |
| 92 const blink::WebNotificationData& notification_data, | 91 const blink::WebNotificationData& notification_data, |
| 93 blink::WebNotificationDelegate* delegate, | 92 blink::WebNotificationDelegate* delegate, |
| 94 const SkBitmap& icon); | 93 const NotificationResources& notification_resources); |
| 95 | 94 |
| 96 // To be called when a persistent notification is ready to be displayed. Will | 95 // To be called when a persistent notification is ready to be displayed. Will |
| 97 // inform the browser process about all available data. The |callbacks| will | 96 // inform the browser process about all available data. The |callbacks| will |
| 98 // be used to inform the Promise pending in Blink that the notification has | 97 // be used to inform the Promise pending in Blink that the notification has |
| 99 // been send to the browser process to be displayed. | 98 // been send to the browser process to be displayed. |
| 100 void DisplayPersistentNotification( | 99 void DisplayPersistentNotification( |
| 101 const blink::WebSecurityOrigin& origin, | 100 const blink::WebSecurityOrigin& origin, |
| 102 const blink::WebNotificationData& notification_data, | 101 const blink::WebNotificationData& notification_data, |
| 103 int64_t service_worker_registration_id, | 102 int64_t service_worker_registration_id, |
| 104 scoped_ptr<blink::WebNotificationShowCallbacks> callbacks, | 103 scoped_ptr<blink::WebNotificationShowCallbacks> callbacks, |
| 105 const SkBitmap& icon); | 104 const NotificationResources& notification_resources); |
| 106 | 105 |
| 107 scoped_refptr<ThreadSafeSender> thread_safe_sender_; | 106 scoped_refptr<ThreadSafeSender> thread_safe_sender_; |
| 108 scoped_refptr<NotificationDispatcher> notification_dispatcher_; | 107 scoped_refptr<NotificationDispatcher> notification_dispatcher_; |
| 109 | 108 |
| 110 // Tracker which stores all pending Notifications, both page and persistent | 109 // Tracker which stores all pending Notifications, both page and persistent |
| 111 // ones, until all their associated resources have been fetched. | 110 // ones, until all their associated resources have been fetched. |
| 112 PendingNotificationsTracker pending_notifications_; | 111 PendingNotificationsTracker notifications_tracker_; |
| 113 | 112 |
| 114 // Tracks pending requests for getting a list of notifications. | 113 // Tracks pending requests for getting a list of notifications. |
| 115 IDMap<blink::WebNotificationGetCallbacks, IDMapOwnPointer> | 114 IDMap<blink::WebNotificationGetCallbacks, IDMapOwnPointer> |
| 116 pending_get_notification_requests_; | 115 pending_get_notification_requests_; |
| 117 | 116 |
| 118 // Tracks pending requests for displaying persistent notifications. | 117 // Tracks pending requests for displaying persistent notifications. |
| 119 IDMap<blink::WebNotificationShowCallbacks, IDMapOwnPointer> | 118 IDMap<blink::WebNotificationShowCallbacks, IDMapOwnPointer> |
| 120 pending_show_notification_requests_; | 119 pending_show_notification_requests_; |
| 121 | 120 |
| 122 // Map to store the delegate associated with a notification request Id. | 121 // Map to store the delegate associated with a notification request Id. |
| 123 std::map<int, blink::WebNotificationDelegate*> active_page_notifications_; | 122 std::map<int, blink::WebNotificationDelegate*> active_page_notifications_; |
| 124 | 123 |
| 125 DISALLOW_COPY_AND_ASSIGN(NotificationManager); | 124 DISALLOW_COPY_AND_ASSIGN(NotificationManager); |
| 126 }; | 125 }; |
| 127 | 126 |
| 128 } // namespace content | 127 } // namespace content |
| 129 | 128 |
| 130 #endif // CONTENT_CHILD_NOTIFICATIONS_NOTIFICATION_MANAGER_H_ | 129 #endif // CONTENT_CHILD_NOTIFICATIONS_NOTIFICATION_MANAGER_H_ |
| OLD | NEW |