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

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

Issue 793403002: Implement WebPushProvider.unregister() in Chromium. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mvan_2
Patch Set: jochen review comments Created 6 years 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
« no previous file with comments | « content/common/push_messaging_messages.h ('k') | content/public/common/push_messaging_status.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/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 // A push service-agnostic interface that the Push API uses for talking to 18 // 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. 19 // push messaging services like GCM. Must only be used on the UI thread.
20 class CONTENT_EXPORT PushMessagingService { 20 class CONTENT_EXPORT PushMessagingService {
21 public: 21 public:
22 typedef base::Callback<void(const std::string& /* registration_id */, 22 using RegisterCallback =
23 PushRegistrationStatus /* status */)> 23 base::Callback<void(const std::string& /* registration_id */,
24 RegisterCallback; 24 PushRegistrationStatus /* status */)>;
25 using UnregisterCallback = base::Callback<void(PushUnregistrationStatus)>;
25 26
26 virtual ~PushMessagingService() {} 27 virtual ~PushMessagingService() {}
27 28
28 // Returns the absolute URL exposed by the push server where the webapp server 29 // Returns the absolute URL exposed by the push server where the webapp server
29 // can send push messages. This is currently assumed to be the same for all 30 // can send push messages. This is currently assumed to be the same for all
30 // origins and push registrations. 31 // origins and push registrations.
31 virtual GURL GetPushEndpoint() = 0; 32 virtual GURL GetPushEndpoint() = 0;
32 33
33 // Register the given |sender_id| with the push messaging service in a 34 // Register the given |sender_id| with the push messaging service in a
34 // document context. The frame is known and a permission UI may be displayed 35 // document context. The frame is known and a permission UI may be displayed
35 // to the user. 36 // to the user.
36 virtual void RegisterFromDocument(const GURL& requesting_origin, 37 virtual void RegisterFromDocument(const GURL& requesting_origin,
37 int64 service_worker_registration_id, 38 int64 service_worker_registration_id,
38 const std::string& sender_id, 39 const std::string& sender_id,
39 int renderer_id, 40 int renderer_id,
40 int render_frame_id, 41 int render_frame_id,
41 bool user_visible_only, 42 bool user_visible_only,
42 const RegisterCallback& callback) = 0; 43 const RegisterCallback& callback) = 0;
43 44
44 // Register the given |sender_id| with the push messaging service. The frame 45 // Register the given |sender_id| with the push messaging service. The frame
45 // is not known so if permission was not previously granted by the user this 46 // is not known so if permission was not previously granted by the user this
46 // request should fail. 47 // request should fail.
47 virtual void RegisterFromWorker(const GURL& requesting_origin, 48 virtual void RegisterFromWorker(const GURL& requesting_origin,
48 int64 service_worker_registration_id, 49 int64 service_worker_registration_id,
49 const std::string& sender_id, 50 const std::string& sender_id,
50 const RegisterCallback& callback) = 0; 51 const RegisterCallback& callback) = 0;
51 52
53 // Unregister an origin and its associated service worker registration id from
54 // the push service.
55 virtual void Unregister(const GURL& requesting_origin,
56 int64 service_worker_registration_id,
57 const UnregisterCallback& callback) = 0;
58
52 // Check whether the requester has permission to register for Push 59 // Check whether the requester has permission to register for Push
53 // Messages 60 // Messages
54 // TODO(mvanouwerkerk): Delete once the Push API flows through platform. 61 // TODO(mvanouwerkerk): Delete once the Push API flows through platform.
55 // https://crbug.com/389194 62 // https://crbug.com/389194
56 virtual blink::WebPushPermissionStatus GetPermissionStatus( 63 virtual blink::WebPushPermissionStatus GetPermissionStatus(
57 const GURL& requesting_origin, 64 const GURL& requesting_origin,
58 int renderer_id, 65 int renderer_id,
59 int render_frame_id) = 0; 66 int render_frame_id) = 0;
60 67
61 // Checks the permission status for the requesting origin. Permission is only 68 // Checks the permission status for the requesting origin. Permission is only
62 // ever granted when the requesting origin matches the top level embedding 69 // ever granted when the requesting origin matches the top level embedding
63 // origin. 70 // origin.
64 virtual blink::WebPushPermissionStatus GetPermissionStatus( 71 virtual blink::WebPushPermissionStatus GetPermissionStatus(
65 const GURL& requesting_origin, 72 const GURL& requesting_origin,
66 const GURL& embedding_origin) = 0; 73 const GURL& embedding_origin) = 0;
67 }; 74 };
68 75
69 } // namespace content 76 } // namespace content
70 77
71 #endif // CONTENT_PUBLIC_BROWSER_PUSH_MESSAGING_SERVICE_H_ 78 #endif // CONTENT_PUBLIC_BROWSER_PUSH_MESSAGING_SERVICE_H_
OLDNEW
« no previous file with comments | « content/common/push_messaging_messages.h ('k') | content/public/common/push_messaging_status.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698