[email protected] | 2449241 | 2010-08-15 19:00:19 | [diff] [blame] | 1 | // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
[email protected] | 90e90855 | 2009-10-05 01:40:12 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
3 | // found in the LICENSE file. | ||||
4 | |||||
[email protected] | 230b7ef | 2011-03-16 22:30:19 | [diff] [blame] | 5 | #ifndef CONTENT_RENDERER_NOTIFICATION_PROVIDER_H_ |
6 | #define CONTENT_RENDERER_NOTIFICATION_PROVIDER_H_ | ||||
[email protected] | 32b76ef | 2010-07-26 23:08:24 | [diff] [blame] | 7 | #pragma once |
[email protected] | 90e90855 | 2009-10-05 01:40:12 | [diff] [blame] | 8 | |
[email protected] | 3a034ebb | 2011-10-03 19:19:44 | [diff] [blame] | 9 | #include "content/public/renderer/render_view_observer.h" |
[email protected] | 797c355 | 2011-03-17 00:26:18 | [diff] [blame] | 10 | #include "content/renderer/active_notification_tracker.h" |
[email protected] | 8bd0fe6 | 2011-01-17 06:44:37 | [diff] [blame] | 11 | #include "third_party/WebKit/Source/WebKit/chromium/public/WebNotification.h" |
12 | #include "third_party/WebKit/Source/WebKit/chromium/public/WebNotificationPresenter.h" | ||||
[email protected] | 90e90855 | 2009-10-05 01:40:12 | [diff] [blame] | 13 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 14 | class RenderViewImpl; |
15 | |||||
[email protected] | 90e90855 | 2009-10-05 01:40:12 | [diff] [blame] | 16 | namespace WebKit { |
17 | class WebNotificationPermissionCallback; | ||||
18 | } | ||||
19 | |||||
[email protected] | b6849bda | 2009-10-14 23:59:26 | [diff] [blame] | 20 | // NotificationProvider class is owned by the RenderView. Only |
[email protected] | 676126f7 | 2011-01-15 00:03:51 | [diff] [blame] | 21 | // to be used on the main thread. |
[email protected] | 3a034ebb | 2011-10-03 19:19:44 | [diff] [blame] | 22 | class NotificationProvider : public content::RenderViewObserver, |
[email protected] | 676126f7 | 2011-01-15 00:03:51 | [diff] [blame] | 23 | public WebKit::WebNotificationPresenter { |
[email protected] | 90e90855 | 2009-10-05 01:40:12 | [diff] [blame] | 24 | public: |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 25 | explicit NotificationProvider(RenderViewImpl* render_view); |
[email protected] | 8a2a6a2 | 2010-08-17 00:37:29 | [diff] [blame] | 26 | virtual ~NotificationProvider(); |
[email protected] | 90e90855 | 2009-10-05 01:40:12 | [diff] [blame] | 27 | |
[email protected] | 676126f7 | 2011-01-15 00:03:51 | [diff] [blame] | 28 | private: |
29 | // RenderView::Observer implementation. | ||||
[email protected] | d2f05d0 | 2011-01-27 18:51:01 | [diff] [blame] | 30 | virtual bool OnMessageReceived(const IPC::Message& message); |
[email protected] | 676126f7 | 2011-01-15 00:03:51 | [diff] [blame] | 31 | |
[email protected] | b6849bda | 2009-10-14 23:59:26 | [diff] [blame] | 32 | // WebKit::WebNotificationPresenter interface. |
[email protected] | 90e90855 | 2009-10-05 01:40:12 | [diff] [blame] | 33 | 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] | 57a777f7 | 2010-03-31 01:09:42 | [diff] [blame] | 37 | const WebKit::WebURL& url); |
[email protected] | d5f614f | 2010-04-06 18:44:28 | [diff] [blame] | 38 | virtual void requestPermission(const WebKit::WebSecurityOrigin& origin, |
[email protected] | 90e90855 | 2009-10-05 01:40:12 | [diff] [blame] | 39 | WebKit::WebNotificationPermissionCallback* callback); |
40 | |||||
[email protected] | b6849bda | 2009-10-14 23:59:26 | [diff] [blame] | 41 | // Internal methods used to show notifications. |
[email protected] | 90e90855 | 2009-10-05 01:40:12 | [diff] [blame] | 42 | bool ShowHTML(const WebKit::WebNotification& notification, int id); |
43 | bool ShowText(const WebKit::WebNotification& notification, int id); | ||||
44 | |||||
[email protected] | b6849bda | 2009-10-14 23:59:26 | [diff] [blame] | 45 | // IPC handlers. |
[email protected] | 90e90855 | 2009-10-05 01:40:12 | [diff] [blame] | 46 | void OnDisplay(int id); |
47 | void OnError(int id, const WebKit::WebString& message); | ||||
48 | void OnClose(int id, bool by_user); | ||||
[email protected] | 0ff6286 | 2010-09-01 05:50:35 | [diff] [blame] | 49 | void OnClick(int id); |
[email protected] | 90e90855 | 2009-10-05 01:40:12 | [diff] [blame] | 50 | void OnPermissionRequestComplete(int id); |
[email protected] | 676126f7 | 2011-01-15 00:03:51 | [diff] [blame] | 51 | void OnNavigate(); |
[email protected] | 90e90855 | 2009-10-05 01:40:12 | [diff] [blame] | 52 | |
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] | 230b7ef | 2011-03-16 22:30:19 | [diff] [blame] | 60 | #endif // CONTENT_RENDERER_NOTIFICATION_PROVIDER_H_ |