| 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 ContentPushSubscriptionOptions; | 
| 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( | 
| 56                                      int64_t service_worker_registration_id, | 57       const GURL& requesting_origin, | 
| 57                                      const std::string& sender_id, | 58       int64_t service_worker_registration_id, | 
| 58                                      int renderer_id, | 59       int renderer_id, | 
| 59                                      int render_frame_id, | 60       int render_frame_id, | 
| 60                                      bool user_visible, | 61       const ContentPushSubscriptionOptions& options, | 
| 61                                      const RegisterCallback& callback) = 0; | 62       const RegisterCallback& callback) = 0; | 
| 62 | 63 | 
| 63   // Subscribe the given |sender_id| with the push messaging service. The frame | 64   // 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 | 65   // The frame is not known so if permission was not previously granted by the | 
| 65   // request should fail. | 66   // user this request should fail. | 
| 66   virtual void SubscribeFromWorker(const GURL& requesting_origin, | 67   virtual void SubscribeFromWorker( | 
| 67                                    int64_t service_worker_registration_id, | 68       const GURL& requesting_origin, | 
| 68                                    const std::string& sender_id, | 69       int64_t service_worker_registration_id, | 
| 69                                    bool user_visible, | 70       const ContentPushSubscriptionOptions& options, | 
| 70                                    const RegisterCallback& callback) = 0; | 71       const RegisterCallback& callback) = 0; | 
| 71 | 72 | 
| 72   // Retrieves the encryption information associated with the subscription | 73   // Retrieves the encryption information associated with the subscription | 
| 73   // associated to |origin| and |service_worker_registration_id|. | 74   // associated to |origin| and |service_worker_registration_id|. | 
| 74   virtual void GetEncryptionInfo(const GURL& origin, | 75   virtual void GetEncryptionInfo(const GURL& origin, | 
| 75                                  int64_t service_worker_registration_id, | 76                                  int64_t service_worker_registration_id, | 
| 76                                  const EncryptionInfoCallback& callback) = 0; | 77                                  const EncryptionInfoCallback& callback) = 0; | 
| 77 | 78 | 
| 78   // Unsubscribe the given |sender_id| from the push messaging service. The | 79   // Unsubscribe the given |sender_id| from the push messaging service. The | 
| 79   // subscription will be synchronously deactivated locally, and asynchronously | 80   // subscription will be synchronously deactivated locally, and asynchronously | 
| 80   // sent to the push service, with automatic retry. | 81   // sent to the push service, with automatic retry. | 
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 122   // |service_worker_registration_id| for the given |origin|. | 123   // |service_worker_registration_id| for the given |origin|. | 
| 123   static void ClearPushSubscriptionID(BrowserContext* browser_context, | 124   static void ClearPushSubscriptionID(BrowserContext* browser_context, | 
| 124                                       const GURL& origin, | 125                                       const GURL& origin, | 
| 125                                       int64_t service_worker_registration_id, | 126                                       int64_t service_worker_registration_id, | 
| 126                                       const base::Closure& callback); | 127                                       const base::Closure& callback); | 
| 127 }; | 128 }; | 
| 128 | 129 | 
| 129 }  // namespace content | 130 }  // namespace content | 
| 130 | 131 | 
| 131 #endif  // CONTENT_PUBLIC_BROWSER_PUSH_MESSAGING_SERVICE_H_ | 132 #endif  // CONTENT_PUBLIC_BROWSER_PUSH_MESSAGING_SERVICE_H_ | 
| OLD | NEW | 
|---|