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 WebPushProvider_h | 5 #ifndef WebPushProvider_h |
6 #define WebPushProvider_h | 6 #define WebPushProvider_h |
7 | 7 |
8 #include "public/platform/WebCallbacks.h" | 8 #include "public/platform/WebCallbacks.h" |
9 #include "public/platform/WebPassOwnPtr.h" | |
10 #include "public/platform/modules/push_messaging/WebPushPermissionStatus.h" | 9 #include "public/platform/modules/push_messaging/WebPushPermissionStatus.h" |
11 #include "public/platform/modules/push_messaging/WebPushSubscription.h" | 10 #include "public/platform/modules/push_messaging/WebPushSubscription.h" |
12 | 11 |
| 12 #include <memory> |
| 13 |
13 namespace blink { | 14 namespace blink { |
14 | 15 |
15 class WebServiceWorkerRegistration; | 16 class WebServiceWorkerRegistration; |
16 struct WebPushError; | 17 struct WebPushError; |
17 struct WebPushSubscriptionOptions; | 18 struct WebPushSubscriptionOptions; |
18 | 19 |
19 using WebPushSubscriptionCallbacks = WebCallbacks<WebPassOwnPtr<WebPushSubscript
ion>, const WebPushError&>; | 20 using WebPushSubscriptionCallbacks = WebCallbacks<std::unique_ptr<WebPushSubscri
ption>, const WebPushError&>; |
20 using WebPushPermissionStatusCallbacks = WebCallbacks<WebPushPermissionStatus, c
onst WebPushError&>; | 21 using WebPushPermissionStatusCallbacks = WebCallbacks<WebPushPermissionStatus, c
onst WebPushError&>; |
21 using WebPushUnsubscribeCallbacks = WebCallbacks<bool, const WebPushError&>; | 22 using WebPushUnsubscribeCallbacks = WebCallbacks<bool, const WebPushError&>; |
22 | 23 |
23 class WebPushProvider { | 24 class WebPushProvider { |
24 public: | 25 public: |
25 virtual ~WebPushProvider() { } | 26 virtual ~WebPushProvider() { } |
26 | 27 |
27 // Takes ownership of the WebPushSubscriptionCallbacks. | 28 // Takes ownership of the WebPushSubscriptionCallbacks. |
28 // Does not take ownership of the WebServiceWorkerRegistration. | 29 // Does not take ownership of the WebServiceWorkerRegistration. |
29 virtual void subscribe(WebServiceWorkerRegistration*, const WebPushSubscript
ionOptions&, WebPushSubscriptionCallbacks*) = 0; | 30 virtual void subscribe(WebServiceWorkerRegistration*, const WebPushSubscript
ionOptions&, WebPushSubscriptionCallbacks*) = 0; |
30 | 31 |
31 // Takes ownership of the WebPushSubscriptionCallbacks. | 32 // Takes ownership of the WebPushSubscriptionCallbacks. |
32 // Does not take ownership of the WebServiceWorkerRegistration. | 33 // Does not take ownership of the WebServiceWorkerRegistration. |
33 virtual void getSubscription(WebServiceWorkerRegistration*, WebPushSubscript
ionCallbacks*) = 0; | 34 virtual void getSubscription(WebServiceWorkerRegistration*, WebPushSubscript
ionCallbacks*) = 0; |
34 | 35 |
35 // Takes ownership of the WebPushPermissionStatusCallbacks. | 36 // Takes ownership of the WebPushPermissionStatusCallbacks. |
36 // Does not take ownership of the WebServiceWorkerRegistration. | 37 // Does not take ownership of the WebServiceWorkerRegistration. |
37 virtual void getPermissionStatus(WebServiceWorkerRegistration*, const WebPus
hSubscriptionOptions&, WebPushPermissionStatusCallbacks*) = 0; | 38 virtual void getPermissionStatus(WebServiceWorkerRegistration*, const WebPus
hSubscriptionOptions&, WebPushPermissionStatusCallbacks*) = 0; |
38 | 39 |
39 // Takes ownership if the WebPushUnsubscribeCallbacks. | 40 // Takes ownership if the WebPushUnsubscribeCallbacks. |
40 // Does not take ownership of the WebServiceWorkerRegistration. | 41 // Does not take ownership of the WebServiceWorkerRegistration. |
41 virtual void unsubscribe(WebServiceWorkerRegistration*, WebPushUnsubscribeCa
llbacks*) = 0; | 42 virtual void unsubscribe(WebServiceWorkerRegistration*, WebPushUnsubscribeCa
llbacks*) = 0; |
42 }; | 43 }; |
43 | 44 |
44 } // namespace blink | 45 } // namespace blink |
45 | 46 |
46 #endif // WebPushProvider_h | 47 #endif // WebPushProvider_h |
OLD | NEW |