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