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

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

Issue 2697793004: Push API: Validate storage before returning cached subscriptions (Closed)
Patch Set: Fix include Created 3 years, 8 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 <stdint.h> 8 #include <stdint.h>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 12 matching lines...) Expand all
23 // 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
24 // 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.
25 class CONTENT_EXPORT PushMessagingService { 25 class CONTENT_EXPORT PushMessagingService {
26 public: 26 public:
27 using RegisterCallback = 27 using RegisterCallback =
28 base::Callback<void(const std::string& registration_id, 28 base::Callback<void(const std::string& registration_id,
29 const std::vector<uint8_t>& p256dh, 29 const std::vector<uint8_t>& p256dh,
30 const std::vector<uint8_t>& auth, 30 const std::vector<uint8_t>& auth,
31 PushRegistrationStatus status)>; 31 PushRegistrationStatus status)>;
32 using UnregisterCallback = base::Callback<void(PushUnregistrationStatus)>; 32 using UnregisterCallback = base::Callback<void(PushUnregistrationStatus)>;
33 33 using SubscriptionInfoCallback =
34 using EncryptionInfoCallback = base::Callback<void( 34 base::Callback<void(bool is_valid,
35 bool success, 35 const std::vector<uint8_t>& p256dh,
36 const std::vector<uint8_t>& p256dh, 36 const std::vector<uint8_t>& auth)>;
37 const std::vector<uint8_t>& auth)>;
38
39 using StringCallback = base::Callback<void(const std::string& data, 37 using StringCallback = base::Callback<void(const std::string& data,
40 bool success, 38 bool success,
41 bool not_found)>; 39 bool not_found)>;
42 40
43 virtual ~PushMessagingService() {} 41 virtual ~PushMessagingService() {}
44 42
45 // Returns the absolute URL to the endpoint of the push service where messages 43 // Returns the absolute URL to the endpoint of the push service where messages
46 // should be posted to. Should return an endpoint compatible with the Web Push 44 // should be posted to. Should return an endpoint compatible with the Web Push
47 // Protocol when |standard_protocol| is true. 45 // Protocol when |standard_protocol| is true.
48 virtual GURL GetEndpoint(bool standard_protocol) const = 0; 46 virtual GURL GetEndpoint(bool standard_protocol) const = 0;
49 47
50 // Subscribe the given |options.sender_info| with the push messaging service 48 // Subscribe the given |options.sender_info| with the push messaging service
51 // in a document context. The frame is known and a permission UI may be 49 // in a document context. The frame is known and a permission UI may be
52 // displayed to the user. 50 // displayed to the user.
53 virtual void SubscribeFromDocument(const GURL& requesting_origin, 51 virtual void SubscribeFromDocument(const GURL& requesting_origin,
54 int64_t service_worker_registration_id, 52 int64_t service_worker_registration_id,
55 int renderer_id, 53 int renderer_id,
56 int render_frame_id, 54 int render_frame_id,
57 const PushSubscriptionOptions& options, 55 const PushSubscriptionOptions& options,
58 const RegisterCallback& callback) = 0; 56 const RegisterCallback& callback) = 0;
59 57
60 // Subscribe the given |options.sender_info| with the push messaging service. 58 // Subscribe the given |options.sender_info| with the push messaging service.
61 // The frame is not known so if permission was not previously granted by the 59 // The frame is not known so if permission was not previously granted by the
62 // user this request should fail. 60 // user this request should fail.
63 virtual void SubscribeFromWorker(const GURL& requesting_origin, 61 virtual void SubscribeFromWorker(const GURL& requesting_origin,
64 int64_t service_worker_registration_id, 62 int64_t service_worker_registration_id,
65 const PushSubscriptionOptions& options, 63 const PushSubscriptionOptions& options,
66 const RegisterCallback& callback) = 0; 64 const RegisterCallback& callback) = 0;
67 65
68 // Retrieves the encryption information associated with the subscription 66 // Retrieves the subscription associated with |origin| and
69 // associated to |origin| and |service_worker_registration_id|. |sender_id| is 67 // |service_worker_registration_id|, validates that the provided
70 // also required since an InstanceID might have multiple tokens associated 68 // |subscription_id| matches the stored one, then passes the encryption
71 // with different senders, though in practice Push doesn't yet use that. 69 // information to the callback. |sender_id| is also required since an
72 virtual void GetEncryptionInfo(const GURL& origin, 70 // InstanceID might have multiple tokens associated with different senders,
73 int64_t service_worker_registration_id, 71 // though in practice Push doesn't yet use that.
74 const std::string& sender_id, 72 virtual void GetSubscriptionInfo(
75 const EncryptionInfoCallback& callback) = 0; 73 const GURL& origin,
74 int64_t service_worker_registration_id,
75 const std::string& sender_id,
76 const std::string& subscription_id,
77 const SubscriptionInfoCallback& callback) = 0;
76 78
77 // Unsubscribe the given |sender_id| from the push messaging service. The 79 // Unsubscribe the given |sender_id| from the push messaging service. Locally
78 // subscription will be synchronously deactivated locally, and asynchronously 80 // deactivates the subscription, then runs |callback|, then asynchronously
79 // sent to the push service, with automatic retry. 81 // attempts to unsubscribe with the push service.
80 virtual void Unsubscribe(const GURL& requesting_origin, 82 virtual void Unsubscribe(PushUnregistrationReason reason,
83 const GURL& requesting_origin,
81 int64_t service_worker_registration_id, 84 int64_t service_worker_registration_id,
82 const std::string& sender_id, 85 const std::string& sender_id,
83 const UnregisterCallback& callback) = 0; 86 const UnregisterCallback& callback) = 0;
84 87
85 // Checks the permission status for the |origin|. The |user_visible| boolean 88 // Checks the permission status for the |origin|. The |user_visible| boolean
86 // indicates whether the permission status only has to cover push messages 89 // indicates whether the permission status only has to cover push messages
87 // resulting in visible effects to the user. 90 // resulting in visible effects to the user.
88 virtual blink::WebPushPermissionStatus GetPermissionStatus( 91 virtual blink::WebPushPermissionStatus GetPermissionStatus(
89 const GURL& origin, 92 const GURL& origin,
90 bool user_visible) = 0; 93 bool user_visible) = 0;
(...skipping 29 matching lines...) Expand all
120 const GURL& origin, 123 const GURL& origin,
121 int64_t service_worker_registration_id, 124 int64_t service_worker_registration_id,
122 const std::string& subscription_id, 125 const std::string& subscription_id,
123 const std::string& sender_id, 126 const std::string& sender_id,
124 const base::Closure& callback); 127 const base::Closure& callback);
125 }; 128 };
126 129
127 } // namespace content 130 } // namespace content
128 131
129 #endif // CONTENT_PUBLIC_BROWSER_PUSH_MESSAGING_SERVICE_H_ 132 #endif // CONTENT_PUBLIC_BROWSER_PUSH_MESSAGING_SERVICE_H_
OLDNEW
« no previous file with comments | « content/common/push_messaging_param_traits.cc ('k') | content/public/common/push_messaging_status.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698