OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CONTENT_CHILD_NOTIFICATIONS_NOTIFICATION_MANAGER_H_ |
| 6 #define CONTENT_CHILD_NOTIFICATIONS_NOTIFICATION_MANAGER_H_ |
| 7 |
| 8 #include <map> |
| 9 |
| 10 #include "base/memory/ref_counted.h" |
| 11 #include "content/child/notifications/notification_dispatcher.h" |
| 12 #include "content/child/worker_task_runner.h" |
| 13 #include "third_party/WebKit/public/platform/WebNotificationManager.h" |
| 14 |
| 15 class SkBitmap; |
| 16 |
| 17 namespace content { |
| 18 |
| 19 class ThreadSafeSender; |
| 20 |
| 21 class NotificationManager : public blink::WebNotificationManager, |
| 22 public WorkerTaskRunner::Observer { |
| 23 public: |
| 24 ~NotificationManager() override; |
| 25 |
| 26 // |thread_safe_sender| and |notification_dispatcher| are used if |
| 27 // calling this leads to construction. |
| 28 static NotificationManager* ThreadSpecificInstance( |
| 29 ThreadSafeSender* thread_safe_sender, |
| 30 NotificationDispatcher* notification_dispatcher); |
| 31 |
| 32 // WorkerTaskRunner::Observer implementation. |
| 33 void OnWorkerRunLoopStopped() override; |
| 34 |
| 35 // blink::WebNotificationManager implementation. |
| 36 virtual void show(const blink::WebSerializedOrigin& origin, |
| 37 const blink::WebNotificationData& notification_data, |
| 38 blink::WebNotificationDelegate* delegate); |
| 39 virtual void close(blink::WebNotificationDelegate* delegate); |
| 40 virtual void notifyDelegateDestroyed( |
| 41 blink::WebNotificationDelegate* delegate); |
| 42 virtual blink::WebNotificationPermission checkPermission( |
| 43 const blink::WebSerializedOrigin& origin); |
| 44 |
| 45 // Called by the NotificationDispatcher. |
| 46 bool OnMessageReceived(const IPC::Message& message); |
| 47 |
| 48 private: |
| 49 NotificationManager( |
| 50 ThreadSafeSender* thread_safe_sender, |
| 51 NotificationDispatcher* notification_dispatcher); |
| 52 |
| 53 scoped_refptr<ThreadSafeSender> thread_safe_sender_; |
| 54 scoped_refptr<NotificationDispatcher> notification_dispatcher_; |
| 55 |
| 56 // Map to store the delegate associated with a notification request Id. |
| 57 std::map<int, blink::WebNotificationDelegate*> active_notifications_; |
| 58 |
| 59 DISALLOW_COPY_AND_ASSIGN(NotificationManager); |
| 60 }; |
| 61 |
| 62 } // namespace content |
| 63 |
| 64 #endif // CONTENT_CHILD_NOTIFICATIONS_NOTIFICATION_MANAGER_H_ |
OLD | NEW |