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 WebNotificationManager_h | 5 #ifndef WebNotificationManager_h |
6 #define WebNotificationManager_h | 6 #define WebNotificationManager_h |
7 | 7 |
8 #include "public/platform/WebCallbacks.h" | 8 #include "public/platform/WebCallbacks.h" |
9 #include "public/platform/WebString.h" | 9 #include "public/platform/WebString.h" |
10 #include "public/platform/WebVector.h" | 10 #include "public/platform/WebVector.h" |
11 #include "public/platform/modules/notifications/WebNotificationData.h" | 11 #include "public/platform/modules/notifications/WebNotificationData.h" |
12 #include "public/platform/modules/notifications/WebNotificationPermission.h" | 12 #include "public/platform/modules/notifications/WebNotificationPermission.h" |
| 13 #include "public/platform/modules/notifications/WebNotificationResources.h" |
| 14 #include <memory> |
13 #include <stdint.h> | 15 #include <stdint.h> |
14 | 16 |
15 namespace blink { | 17 namespace blink { |
16 | 18 |
17 class WebNotificationDelegate; | 19 class WebNotificationDelegate; |
18 class WebSecurityOrigin; | 20 class WebSecurityOrigin; |
19 class WebServiceWorkerRegistration; | 21 class WebServiceWorkerRegistration; |
20 | 22 |
21 // Structure representing the info associated with a persistent notification. | 23 // Structure representing the info associated with a persistent notification. |
22 struct WebPersistentNotificationInfo { | 24 struct WebPersistentNotificationInfo { |
23 int64_t persistentId = 0; | 25 int64_t persistentId = 0; |
24 WebNotificationData data; | 26 WebNotificationData data; |
25 }; | 27 }; |
26 | 28 |
27 using WebNotificationGetCallbacks = WebCallbacks<const WebVector<WebPersistentNo
tificationInfo>&, void>; | 29 using WebNotificationGetCallbacks = WebCallbacks<const WebVector<WebPersistentNo
tificationInfo>&, void>; |
28 using WebNotificationShowCallbacks = WebCallbacks<void, void>; | 30 using WebNotificationShowCallbacks = WebCallbacks<void, void>; |
29 | 31 |
30 // Provides the services to show platform notifications to the user. | 32 // Provides the services to show platform notifications to the user. |
31 class WebNotificationManager { | 33 class WebNotificationManager { |
32 public: | 34 public: |
33 virtual ~WebNotificationManager() { } | 35 virtual ~WebNotificationManager() { } |
34 | 36 |
35 // Shows a page notification on the user's system. These notifications will
have their | 37 // Shows a page notification on the user's system. These notifications will
have their |
36 // events delivered to the delegate specified in this call. | 38 // events delivered to the delegate specified in this call. |
37 virtual void show(const WebSecurityOrigin&, const WebNotificationData&, WebN
otificationDelegate*) = 0; | 39 virtual void show(const WebSecurityOrigin&, const WebNotificationData&, std:
:unique_ptr<WebNotificationResources>, WebNotificationDelegate*) = 0; |
38 | 40 |
39 // Shows a persistent notification on the user's system. These notifications
will have | 41 // Shows a persistent notification on the user's system. These notifications
will have |
40 // their events delivered to a Service Worker rather than the object's deleg
ate. Will | 42 // their events delivered to a Service Worker rather than the object's deleg
ate. Will |
41 // take ownership of the WebNotificationShowCallbacks object. | 43 // take ownership of the WebNotificationShowCallbacks object. |
42 virtual void showPersistent(const WebSecurityOrigin&, const WebNotificationD
ata&, WebServiceWorkerRegistration*, WebNotificationShowCallbacks*) = 0; | 44 virtual void showPersistent(const WebSecurityOrigin&, const WebNotificationD
ata&, std::unique_ptr<WebNotificationResources>, WebServiceWorkerRegistration*,
WebNotificationShowCallbacks*) = 0; |
43 | 45 |
44 // Asynchronously gets the persistent notifications belonging to the Service
Worker Registration. | 46 // Asynchronously gets the persistent notifications belonging to the Service
Worker Registration. |
45 // If |filterTag| is not an empty string, only the notification with the giv
en tag will be | 47 // If |filterTag| is not an empty string, only the notification with the giv
en tag will be |
46 // considered. Will take ownership of the WebNotificationGetCallbacks object
. | 48 // considered. Will take ownership of the WebNotificationGetCallbacks object
. |
47 virtual void getNotifications(const WebString& filterTag, WebServiceWorkerRe
gistration*, WebNotificationGetCallbacks*) = 0; | 49 virtual void getNotifications(const WebString& filterTag, WebServiceWorkerRe
gistration*, WebNotificationGetCallbacks*) = 0; |
48 | 50 |
49 // Closes a notification previously shown, and removes it if being shown. | 51 // Closes a notification previously shown, and removes it if being shown. |
50 virtual void close(WebNotificationDelegate*) = 0; | 52 virtual void close(WebNotificationDelegate*) = 0; |
51 | 53 |
52 // Closes a persistent notification identified by its persistent notificatio
n Id. | 54 // Closes a persistent notification identified by its persistent notificatio
n Id. |
53 virtual void closePersistent(const WebSecurityOrigin&, int64_t persistentNot
ificationId) = 0; | 55 virtual void closePersistent(const WebSecurityOrigin&, int64_t persistentNot
ificationId) = 0; |
54 | 56 |
55 // Indicates that the delegate object is being destroyed, and must no longer | 57 // Indicates that the delegate object is being destroyed, and must no longer |
56 // be used by the embedder to dispatch events. | 58 // be used by the embedder to dispatch events. |
57 virtual void notifyDelegateDestroyed(WebNotificationDelegate*) = 0; | 59 virtual void notifyDelegateDestroyed(WebNotificationDelegate*) = 0; |
58 | 60 |
59 // Synchronously checks the permission level for the given origin. | 61 // Synchronously checks the permission level for the given origin. |
60 virtual WebNotificationPermission checkPermission(const WebSecurityOrigin&)
= 0; | 62 virtual WebNotificationPermission checkPermission(const WebSecurityOrigin&)
= 0; |
61 | 63 |
62 // Returns the maximum number of actions supported by the embedder. | 64 // Returns the maximum number of actions supported by the embedder. |
63 virtual size_t maxActions() = 0; | 65 virtual size_t maxActions() = 0; |
64 }; | 66 }; |
65 | 67 |
66 } // namespace blink | 68 } // namespace blink |
67 | 69 |
68 #endif // WebNotificationManager_h | 70 #endif // WebNotificationManager_h |
OLD | NEW |