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