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

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: 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 // TODO(peter): Remove this method when Blink has been updated. 60 // TODO(peter): Remove this method when Blink has been updated.
johnme 2015/03/18 15:03:06 <offtopic> Is this being removed by some other CL?
Peter Beverloo 2015/03/19 15:46:44 One that landed two days ago :-).
53 virtual void closePersistent( 61 virtual void closePersistent(
54 const blink::WebString& persistent_notification_id); 62 const blink::WebString& persistent_notification_id);
55 virtual void notifyDelegateDestroyed( 63 virtual void notifyDelegateDestroyed(
56 blink::WebNotificationDelegate* delegate); 64 blink::WebNotificationDelegate* delegate);
57 virtual blink::WebNotificationPermission checkPermission( 65 virtual blink::WebNotificationPermission checkPermission(
58 const blink::WebSerializedOrigin& origin); 66 const blink::WebSerializedOrigin& origin);
59 67
60 // Called by the NotificationDispatcher. 68 // Called by the NotificationDispatcher.
61 bool OnMessageReceived(const IPC::Message& message); 69 bool OnMessageReceived(const IPC::Message& message);
62 70
63 private: 71 private:
64 NotificationManager( 72 NotificationManager(
65 ThreadSafeSender* thread_safe_sender, 73 ThreadSafeSender* thread_safe_sender,
66 base::SingleThreadTaskRunner* main_thread_task_runner, 74 base::SingleThreadTaskRunner* main_thread_task_runner,
67 NotificationDispatcher* notification_dispatcher); 75 NotificationDispatcher* notification_dispatcher);
68 76
69 // IPC message handlers. 77 // IPC message handlers.
70 void OnDidShow(int notification_id); 78 void OnDidShow(int notification_id);
71 void OnDidClose(int notification_id); 79 void OnDidClose(int notification_id);
72 void OnDidClick(int notification_id); 80 void OnDidClick(int notification_id);
81 void OnDidGetNotifications(
82 int request_id,
83 const std::vector<PersistentNotificationInfo>& notification_infos);
73 84
74 // 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
75 // inform the browser process about all available data. The |delegate|, 86 // inform the browser process about all available data. The |delegate|,
76 // 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
77 // notification to the JavaScript object. 88 // notification to the JavaScript object.
78 void DisplayPageNotification( 89 void DisplayPageNotification(
79 const blink::WebSerializedOrigin& origin, 90 const blink::WebSerializedOrigin& origin,
80 const blink::WebNotificationData& notification_data, 91 const blink::WebNotificationData& notification_data,
81 blink::WebNotificationDelegate* delegate, 92 blink::WebNotificationDelegate* delegate,
82 const SkBitmap& icon); 93 const SkBitmap& icon);
83 94
84 // 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
85 // inform the browser process about all available data. The |callbacks| will 96 // inform the browser process about all available data. The |callbacks| will
86 // 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
87 // been send to the browser process to be displayed. 98 // been send to the browser process to be displayed.
88 void DisplayPersistentNotification( 99 void DisplayPersistentNotification(
89 const blink::WebSerializedOrigin& origin, 100 const blink::WebSerializedOrigin& origin,
90 const blink::WebNotificationData& notification_data, 101 const blink::WebNotificationData& notification_data,
91 int64 service_worker_registration_id, 102 int64 service_worker_registration_id,
92 scoped_ptr<blink::WebNotificationShowCallbacks> callbacks, 103 scoped_ptr<blink::WebNotificationShowCallbacks> callbacks,
93 const SkBitmap& icon); 104 const SkBitmap& icon);
94 105
95 scoped_refptr<ThreadSafeSender> thread_safe_sender_; 106 scoped_refptr<ThreadSafeSender> thread_safe_sender_;
96 scoped_refptr<NotificationDispatcher> notification_dispatcher_; 107 scoped_refptr<NotificationDispatcher> notification_dispatcher_;
97 108
98 // Tracker which stores all pending Notifications, both page and persistent 109 // Tracker which stores all pending Notifications, both page and persistent
99 // ones, until all their associated resources have been fetched. 110 // ones, until all their associated resources have been fetched.
100 PendingNotificationsTracker pending_notifications_; 111 PendingNotificationsTracker pending_notifications_;
101 112
113 // Tracks pending requests for getting a list of notifications.
114 IDMap<blink::WebNotificationGetCallbacks, IDMapOwnPointer>
115 pending_get_notification_requests_;
116
102 // Map to store the delegate associated with a notification request Id. 117 // Map to store the delegate associated with a notification request Id.
103 std::map<int, blink::WebNotificationDelegate*> active_page_notifications_; 118 std::map<int, blink::WebNotificationDelegate*> active_page_notifications_;
104 119
105 DISALLOW_COPY_AND_ASSIGN(NotificationManager); 120 DISALLOW_COPY_AND_ASSIGN(NotificationManager);
106 }; 121 };
107 122
108 } // namespace content 123 } // namespace content
109 124
110 #endif // CONTENT_CHILD_NOTIFICATIONS_NOTIFICATION_MANAGER_H_ 125 #endif // CONTENT_CHILD_NOTIFICATIONS_NOTIFICATION_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698