Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(161)

Side by Side Diff: content/public/browser/push_messaging_service.h

Issue 914693002: Push API: Fix unsubscribing from GCM on Android (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove obsolete PushEventNoPermission test Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/modules/push_messaging/WebPushPermi ssionStatus.h" 13 #include "third_party/WebKit/public/platform/modules/push_messaging/WebPushPermi ssionStatus.h"
14 #include "url/gurl.h" 14 #include "url/gurl.h"
15 15
16 namespace content { 16 namespace content {
17 17
18 class BrowserContext; 18 class BrowserContext;
19 class ServiceWorkerContext; 19 class ServiceWorkerContext;
20 20
21 // A push service-agnostic interface that the Push API uses for talking to 21 // A push service-agnostic interface that the Push API uses for talking to
22 // push messaging services like GCM. Must only be used on the UI thread. 22 // push messaging services like GCM. Must only be used on the UI thread.
23 class CONTENT_EXPORT PushMessagingService { 23 class CONTENT_EXPORT PushMessagingService {
24 public: 24 public:
25 using GetNotificationsShownCallback =
26 base::Callback<void(const std::string& notifications_shown,
27 bool success, bool not_found)>;
28
29 using ResultCallback = base::Callback<void(bool success)>;
30
31 using RegisterCallback = 25 using RegisterCallback =
32 base::Callback<void(const std::string& /* registration_id */, 26 base::Callback<void(const std::string& /* registration_id */,
33 PushRegistrationStatus /* status */)>; 27 PushRegistrationStatus /* status */)>;
34 using UnregisterCallback = base::Callback<void(PushUnregistrationStatus)>; 28 using UnregisterCallback = base::Callback<void(PushUnregistrationStatus)>;
35 29
30 using StringCallback = base::Callback<void(const std::string& data,
31 bool success,
32 bool not_found)>;
33
34 using ResultCallback = base::Callback<void(bool success)>;
35
36 virtual ~PushMessagingService() {} 36 virtual ~PushMessagingService() {}
37 37
38 // Returns the absolute URL exposed by the push server where the webapp server 38 // Returns the absolute URL exposed by the push server where the webapp server
39 // can send push messages. This is currently assumed to be the same for all 39 // can send push messages. This is currently assumed to be the same for all
40 // origins and push registrations. 40 // origins and push registrations.
41 virtual GURL GetPushEndpoint() = 0; 41 virtual GURL GetPushEndpoint() = 0;
42 42
43 // Register the given |sender_id| with the push messaging service in a 43 // Register the given |sender_id| with the push messaging service in a
44 // document context. The frame is known and a permission UI may be displayed 44 // document context. The frame is known and a permission UI may be displayed
45 // to the user. 45 // to the user.
(...skipping 10 matching lines...) Expand all
56 // request should fail. 56 // request should fail.
57 virtual void RegisterFromWorker(const GURL& requesting_origin, 57 virtual void RegisterFromWorker(const GURL& requesting_origin,
58 int64 service_worker_registration_id, 58 int64 service_worker_registration_id,
59 const std::string& sender_id, 59 const std::string& sender_id,
60 const RegisterCallback& callback) = 0; 60 const RegisterCallback& callback) = 0;
61 61
62 // Unregister an origin and its associated service worker registration id from 62 // Unregister an origin and its associated service worker registration id from
63 // the push service. 63 // the push service.
64 virtual void Unregister(const GURL& requesting_origin, 64 virtual void Unregister(const GURL& requesting_origin,
65 int64 service_worker_registration_id, 65 int64 service_worker_registration_id,
66 const std::string& sender_id,
66 bool retry_on_failure, 67 bool retry_on_failure,
67 const UnregisterCallback& callback) = 0; 68 const UnregisterCallback& callback) = 0;
68 69
69 // Checks the permission status for the requesting origin. Permission is only 70 // Checks the permission status for the requesting origin. Permission is only
70 // ever granted when the requesting origin matches the top level embedding 71 // ever granted when the requesting origin matches the top level embedding
71 // origin. 72 // origin.
72 virtual blink::WebPushPermissionStatus GetPermissionStatus( 73 virtual blink::WebPushPermissionStatus GetPermissionStatus(
73 const GURL& requesting_origin, 74 const GURL& requesting_origin,
74 const GURL& embedding_origin) = 0; 75 const GURL& embedding_origin) = 0;
75 76
76 protected: 77 protected:
77 // Provide a storage mechanism to read/write an opaque 78 // Provide a storage mechanism to read/write an opaque
78 // "notifications_shown_by_last_few_pushes" string associated with a Service 79 // "notifications_shown_by_last_few_pushes" string associated with a Service
79 // Worker registration. Stored data is deleted when the associated 80 // Worker registration. Stored data is deleted when the associated
80 // registration is deleted. 81 // registration is deleted.
81 static void GetNotificationsShownByLastFewPushes( 82 static void GetNotificationsShownByLastFewPushes(
82 ServiceWorkerContext* service_worker_context, 83 ServiceWorkerContext* service_worker_context,
83 int64 service_worker_registration_id, 84 int64 service_worker_registration_id,
84 const GetNotificationsShownCallback& callback); 85 const StringCallback& callback);
85 static void SetNotificationsShownByLastFewPushes( 86 static void SetNotificationsShownByLastFewPushes(
86 ServiceWorkerContext* service_worker_context, 87 ServiceWorkerContext* service_worker_context,
87 int64 service_worker_registration_id, 88 int64 service_worker_registration_id,
88 const GURL& origin, 89 const GURL& origin,
89 const std::string& notifications_shown, 90 const std::string& notifications_shown,
90 const ResultCallback& callback); 91 const ResultCallback& callback);
91 92
93 static void GetSenderId(BrowserContext* browser_context,
94 const GURL& origin,
95 int64 service_worker_registration_id,
96 const StringCallback& callback);
97
92 // Clear the push registration id stored in the service worker with the given 98 // Clear the push registration id stored in the service worker with the given
93 // |service_worker_registration_id| for the given |origin|. 99 // |service_worker_registration_id| for the given |origin|.
94 static void ClearPushRegistrationID(BrowserContext* browser_context, 100 static void ClearPushRegistrationID(BrowserContext* browser_context,
95 const GURL& origin, 101 const GURL& origin,
96 int64 service_worker_registration_id); 102 int64 service_worker_registration_id);
97 }; 103 };
98 104
99 } // namespace content 105 } // namespace content
100 106
101 #endif // CONTENT_PUBLIC_BROWSER_PUSH_MESSAGING_SERVICE_H_ 107 #endif // CONTENT_PUBLIC_BROWSER_PUSH_MESSAGING_SERVICE_H_
OLDNEW
« no previous file with comments | « content/browser/push_messaging/push_messaging_message_filter.cc ('k') | content/public/browser/push_messaging_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698