| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CONTENT_RENDERER_PUSH_MESSAGING_PUSH_MESSAGING_DISPATCHER_H_ | |
| 6 #define CONTENT_RENDERER_PUSH_MESSAGING_PUSH_MESSAGING_DISPATCHER_H_ | |
| 7 | |
| 8 #include <stdint.h> | |
| 9 | |
| 10 #include <memory> | |
| 11 #include <string> | |
| 12 #include <vector> | |
| 13 | |
| 14 #include "base/id_map.h" | |
| 15 #include "base/macros.h" | |
| 16 #include "content/public/common/push_messaging_status.h" | |
| 17 #include "content/public/renderer/render_frame_observer.h" | |
| 18 #include "third_party/WebKit/public/platform/modules/push_messaging/WebPushClien
t.h" | |
| 19 #include "third_party/WebKit/public/platform/modules/push_messaging/WebPushPermi
ssionStatus.h" | |
| 20 | |
| 21 class GURL; | |
| 22 | |
| 23 namespace blink { | |
| 24 struct WebPushSubscriptionOptions; | |
| 25 } | |
| 26 | |
| 27 namespace IPC { | |
| 28 class Message; | |
| 29 } // namespace IPC | |
| 30 | |
| 31 namespace content { | |
| 32 | |
| 33 struct Manifest; | |
| 34 struct ManifestDebugInfo; | |
| 35 struct PushSubscriptionOptions; | |
| 36 | |
| 37 class PushMessagingDispatcher : public RenderFrameObserver, | |
| 38 public blink::WebPushClient { | |
| 39 public: | |
| 40 explicit PushMessagingDispatcher(RenderFrame* render_frame); | |
| 41 ~PushMessagingDispatcher() override; | |
| 42 | |
| 43 private: | |
| 44 // RenderFrameObserver implementation. | |
| 45 bool OnMessageReceived(const IPC::Message& message) override; | |
| 46 void OnDestruct() override; | |
| 47 | |
| 48 // WebPushClient implementation. | |
| 49 void subscribe( | |
| 50 blink::WebServiceWorkerRegistration* service_worker_registration, | |
| 51 const blink::WebPushSubscriptionOptions& options, | |
| 52 std::unique_ptr<blink::WebPushSubscriptionCallbacks> callbacks) override; | |
| 53 | |
| 54 void DidGetManifest( | |
| 55 blink::WebServiceWorkerRegistration* service_worker_registration, | |
| 56 const blink::WebPushSubscriptionOptions& options, | |
| 57 std::unique_ptr<blink::WebPushSubscriptionCallbacks> callbacks, | |
| 58 const GURL& manifest_url, | |
| 59 const Manifest& manifest, | |
| 60 const ManifestDebugInfo&); | |
| 61 | |
| 62 void DoSubscribe( | |
| 63 blink::WebServiceWorkerRegistration* service_worker_registration, | |
| 64 const PushSubscriptionOptions& options, | |
| 65 std::unique_ptr<blink::WebPushSubscriptionCallbacks> callbacks); | |
| 66 | |
| 67 void OnSubscribeFromDocumentSuccess(int32_t request_id, | |
| 68 const GURL& endpoint, | |
| 69 const PushSubscriptionOptions& options, | |
| 70 const std::vector<uint8_t>& p256dh, | |
| 71 const std::vector<uint8_t>& auth); | |
| 72 | |
| 73 void OnSubscribeFromDocumentError(int32_t request_id, | |
| 74 PushRegistrationStatus status); | |
| 75 | |
| 76 IDMap<std::unique_ptr<blink::WebPushSubscriptionCallbacks>> | |
| 77 subscription_callbacks_; | |
| 78 | |
| 79 DISALLOW_COPY_AND_ASSIGN(PushMessagingDispatcher); | |
| 80 }; | |
| 81 | |
| 82 } // namespace content | |
| 83 | |
| 84 #endif // CONTENT_RENDERER_PUSH_MESSAGING_PUSH_MESSAGING_DISPATCHER_H_ | |
| OLD | NEW |