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.
5 #ifndef CONTENT_RENDERER_PUSH_MESSAGING_DISPATCHER_H_
6 #define CONTENT_RENDERER_PUSH_MESSAGING_DISPATCHER_H_
10 #include "base/id_map.h"
11 #include "content/public/common/push_messaging_status.h"
12 #include "content/public/renderer/render_frame_observer.h"
13 #include "third_party/WebKit/public/platform/WebPushClient.h"
22 class WebServiceWorkerProvider
;
30 class PushMessagingDispatcher
: public RenderFrameObserver
,
31 public blink::WebPushClient
{
33 explicit PushMessagingDispatcher(RenderFrame
* render_frame
);
34 virtual ~PushMessagingDispatcher();
37 // RenderFrame::Observer implementation.
38 virtual bool OnMessageReceived(const IPC::Message
& message
) override
;
40 // WebPushClient implementation.
41 virtual void registerPushMessaging(
42 const blink::WebString
& sender_id
,
43 blink::WebPushRegistrationCallbacks
* callbacks
,
44 blink::WebServiceWorkerProvider
* service_worker_provider
);
46 void DoRegister(const std::string
& sender_id
,
47 blink::WebPushRegistrationCallbacks
* callbacks
,
48 blink::WebServiceWorkerProvider
* service_worker_provider
,
49 const Manifest
& manifest
);
51 void OnRegisterSuccess(int32 callbacks_id
,
53 const std::string
& registration_id
);
55 void OnRegisterError(int32 callbacks_id
, PushMessagingStatus status
);
57 IDMap
<blink::WebPushRegistrationCallbacks
, IDMapOwnPointer
>
58 registration_callbacks_
;
60 DISALLOW_COPY_AND_ASSIGN(PushMessagingDispatcher
);
63 } // namespace content
65 #endif // CONTENT_RENDERER_PUSH_MESSAGING_DISPATCHER_H_