OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_NOTIFICATION_PROVIDER_H_ | 5 #ifndef CONTENT_RENDERER_NOTIFICATION_PROVIDER_H_ |
6 #define CONTENT_RENDERER_NOTIFICATION_PROVIDER_H_ | 6 #define CONTENT_RENDERER_NOTIFICATION_PROVIDER_H_ |
7 | 7 |
8 #include "content/public/renderer/render_frame_observer.h" | 8 #include "content/public/renderer/render_frame_observer.h" |
9 #include "content/renderer/active_notification_tracker.h" | 9 #include "content/renderer/active_notification_tracker.h" |
10 #include "third_party/WebKit/public/web/WebNotification.h" | 10 #include "third_party/WebKit/public/web/WebNotification.h" |
11 #include "third_party/WebKit/public/web/WebNotificationPresenter.h" | 11 #include "third_party/WebKit/public/web/WebNotificationPresenter.h" |
12 | 12 |
13 namespace blink { | |
14 class WebNotificationPermissionCallback; | |
15 } | |
16 | |
17 namespace content { | 13 namespace content { |
18 | 14 |
19 // NotificationProvider class is owned by the RenderFrame. Only to be used on | 15 // NotificationProvider class is owned by the RenderFrame. Only to be used on |
20 // the main thread. | 16 // the main thread. |
21 class NotificationProvider : public RenderFrameObserver, | 17 class NotificationProvider : public RenderFrameObserver, |
22 public blink::WebNotificationPresenter { | 18 public blink::WebNotificationPresenter { |
23 public: | 19 public: |
24 explicit NotificationProvider(RenderFrame* render_frame); | 20 explicit NotificationProvider(RenderFrame* render_frame); |
25 virtual ~NotificationProvider(); | 21 virtual ~NotificationProvider(); |
26 | 22 |
27 private: | 23 private: |
28 // RenderFrameObserver implementation. | 24 // RenderFrameObserver implementation. |
29 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 25 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
30 | 26 |
31 // blink::WebNotificationPresenter interface. | 27 // blink::WebNotificationPresenter interface. |
32 virtual bool show(const blink::WebNotification& proxy); | 28 virtual bool show(const blink::WebNotification& proxy); |
33 virtual void cancel(const blink::WebNotification& proxy); | 29 virtual void cancel(const blink::WebNotification& proxy); |
34 virtual void objectDestroyed(const blink::WebNotification& proxy); | 30 virtual void objectDestroyed(const blink::WebNotification& proxy); |
35 virtual blink::WebNotificationPresenter::Permission checkPermission( | 31 virtual blink::WebNotificationPresenter::Permission checkPermission( |
36 const blink::WebSecurityOrigin& origin); | 32 const blink::WebSecurityOrigin& origin); |
37 virtual void requestPermission(const blink::WebSecurityOrigin& origin, | |
38 blink::WebNotificationPermissionCallback* callback); | |
39 | 33 |
40 // IPC handlers. | 34 // IPC handlers. |
41 void OnDisplay(int id); | 35 void OnDisplay(int id); |
42 void OnError(int id); | 36 void OnError(int id); |
43 void OnClose(int id, bool by_user); | 37 void OnClose(int id, bool by_user); |
44 void OnClick(int id); | 38 void OnClick(int id); |
45 void OnPermissionRequestComplete(int id); | |
46 void OnNavigate(); | 39 void OnNavigate(); |
47 | 40 |
48 // A tracker object which manages the active notifications and the IDs | 41 // A tracker object which manages the active notifications and the IDs |
49 // that are used to refer to them over IPC. | 42 // that are used to refer to them over IPC. |
50 ActiveNotificationTracker manager_; | 43 ActiveNotificationTracker manager_; |
51 | 44 |
52 DISALLOW_COPY_AND_ASSIGN(NotificationProvider); | 45 DISALLOW_COPY_AND_ASSIGN(NotificationProvider); |
53 }; | 46 }; |
54 | 47 |
55 } // namespace content | 48 } // namespace content |
56 | 49 |
57 #endif // CONTENT_RENDERER_NOTIFICATION_PROVIDER_H_ | 50 #endif // CONTENT_RENDERER_NOTIFICATION_PROVIDER_H_ |
OLD | NEW |