Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(148)

Side by Side Diff: content/child/notifications/notification_manager.h

Issue 1014073002: Implement getting notifications up to the browser process. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comments Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 11
12 #include "base/id_map.h"
11 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
12 #include "base/single_thread_task_runner.h" 14 #include "base/single_thread_task_runner.h"
13 #include "content/child/notifications/notification_dispatcher.h" 15 #include "content/child/notifications/notification_dispatcher.h"
14 #include "content/child/notifications/pending_notifications_tracker.h" 16 #include "content/child/notifications/pending_notifications_tracker.h"
15 #include "content/child/worker_task_runner.h" 17 #include "content/child/worker_task_runner.h"
18 #include "content/common/platform_notification_messages.h"
16 #include "third_party/WebKit/public/platform/modules/notifications/WebNotificati onManager.h" 19 #include "third_party/WebKit/public/platform/modules/notifications/WebNotificati onManager.h"
17 20
18 class SkBitmap; 21 class SkBitmap;
19 22
20 namespace content { 23 namespace content {
21 24
25 struct PlatformNotificationData;
22 class ThreadSafeSender; 26 class ThreadSafeSender;
23 27
24 class NotificationManager : public blink::WebNotificationManager, 28 class NotificationManager : public blink::WebNotificationManager,
25 public WorkerTaskRunner::Observer { 29 public WorkerTaskRunner::Observer {
26 public: 30 public:
27 ~NotificationManager() override; 31 ~NotificationManager() override;
28 32
29 // |thread_safe_sender| and |notification_dispatcher| are used if 33 // |thread_safe_sender| and |notification_dispatcher| are used if
30 // calling this leads to construction. 34 // calling this leads to construction.
31 static NotificationManager* ThreadSpecificInstance( 35 static NotificationManager* ThreadSpecificInstance(
32 ThreadSafeSender* thread_safe_sender, 36 ThreadSafeSender* thread_safe_sender,
33 base::SingleThreadTaskRunner* main_thread_task_runner, 37 base::SingleThreadTaskRunner* main_thread_task_runner,
34 NotificationDispatcher* notification_dispatcher); 38 NotificationDispatcher* notification_dispatcher);
35 39
36 // WorkerTaskRunner::Observer implementation. 40 // WorkerTaskRunner::Observer implementation.
37 void OnWorkerRunLoopStopped() override; 41 void OnWorkerRunLoopStopped() override;
38 42
39 // blink::WebNotificationManager implementation. 43 // blink::WebNotificationManager implementation.
40 virtual void show(const blink::WebSerializedOrigin& origin, 44 virtual void show(const blink::WebSerializedOrigin& origin,
41 const blink::WebNotificationData& notification_data, 45 const blink::WebNotificationData& notification_data,
42 blink::WebNotificationDelegate* delegate); 46 blink::WebNotificationDelegate* delegate);
43 virtual void showPersistent( 47 virtual void showPersistent(
44 const blink::WebSerializedOrigin& origin, 48 const blink::WebSerializedOrigin& origin,
45 const blink::WebNotificationData& notification_data, 49 const blink::WebNotificationData& notification_data,
46 blink::WebServiceWorkerRegistration* service_worker_registration, 50 blink::WebServiceWorkerRegistration* service_worker_registration,
47 blink::WebNotificationShowCallbacks* callbacks); 51 blink::WebNotificationShowCallbacks* callbacks);
52 virtual void getNotifications(
53 const blink::WebString& filter_tag,
54 blink::WebServiceWorkerRegistration* service_worker_registration,
55 blink::WebNotificationGetCallbacks* callbacks);
48 virtual void close(blink::WebNotificationDelegate* delegate); 56 virtual void close(blink::WebNotificationDelegate* delegate);
49 virtual void closePersistent( 57 virtual void closePersistent(
50 const blink::WebSerializedOrigin& origin, 58 const blink::WebSerializedOrigin& origin,
51 const blink::WebString& persistent_notification_id); 59 const blink::WebString& persistent_notification_id);
52 virtual void notifyDelegateDestroyed( 60 virtual void notifyDelegateDestroyed(
53 blink::WebNotificationDelegate* delegate); 61 blink::WebNotificationDelegate* delegate);
54 virtual blink::WebNotificationPermission checkPermission( 62 virtual blink::WebNotificationPermission checkPermission(
55 const blink::WebSerializedOrigin& origin); 63 const blink::WebSerializedOrigin& origin);
56 64
57 // Called by the NotificationDispatcher. 65 // Called by the NotificationDispatcher.
58 bool OnMessageReceived(const IPC::Message& message); 66 bool OnMessageReceived(const IPC::Message& message);
59 67
60 private: 68 private:
61 NotificationManager( 69 NotificationManager(
62 ThreadSafeSender* thread_safe_sender, 70 ThreadSafeSender* thread_safe_sender,
63 base::SingleThreadTaskRunner* main_thread_task_runner, 71 base::SingleThreadTaskRunner* main_thread_task_runner,
64 NotificationDispatcher* notification_dispatcher); 72 NotificationDispatcher* notification_dispatcher);
65 73
66 // IPC message handlers. 74 // IPC message handlers.
67 void OnDidShow(int notification_id); 75 void OnDidShow(int notification_id);
68 void OnDidClose(int notification_id); 76 void OnDidClose(int notification_id);
69 void OnDidClick(int notification_id); 77 void OnDidClick(int notification_id);
78 void OnDidGetNotifications(
79 int request_id,
80 const std::vector<PersistentNotificationInfo>& notification_infos);
70 81
71 // 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
72 // inform the browser process about all available data. The |delegate|, 83 // inform the browser process about all available data. The |delegate|,
73 // 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
74 // notification to the JavaScript object. 85 // notification to the JavaScript object.
75 void DisplayPageNotification( 86 void DisplayPageNotification(
76 const blink::WebSerializedOrigin& origin, 87 const blink::WebSerializedOrigin& origin,
77 const blink::WebNotificationData& notification_data, 88 const blink::WebNotificationData& notification_data,
78 blink::WebNotificationDelegate* delegate, 89 blink::WebNotificationDelegate* delegate,
79 const SkBitmap& icon); 90 const SkBitmap& icon);
80 91
81 // 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
82 // inform the browser process about all available data. The |callbacks| will 93 // inform the browser process about all available data. The |callbacks| will
83 // 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
84 // been send to the browser process to be displayed. 95 // been send to the browser process to be displayed.
85 void DisplayPersistentNotification( 96 void DisplayPersistentNotification(
86 const blink::WebSerializedOrigin& origin, 97 const blink::WebSerializedOrigin& origin,
87 const blink::WebNotificationData& notification_data, 98 const blink::WebNotificationData& notification_data,
88 int64 service_worker_registration_id, 99 int64 service_worker_registration_id,
89 scoped_ptr<blink::WebNotificationShowCallbacks> callbacks, 100 scoped_ptr<blink::WebNotificationShowCallbacks> callbacks,
90 const SkBitmap& icon); 101 const SkBitmap& icon);
91 102
92 scoped_refptr<ThreadSafeSender> thread_safe_sender_; 103 scoped_refptr<ThreadSafeSender> thread_safe_sender_;
93 scoped_refptr<NotificationDispatcher> notification_dispatcher_; 104 scoped_refptr<NotificationDispatcher> notification_dispatcher_;
94 105
95 // Tracker which stores all pending Notifications, both page and persistent 106 // Tracker which stores all pending Notifications, both page and persistent
96 // ones, until all their associated resources have been fetched. 107 // ones, until all their associated resources have been fetched.
97 PendingNotificationsTracker pending_notifications_; 108 PendingNotificationsTracker pending_notifications_;
98 109
110 // Tracks pending requests for getting a list of notifications.
111 IDMap<blink::WebNotificationGetCallbacks, IDMapOwnPointer>
112 pending_get_notification_requests_;
113
99 // Map to store the delegate associated with a notification request Id. 114 // Map to store the delegate associated with a notification request Id.
100 std::map<int, blink::WebNotificationDelegate*> active_page_notifications_; 115 std::map<int, blink::WebNotificationDelegate*> active_page_notifications_;
101 116
102 DISALLOW_COPY_AND_ASSIGN(NotificationManager); 117 DISALLOW_COPY_AND_ASSIGN(NotificationManager);
103 }; 118 };
104 119
105 } // namespace content 120 } // namespace content
106 121
107 #endif // CONTENT_CHILD_NOTIFICATIONS_NOTIFICATION_MANAGER_H_ 122 #endif // CONTENT_CHILD_NOTIFICATIONS_NOTIFICATION_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698