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