| 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 <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| 11 #include "content/common/content_export.h" | 11 #include "content/common/content_export.h" |
| 12 #include "content/public/common/push_messaging_status.h" | 12 #include "content/public/common/push_messaging_status.h" |
| 13 #include "third_party/WebKit/public/platform/WebPushPermissionStatus.h" | 13 #include "third_party/WebKit/public/platform/WebPushPermissionStatus.h" |
| 14 #include "url/gurl.h" | 14 #include "url/gurl.h" |
| 15 | 15 |
| 16 namespace content { | 16 namespace content { |
| 17 | 17 |
| 18 class ServiceWorkerContext; |
| 19 |
| 18 // A push service-agnostic interface that the Push API uses for talking to | 20 // A push service-agnostic interface that the Push API uses for talking to |
| 19 // push messaging services like GCM. Must only be used on the UI thread. | 21 // push messaging services like GCM. Must only be used on the UI thread. |
| 20 class CONTENT_EXPORT PushMessagingService { | 22 class CONTENT_EXPORT PushMessagingService { |
| 21 public: | 23 public: |
| 24 using GetNotificationsShownCallback = |
| 25 base::Callback<void(const std::string& notifications_shown, |
| 26 bool success, bool not_found)>; |
| 27 |
| 28 using ResultCallback = base::Callback<void(bool success)>; |
| 29 |
| 22 using RegisterCallback = | 30 using RegisterCallback = |
| 23 base::Callback<void(const std::string& /* registration_id */, | 31 base::Callback<void(const std::string& /* registration_id */, |
| 24 PushRegistrationStatus /* status */)>; | 32 PushRegistrationStatus /* status */)>; |
| 25 using UnregisterCallback = base::Callback<void(PushUnregistrationStatus)>; | 33 using UnregisterCallback = base::Callback<void(PushUnregistrationStatus)>; |
| 26 | 34 |
| 35 // Provide a storage mechanism to read/write an opaque |
| 36 // "notifications_shown_by_last_few_pushes" string associated with a Service |
| 37 // Worker registration. Stored data is deleted when the associated |
| 38 // registration is deleted. |
| 39 static void GetNotificationsShownByLastFewPushes( |
| 40 ServiceWorkerContext* service_worker_context, |
| 41 int64 service_worker_registration_id, |
| 42 const GetNotificationsShownCallback& callback); |
| 43 static void SetNotificationsShownByLastFewPushes( |
| 44 ServiceWorkerContext* service_worker_context, |
| 45 int64 service_worker_registration_id, |
| 46 const GURL& origin, |
| 47 const std::string& notifications_shown, |
| 48 const ResultCallback& callback); |
| 49 |
| 27 virtual ~PushMessagingService() {} | 50 virtual ~PushMessagingService() {} |
| 28 | 51 |
| 29 // Returns the absolute URL exposed by the push server where the webapp server | 52 // Returns the absolute URL exposed by the push server where the webapp server |
| 30 // can send push messages. This is currently assumed to be the same for all | 53 // can send push messages. This is currently assumed to be the same for all |
| 31 // origins and push registrations. | 54 // origins and push registrations. |
| 32 virtual GURL GetPushEndpoint() = 0; | 55 virtual GURL GetPushEndpoint() = 0; |
| 33 | 56 |
| 34 // Register the given |sender_id| with the push messaging service in a | 57 // Register the given |sender_id| with the push messaging service in a |
| 35 // document context. The frame is known and a permission UI may be displayed | 58 // document context. The frame is known and a permission UI may be displayed |
| 36 // to the user. | 59 // to the user. |
| (...skipping 23 matching lines...) Expand all Loading... |
| 60 // ever granted when the requesting origin matches the top level embedding | 83 // ever granted when the requesting origin matches the top level embedding |
| 61 // origin. | 84 // origin. |
| 62 virtual blink::WebPushPermissionStatus GetPermissionStatus( | 85 virtual blink::WebPushPermissionStatus GetPermissionStatus( |
| 63 const GURL& requesting_origin, | 86 const GURL& requesting_origin, |
| 64 const GURL& embedding_origin) = 0; | 87 const GURL& embedding_origin) = 0; |
| 65 }; | 88 }; |
| 66 | 89 |
| 67 } // namespace content | 90 } // namespace content |
| 68 | 91 |
| 69 #endif // CONTENT_PUBLIC_BROWSER_PUSH_MESSAGING_SERVICE_H_ | 92 #endif // CONTENT_PUBLIC_BROWSER_PUSH_MESSAGING_SERVICE_H_ |
| OLD | NEW |