| 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/WebCommon.h" | 9 #include "public/platform/WebCommon.h" |
| 10 #include "public/platform/WebString.h" | 10 #include "public/platform/WebString.h" |
| 11 #include "public/platform/WebVector.h" | 11 #include "public/platform/WebVector.h" |
| 12 #include "public/platform/modules/notifications/WebNotificationData.h" | 12 #include "public/platform/modules/notifications/WebNotificationData.h" |
| 13 #include "public/platform/modules/notifications/WebNotificationPermission.h" | 13 #include "public/platform/modules/notifications/WebNotificationPermission.h" |
| 14 #include <stdint.h> |
| 14 | 15 |
| 15 namespace blink { | 16 namespace blink { |
| 16 | 17 |
| 17 class WebNotificationDelegate; | 18 class WebNotificationDelegate; |
| 18 class WebSerializedOrigin; | 19 class WebSerializedOrigin; |
| 19 class WebServiceWorkerRegistration; | 20 class WebServiceWorkerRegistration; |
| 20 | 21 |
| 21 // Structure representing the info associated with a persistent notification. | 22 // Structure representing the info associated with a persistent notification. |
| 22 struct WebPersistentNotificationInfo { | 23 struct WebPersistentNotificationInfo { |
| 24 // TODO(peter): Remove the string property when Chromium has switched over. |
| 23 WebString persistentNotificationId; | 25 WebString persistentNotificationId; |
| 26 |
| 27 int64_t persistentId = 0; |
| 24 WebNotificationData data; | 28 WebNotificationData data; |
| 25 }; | 29 }; |
| 26 | 30 |
| 27 using WebNotificationGetCallbacks = WebCallbacks<WebVector<WebPersistentNotifica
tionInfo>, void>; | 31 using WebNotificationGetCallbacks = WebCallbacks<WebVector<WebPersistentNotifica
tionInfo>, void>; |
| 28 using WebNotificationShowCallbacks = WebCallbacks<void, void>; | 32 using WebNotificationShowCallbacks = WebCallbacks<void, void>; |
| 29 | 33 |
| 30 // Provides the services to show platform notifications to the user. | 34 // Provides the services to show platform notifications to the user. |
| 31 class WebNotificationManager { | 35 class WebNotificationManager { |
| 32 public: | 36 public: |
| 33 virtual ~WebNotificationManager() { } | 37 virtual ~WebNotificationManager() { } |
| 34 | 38 |
| 35 // Shows a page notification on the user's system. These notifications will
have their | 39 // Shows a page notification on the user's system. These notifications will
have their |
| 36 // events delivered to the delegate specified in this call. | 40 // events delivered to the delegate specified in this call. |
| 37 virtual void show(const WebSerializedOrigin&, const WebNotificationData&, We
bNotificationDelegate*) = 0; | 41 virtual void show(const WebSerializedOrigin&, const WebNotificationData&, We
bNotificationDelegate*) = 0; |
| 38 | 42 |
| 39 // Shows a persistent notification on the user's system. These notifications
will have | 43 // 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 | 44 // their events delivered to a Service Worker rather than the object's deleg
ate. Will |
| 41 // take ownership of the WebNotificationShowCallbacks object. | 45 // take ownership of the WebNotificationShowCallbacks object. |
| 42 virtual void showPersistent(const WebSerializedOrigin&, const WebNotificatio
nData&, WebServiceWorkerRegistration*, WebNotificationShowCallbacks*) = 0; | 46 virtual void showPersistent(const WebSerializedOrigin&, const WebNotificatio
nData&, WebServiceWorkerRegistration*, WebNotificationShowCallbacks*) = 0; |
| 43 | 47 |
| 44 // Asynchronously gets the persistent notifications belonging to the Service
Worker Registration. | 48 // 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 | 49 // 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
. | 50 // considered. Will take ownership of the WebNotificationGetCallbacks object
. |
| 47 virtual void getNotifications(const WebString& filterTag, WebServiceWorkerRe
gistration*, WebNotificationGetCallbacks*) | 51 virtual void getNotifications(const WebString& filterTag, WebServiceWorkerRe
gistration*, WebNotificationGetCallbacks*) = 0; |
| 48 { | |
| 49 BLINK_ASSERT_NOT_REACHED(); | |
| 50 } | |
| 51 | 52 |
| 52 // Closes a notification previously shown, and removes it if being shown. | 53 // Closes a notification previously shown, and removes it if being shown. |
| 53 virtual void close(WebNotificationDelegate*) = 0; | 54 virtual void close(WebNotificationDelegate*) = 0; |
| 54 | 55 |
| 55 // Closes a persistent notification identified by its persistent notificatio
n Id. | 56 // Closes a persistent notification identified by its persistent notificatio
n Id. |
| 56 virtual void closePersistent(const WebSerializedOrigin&, const WebString& pe
rsistentNotificationId) = 0; | 57 virtual void closePersistent(const WebSerializedOrigin&, int64_t persistentN
otificationId) |
| 58 { |
| 59 BLINK_ASSERT_NOT_REACHED(); |
| 60 } |
| 61 |
| 62 // TODO(peter): Remove this method when the embedder accepts integral persis
tent ids. |
| 63 virtual void closePersistent(const WebSerializedOrigin&, const WebString& pe
rsistentNotificationId) |
| 64 { |
| 65 BLINK_ASSERT_NOT_REACHED(); |
| 66 } |
| 57 | 67 |
| 58 // Indicates that the delegate object is being destroyed, and must no longer | 68 // Indicates that the delegate object is being destroyed, and must no longer |
| 59 // be used by the embedder to dispatch events. | 69 // be used by the embedder to dispatch events. |
| 60 virtual void notifyDelegateDestroyed(WebNotificationDelegate*) = 0; | 70 virtual void notifyDelegateDestroyed(WebNotificationDelegate*) = 0; |
| 61 | 71 |
| 62 // Synchronously checks the permission level for the given origin. | 72 // Synchronously checks the permission level for the given origin. |
| 63 virtual WebNotificationPermission checkPermission(const WebSerializedOrigin&
) = 0; | 73 virtual WebNotificationPermission checkPermission(const WebSerializedOrigin&
) = 0; |
| 64 }; | 74 }; |
| 65 | 75 |
| 66 } // namespace blink | 76 } // namespace blink |
| 67 | 77 |
| 68 #endif // WebNotificationManager_h | 78 #endif // WebNotificationManager_h |
| OLD | NEW |