| 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 CHROME_BROWSER_PUSH_MESSAGING_PUSH_MESSAGING_SERVICE_IMPL_H_ | 5 #ifndef CHROME_BROWSER_PUSH_MESSAGING_PUSH_MESSAGING_SERVICE_IMPL_H_ | 
| 6 #define CHROME_BROWSER_PUSH_MESSAGING_PUSH_MESSAGING_SERVICE_IMPL_H_ | 6 #define CHROME_BROWSER_PUSH_MESSAGING_PUSH_MESSAGING_SERVICE_IMPL_H_ | 
| 7 | 7 | 
| 8 #include <stdint.h> | 8 #include <stdint.h> | 
| 9 #include <memory> | 9 #include <memory> | 
| 10 #include <set> | 10 #include <set> | 
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 71   void OnMessagesDeleted(const std::string& app_id) override; | 71   void OnMessagesDeleted(const std::string& app_id) override; | 
| 72   void OnSendError( | 72   void OnSendError( | 
| 73       const std::string& app_id, | 73       const std::string& app_id, | 
| 74       const gcm::GCMClient::SendErrorDetails& send_error_details) override; | 74       const gcm::GCMClient::SendErrorDetails& send_error_details) override; | 
| 75   void OnSendAcknowledged(const std::string& app_id, | 75   void OnSendAcknowledged(const std::string& app_id, | 
| 76                           const std::string& message_id) override; | 76                           const std::string& message_id) override; | 
| 77   bool CanHandle(const std::string& app_id) const override; | 77   bool CanHandle(const std::string& app_id) const override; | 
| 78 | 78 | 
| 79   // content::PushMessagingService implementation: | 79   // content::PushMessagingService implementation: | 
| 80   GURL GetEndpoint(bool standard_protocol) const override; | 80   GURL GetEndpoint(bool standard_protocol) const override; | 
| 81   void SubscribeFromDocument( | 81   void SubscribeFromDocument(const GURL& requesting_origin, | 
| 82       const GURL& requesting_origin, | 82                              int64_t service_worker_registration_id, | 
| 83       int64_t service_worker_registration_id, | 83                              int renderer_id, | 
| 84       int renderer_id, | 84                              int render_frame_id, | 
| 85       int render_frame_id, | 85                              const content::PushSubscriptionOptions& options, | 
| 86       const content::PushSubscriptionOptions& options, | 86                              const RegisterCallback& callback) override; | 
| 87       const content::PushMessagingService::RegisterCallback& callback) override; | 87   void SubscribeFromWorker(const GURL& requesting_origin, | 
| 88   void SubscribeFromWorker( | 88                            int64_t service_worker_registration_id, | 
| 89       const GURL& requesting_origin, | 89                            const content::PushSubscriptionOptions& options, | 
| 90       int64_t service_worker_registration_id, | 90                            const RegisterCallback& callback) override; | 
| 91       const content::PushSubscriptionOptions& options, | 91   void GetEncryptionInfo(const GURL& origin, | 
| 92       const content::PushMessagingService::RegisterCallback& callback) override; | 92                          int64_t service_worker_registration_id, | 
| 93   void GetEncryptionInfo( | 93                          const std::string& sender_id, | 
| 94       const GURL& origin, | 94                          const EncryptionInfoCallback& callback) override; | 
| 95       int64_t service_worker_registration_id, | 95   void Unsubscribe(const GURL& requesting_origin, | 
| 96       const std::string& sender_id, | 96                    int64_t service_worker_registration_id, | 
| 97       const content::PushMessagingService::EncryptionInfoCallback& callback) | 97                    const std::string& sender_id, | 
| 98       override; | 98                    const UnregisterCallback&) override; | 
| 99   void Unsubscribe( |  | 
| 100       const GURL& requesting_origin, |  | 
| 101       int64_t service_worker_registration_id, |  | 
| 102       const std::string& sender_id, |  | 
| 103       const content::PushMessagingService::UnregisterCallback&) override; |  | 
| 104   blink::WebPushPermissionStatus GetPermissionStatus( | 99   blink::WebPushPermissionStatus GetPermissionStatus( | 
| 105       const GURL& origin, | 100       const GURL& origin, | 
| 106       bool user_visible) override; | 101       bool user_visible) override; | 
| 107   bool SupportNonVisibleMessages() override; | 102   bool SupportNonVisibleMessages() override; | 
| 108 | 103 | 
| 109   // content_settings::Observer implementation. | 104   // content_settings::Observer implementation. | 
| 110   void OnContentSettingChanged(const ContentSettingsPattern& primary_pattern, | 105   void OnContentSettingChanged(const ContentSettingsPattern& primary_pattern, | 
| 111                                const ContentSettingsPattern& secondary_pattern, | 106                                const ContentSettingsPattern& secondary_pattern, | 
| 112                                ContentSettingsType content_type, | 107                                ContentSettingsType content_type, | 
| 113                                std::string resource_identifier) override; | 108                                std::string resource_identifier) override; | 
| (...skipping 26 matching lines...) Expand all  Loading... | 
| 140                               int64_t service_worker_registration_id, | 135                               int64_t service_worker_registration_id, | 
| 141                               const gcm::IncomingMessage& message, | 136                               const gcm::IncomingMessage& message, | 
| 142                               const base::Closure& message_handled_closure, | 137                               const base::Closure& message_handled_closure, | 
| 143                               content::PushDeliveryStatus status); | 138                               content::PushDeliveryStatus status); | 
| 144 | 139 | 
| 145   void DidHandleMessage(const std::string& app_id, | 140   void DidHandleMessage(const std::string& app_id, | 
| 146                         const base::Closure& completion_closure); | 141                         const base::Closure& completion_closure); | 
| 147 | 142 | 
| 148   // Subscribe methods --------------------------------------------------------- | 143   // Subscribe methods --------------------------------------------------------- | 
| 149 | 144 | 
| 150   void DoSubscribe( | 145   void DoSubscribe(const PushMessagingAppIdentifier& app_identifier, | 
| 151       const PushMessagingAppIdentifier& app_identifier, | 146                    const content::PushSubscriptionOptions& options, | 
| 152       const content::PushSubscriptionOptions& options, | 147                    const RegisterCallback& callback, | 
| 153       const content::PushMessagingService::RegisterCallback& callback, | 148                    blink::mojom::PermissionStatus permission_status); | 
| 154       blink::mojom::PermissionStatus permission_status); |  | 
| 155 | 149 | 
| 156   void SubscribeEnd( | 150   void SubscribeEnd(const RegisterCallback& callback, | 
| 157       const content::PushMessagingService::RegisterCallback& callback, | 151                     const std::string& subscription_id, | 
| 158       const std::string& subscription_id, | 152                     const std::vector<uint8_t>& p256dh, | 
| 159       const std::vector<uint8_t>& p256dh, | 153                     const std::vector<uint8_t>& auth, | 
| 160       const std::vector<uint8_t>& auth, | 154                     content::PushRegistrationStatus status); | 
| 161       content::PushRegistrationStatus status); |  | 
| 162 | 155 | 
| 163   void SubscribeEndWithError( | 156   void SubscribeEndWithError(const RegisterCallback& callback, | 
| 164       const content::PushMessagingService::RegisterCallback& callback, | 157                              content::PushRegistrationStatus status); | 
| 165       content::PushRegistrationStatus status); |  | 
| 166 | 158 | 
| 167   void DidSubscribe( | 159   void DidSubscribe(const PushMessagingAppIdentifier& app_identifier, | 
| 168       const PushMessagingAppIdentifier& app_identifier, | 160                     const std::string& sender_id, | 
| 169       const std::string& sender_id, | 161                     const RegisterCallback& callback, | 
| 170       const content::PushMessagingService::RegisterCallback& callback, | 162                     const std::string& subscription_id, | 
| 171       const std::string& subscription_id, | 163                     instance_id::InstanceID::Result result); | 
| 172       instance_id::InstanceID::Result result); |  | 
| 173 | 164 | 
| 174   void DidSubscribeWithEncryptionInfo( | 165   void DidSubscribeWithEncryptionInfo( | 
| 175       const PushMessagingAppIdentifier& app_identifier, | 166       const PushMessagingAppIdentifier& app_identifier, | 
| 176       const content::PushMessagingService::RegisterCallback& callback, | 167       const RegisterCallback& callback, | 
| 177       const std::string& subscription_id, | 168       const std::string& subscription_id, | 
| 178       const std::string& p256dh, | 169       const std::string& p256dh, | 
| 179       const std::string& auth_secret); | 170       const std::string& auth_secret); | 
| 180 | 171 | 
| 181   // GetEncryptionInfo method -------------------------------------------------- | 172   // GetEncryptionInfo method -------------------------------------------------- | 
| 182 | 173 | 
| 183   void DidGetEncryptionInfo( | 174   void DidGetEncryptionInfo(const EncryptionInfoCallback& callback, | 
| 184       const PushMessagingService::EncryptionInfoCallback& callback, | 175                             const std::string& p256dh, | 
| 185       const std::string& p256dh, | 176                             const std::string& auth_secret) const; | 
| 186       const std::string& auth_secret) const; |  | 
| 187 | 177 | 
| 188   // Unsubscribe methods ------------------------------------------------------- | 178   // Unsubscribe methods ------------------------------------------------------- | 
| 189 | 179 | 
| 190   void Unsubscribe(const std::string& app_id, | 180   // |origin|, |service_worker_registration_id| and |app_id| should be provided | 
| 191                    const std::string& sender_id, | 181   // whenever they can be obtained. It's valid for |origin| to be empty and | 
| 192                    const content::PushMessagingService::UnregisterCallback&); | 182   // |service_worker_registration_id| to be kInvalidServiceWorkerRegistrationId, | 
|  | 183   // or for app_id to be empty, but not both at once. | 
|  | 184   void UnsubscribeInternal(content::PushUnregistrationReason reason, | 
|  | 185                            const GURL& origin, | 
|  | 186                            int64_t service_worker_registration_id, | 
|  | 187                            const std::string& app_id, | 
|  | 188                            const std::string& sender_id, | 
|  | 189                            const UnregisterCallback& callback); | 
|  | 190 | 
|  | 191   void DidClearPushSubscriptionId(content::PushUnregistrationReason reason, | 
|  | 192                                   const std::string& app_id, | 
|  | 193                                   const std::string& sender_id, | 
|  | 194                                   const UnregisterCallback& callback); | 
| 193 | 195 | 
| 194   void DidDeleteID(const std::string& app_id, | 196   void DidDeleteID(const std::string& app_id, | 
| 195                    bool was_subscribed, | 197                    bool was_subscribed, | 
| 196                    const content::PushMessagingService::UnregisterCallback&, | 198                    const UnregisterCallback&, | 
| 197                    instance_id::InstanceID::Result result); | 199                    instance_id::InstanceID::Result result); | 
| 198 | 200 | 
| 199   void DidUnsubscribeInstanceID( | 201   void DidUnsubscribe(const std::string& app_id_when_instance_id, | 
| 200       const std::string& app_id, | 202                       bool was_subscribed, | 
| 201       bool was_subscribed, | 203                       const UnregisterCallback& callback, | 
| 202       const content::PushMessagingService::UnregisterCallback&, | 204                       content::PushUnregistrationStatus status); | 
| 203       instance_id::InstanceID::Result result); |  | 
| 204 |  | 
| 205   void DidUnsubscribe(bool was_subscribed, |  | 
| 206                       const content::PushMessagingService::UnregisterCallback&, |  | 
| 207                       gcm::GCMClient::Result result); |  | 
| 208 | 205 | 
| 209   // OnContentSettingChanged methods ------------------------------------------- | 206   // OnContentSettingChanged methods ------------------------------------------- | 
| 210 | 207 | 
| 211   void UnsubscribeBecausePermissionRevoked( | 208   void UnsubscribeBecausePermissionRevoked( | 
| 212       const PushMessagingAppIdentifier& app_identifier, | 209       const PushMessagingAppIdentifier& app_identifier, | 
| 213       const base::Closure& closure, | 210       const UnregisterCallback& callback, | 
| 214       const std::string& sender_id, | 211       const std::string& sender_id, | 
| 215       bool success, | 212       bool success, | 
| 216       bool not_found); | 213       bool not_found); | 
| 217 | 214 | 
| 218   // Helper methods ------------------------------------------------------------ | 215   // Helper methods ------------------------------------------------------------ | 
| 219 | 216 | 
| 220   // Normalizes the |sender_info|. In most cases the |sender_info| will be | 217   // Normalizes the |sender_info|. In most cases the |sender_info| will be | 
| 221   // passed through to the GCM Driver as-is, but NIST P-256 application server | 218   // passed through to the GCM Driver as-is, but NIST P-256 application server | 
| 222   // keys have to be encoded using the URL-safe variant of the base64 encoding. | 219   // keys have to be encoded using the URL-safe variant of the base64 encoding. | 
| 223   std::string NormalizeSenderInfo(const std::string& sender_info) const; | 220   std::string NormalizeSenderInfo(const std::string& sender_info) const; | 
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 276   // we can finish processing them without being interrupted. | 273   // we can finish processing them without being interrupted. | 
| 277   std::unique_ptr<ScopedKeepAlive> in_flight_keep_alive_; | 274   std::unique_ptr<ScopedKeepAlive> in_flight_keep_alive_; | 
| 278 #endif | 275 #endif | 
| 279 | 276 | 
| 280   base::WeakPtrFactory<PushMessagingServiceImpl> weak_factory_; | 277   base::WeakPtrFactory<PushMessagingServiceImpl> weak_factory_; | 
| 281 | 278 | 
| 282   DISALLOW_COPY_AND_ASSIGN(PushMessagingServiceImpl); | 279   DISALLOW_COPY_AND_ASSIGN(PushMessagingServiceImpl); | 
| 283 }; | 280 }; | 
| 284 | 281 | 
| 285 #endif  // CHROME_BROWSER_PUSH_MESSAGING_PUSH_MESSAGING_SERVICE_IMPL_H_ | 282 #endif  // CHROME_BROWSER_PUSH_MESSAGING_PUSH_MESSAGING_SERVICE_IMPL_H_ | 
| OLD | NEW | 
|---|