| 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 CONTENT_PUBLIC_BROWSER_PUSH_MESSAGING_SERVICE_H_ | 5 #ifndef CONTENT_PUBLIC_BROWSER_PUSH_MESSAGING_SERVICE_H_ |
| 6 #define CONTENT_PUBLIC_BROWSER_PUSH_MESSAGING_SERVICE_H_ | 6 #define CONTENT_PUBLIC_BROWSER_PUSH_MESSAGING_SERVICE_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/callback_forward.h" | 12 #include "base/callback_forward.h" |
| 13 #include "content/common/content_export.h" | 13 #include "content/common/content_export.h" |
| 14 #include "content/public/common/push_messaging_status.h" | 14 #include "content/public/common/push_messaging_status.h" |
| 15 #include "third_party/WebKit/public/platform/modules/push_messaging/WebPushPermi
ssionStatus.h" | 15 #include "third_party/WebKit/public/platform/modules/push_messaging/WebPushPermi
ssionStatus.h" |
| 16 #include "url/gurl.h" | 16 #include "url/gurl.h" |
| 17 | 17 |
| 18 namespace content { | 18 namespace content { |
| 19 | 19 |
| 20 class BrowserContext; | 20 class BrowserContext; |
| 21 class ServiceWorkerContext; | 21 class ServiceWorkerContext; |
| 22 struct PushSubscriptionOptions; |
| 22 | 23 |
| 23 // A push service-agnostic interface that the Push API uses for talking to | 24 // A push service-agnostic interface that the Push API uses for talking to |
| 24 // push messaging services like GCM. Must only be used on the UI thread. | 25 // push messaging services like GCM. Must only be used on the UI thread. |
| 25 class CONTENT_EXPORT PushMessagingService { | 26 class CONTENT_EXPORT PushMessagingService { |
| 26 public: | 27 public: |
| 27 using RegisterCallback = | 28 using RegisterCallback = |
| 28 base::Callback<void(const std::string& registration_id, | 29 base::Callback<void(const std::string& registration_id, |
| 29 const std::vector<uint8_t>& p256dh, | 30 const std::vector<uint8_t>& p256dh, |
| 30 const std::vector<uint8_t>& auth, | 31 const std::vector<uint8_t>& auth, |
| 31 PushRegistrationStatus status)>; | 32 PushRegistrationStatus status)>; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 42 | 43 |
| 43 using ResultCallback = base::Callback<void(bool success)>; | 44 using ResultCallback = base::Callback<void(bool success)>; |
| 44 | 45 |
| 45 virtual ~PushMessagingService() {} | 46 virtual ~PushMessagingService() {} |
| 46 | 47 |
| 47 // Returns the absolute URL exposed by the push server where the webapp server | 48 // Returns the absolute URL exposed by the push server where the webapp server |
| 48 // can send push messages. This is currently assumed to be the same for all | 49 // can send push messages. This is currently assumed to be the same for all |
| 49 // origins and push registrations. | 50 // origins and push registrations. |
| 50 virtual GURL GetPushEndpoint() = 0; | 51 virtual GURL GetPushEndpoint() = 0; |
| 51 | 52 |
| 52 // Subscribe the given |sender_id| with the push messaging service in a | 53 // Subscribe the given |options.sender_info| with the push messaging service |
| 53 // document context. The frame is known and a permission UI may be displayed | 54 // in a document context. The frame is known and a permission UI may be |
| 54 // to the user. | 55 // displayed to the user. |
| 55 virtual void SubscribeFromDocument(const GURL& requesting_origin, | 56 virtual void SubscribeFromDocument(const GURL& requesting_origin, |
| 56 int64_t service_worker_registration_id, | 57 int64_t service_worker_registration_id, |
| 57 const std::string& sender_id, | |
| 58 int renderer_id, | 58 int renderer_id, |
| 59 int render_frame_id, | 59 int render_frame_id, |
| 60 bool user_visible, | 60 const PushSubscriptionOptions& options, |
| 61 const RegisterCallback& callback) = 0; | 61 const RegisterCallback& callback) = 0; |
| 62 | 62 |
| 63 // Subscribe the given |sender_id| with the push messaging service. The frame | 63 // Subscribe the given |options.sender_info| with the push messaging service. |
| 64 // is not known so if permission was not previously granted by the user this | 64 // The frame is not known so if permission was not previously granted by the |
| 65 // request should fail. | 65 // user this request should fail. |
| 66 virtual void SubscribeFromWorker(const GURL& requesting_origin, | 66 virtual void SubscribeFromWorker(const GURL& requesting_origin, |
| 67 int64_t service_worker_registration_id, | 67 int64_t service_worker_registration_id, |
| 68 const std::string& sender_id, | 68 const PushSubscriptionOptions& options, |
| 69 bool user_visible, | |
| 70 const RegisterCallback& callback) = 0; | 69 const RegisterCallback& callback) = 0; |
| 71 | 70 |
| 72 // Retrieves the encryption information associated with the subscription | 71 // Retrieves the encryption information associated with the subscription |
| 73 // associated to |origin| and |service_worker_registration_id|. | 72 // associated to |origin| and |service_worker_registration_id|. |
| 74 virtual void GetEncryptionInfo(const GURL& origin, | 73 virtual void GetEncryptionInfo(const GURL& origin, |
| 75 int64_t service_worker_registration_id, | 74 int64_t service_worker_registration_id, |
| 76 const EncryptionInfoCallback& callback) = 0; | 75 const EncryptionInfoCallback& callback) = 0; |
| 77 | 76 |
| 78 // Unsubscribe the given |sender_id| from the push messaging service. The | 77 // Unsubscribe the given |sender_id| from the push messaging service. The |
| 79 // subscription will be synchronously deactivated locally, and asynchronously | 78 // subscription will be synchronously deactivated locally, and asynchronously |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 // |service_worker_registration_id| for the given |origin|. | 119 // |service_worker_registration_id| for the given |origin|. |
| 121 static void ClearPushSubscriptionID(BrowserContext* browser_context, | 120 static void ClearPushSubscriptionID(BrowserContext* browser_context, |
| 122 const GURL& origin, | 121 const GURL& origin, |
| 123 int64_t service_worker_registration_id, | 122 int64_t service_worker_registration_id, |
| 124 const base::Closure& callback); | 123 const base::Closure& callback); |
| 125 }; | 124 }; |
| 126 | 125 |
| 127 } // namespace content | 126 } // namespace content |
| 128 | 127 |
| 129 #endif // CONTENT_PUBLIC_BROWSER_PUSH_MESSAGING_SERVICE_H_ | 128 #endif // CONTENT_PUBLIC_BROWSER_PUSH_MESSAGING_SERVICE_H_ |
| OLD | NEW |