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