blob: 620464366706764c76a15aa4d51f4bd565d6caba [file] [log] [blame]
[email protected]24492412010-08-15 19:00:191// Copyright (c) 2010 The Chromium Authors. All rights reserved.
[email protected]90e908552009-10-05 01:40:122// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
[email protected]230b7ef2011-03-16 22:30:195#ifndef CONTENT_RENDERER_NOTIFICATION_PROVIDER_H_
6#define CONTENT_RENDERER_NOTIFICATION_PROVIDER_H_
[email protected]32b76ef2010-07-26 23:08:247#pragma once
[email protected]90e908552009-10-05 01:40:128
[email protected]3a034ebb2011-10-03 19:19:449#include "content/public/renderer/render_view_observer.h"
[email protected]797c3552011-03-17 00:26:1810#include "content/renderer/active_notification_tracker.h"
[email protected]8bd0fe62011-01-17 06:44:3711#include "third_party/WebKit/Source/WebKit/chromium/public/WebNotification.h"
12#include "third_party/WebKit/Source/WebKit/chromium/public/WebNotificationPresenter.h"
[email protected]90e908552009-10-05 01:40:1213
[email protected]310ebd6302011-10-10 19:06:2814class RenderViewImpl;
15
[email protected]90e908552009-10-05 01:40:1216namespace WebKit {
17class WebNotificationPermissionCallback;
18}
19
[email protected]b6849bda2009-10-14 23:59:2620// NotificationProvider class is owned by the RenderView. Only
[email protected]676126f72011-01-15 00:03:5121// to be used on the main thread.
[email protected]3a034ebb2011-10-03 19:19:4422class NotificationProvider : public content::RenderViewObserver,
[email protected]676126f72011-01-15 00:03:5123 public WebKit::WebNotificationPresenter {
[email protected]90e908552009-10-05 01:40:1224 public:
[email protected]310ebd6302011-10-10 19:06:2825 explicit NotificationProvider(RenderViewImpl* render_view);
[email protected]8a2a6a22010-08-17 00:37:2926 virtual ~NotificationProvider();
[email protected]90e908552009-10-05 01:40:1227
[email protected]676126f72011-01-15 00:03:5128 private:
29 // RenderView::Observer implementation.
[email protected]d2f05d02011-01-27 18:51:0130 virtual bool OnMessageReceived(const IPC::Message& message);
[email protected]676126f72011-01-15 00:03:5131
[email protected]b6849bda2009-10-14 23:59:2632 // WebKit::WebNotificationPresenter interface.
[email protected]90e908552009-10-05 01:40:1233 virtual bool show(const WebKit::WebNotification& proxy);
34 virtual void cancel(const WebKit::WebNotification& proxy);
35 virtual void objectDestroyed(const WebKit::WebNotification& proxy);
36 virtual WebKit::WebNotificationPresenter::Permission checkPermission(
[email protected]57a777f72010-03-31 01:09:4237 const WebKit::WebURL& url);
[email protected]d5f614f2010-04-06 18:44:2838 virtual void requestPermission(const WebKit::WebSecurityOrigin& origin,
[email protected]90e908552009-10-05 01:40:1239 WebKit::WebNotificationPermissionCallback* callback);
40
[email protected]b6849bda2009-10-14 23:59:2641 // Internal methods used to show notifications.
[email protected]90e908552009-10-05 01:40:1242 bool ShowHTML(const WebKit::WebNotification& notification, int id);
43 bool ShowText(const WebKit::WebNotification& notification, int id);
44
[email protected]b6849bda2009-10-14 23:59:2645 // IPC handlers.
[email protected]90e908552009-10-05 01:40:1246 void OnDisplay(int id);
47 void OnError(int id, const WebKit::WebString& message);
48 void OnClose(int id, bool by_user);
[email protected]0ff62862010-09-01 05:50:3549 void OnClick(int id);
[email protected]90e908552009-10-05 01:40:1250 void OnPermissionRequestComplete(int id);
[email protected]676126f72011-01-15 00:03:5151 void OnNavigate();
[email protected]90e908552009-10-05 01:40:1252
53 // A tracker object which manages the active notifications and the IDs
54 // that are used to refer to them over IPC.
55 ActiveNotificationTracker manager_;
56
57 DISALLOW_COPY_AND_ASSIGN(NotificationProvider);
58};
59
[email protected]230b7ef2011-03-16 22:30:1960#endif // CONTENT_RENDERER_NOTIFICATION_PROVIDER_H_