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_DISPATCHER_H_ 6#define CONTENT_RENDERER_PUSH_MESSAGING_DISPATCHER_H_ 7 8#include <string> 9 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" 14 15class GURL; 16 17namespace IPC { 18class Message; 19} // namespace IPC 20 21namespace blink { 22class WebServiceWorkerProvider; 23class WebString; 24} // namespace blink 25 26namespace content { 27class PushMessagingDispatcher : public RenderFrameObserver, 28 public blink::WebPushClient { 29 public: 30 explicit PushMessagingDispatcher(RenderFrame* render_frame); 31 virtual ~PushMessagingDispatcher(); 32 33 private: 34 // RenderFrame::Observer implementation. 35 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; 36 37 // WebPushClient implementation. 38 // TODO(mvanouwerkerk): Delete this method once its callers are gone and 39 // WebPushClient no longer defines it (as pure virtual). 40 virtual void registerPushMessaging( 41 const blink::WebString& sender_id, 42 blink::WebPushRegistrationCallbacks* callbacks); 43 virtual void registerPushMessaging( 44 const blink::WebString& sender_id, 45 blink::WebPushRegistrationCallbacks* callbacks, 46 blink::WebServiceWorkerProvider* service_worker_provider); 47 48 void OnRegisterSuccess(int32 callbacks_id, 49 const GURL& endpoint, 50 const std::string& registration_id); 51 52 void OnRegisterError(int32 callbacks_id, PushMessagingStatus status); 53 54 IDMap<blink::WebPushRegistrationCallbacks, IDMapOwnPointer> 55 registration_callbacks_; 56 57 DISALLOW_COPY_AND_ASSIGN(PushMessagingDispatcher); 58}; 59 60} // namespace content 61 62#endif // CONTENT_RENDERER_PUSH_MESSAGING_DISPATCHER_H_ 63