| 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 "base/memory/scoped_vector.h" |
| 8 #include "content/public/renderer/render_frame_observer.h" | 9 #include "content/public/renderer/render_frame_observer.h" |
| 9 #include "content/renderer/active_notification_tracker.h" | 10 #include "content/renderer/active_notification_tracker.h" |
| 10 #include "third_party/WebKit/public/web/WebNotification.h" | 11 #include "third_party/WebKit/public/web/WebNotification.h" |
| 11 #include "third_party/WebKit/public/web/WebNotificationPresenter.h" | 12 #include "third_party/WebKit/public/web/WebNotificationPresenter.h" |
| 12 | 13 |
| 14 class SkBitmap; |
| 15 |
| 13 namespace content { | 16 namespace content { |
| 14 | 17 |
| 15 // NotificationProvider class is owned by the RenderFrame. Only to be used on | 18 // NotificationProvider class is owned by the RenderFrame. Only to be used on |
| 16 // the main thread. | 19 // the main thread. |
| 17 class NotificationProvider : public RenderFrameObserver, | 20 class NotificationProvider : public RenderFrameObserver, |
| 18 public blink::WebNotificationPresenter { | 21 public blink::WebNotificationPresenter { |
| 19 public: | 22 public: |
| 20 explicit NotificationProvider(RenderFrame* render_frame); | 23 explicit NotificationProvider(RenderFrame* render_frame); |
| 21 virtual ~NotificationProvider(); | 24 virtual ~NotificationProvider(); |
| 22 | 25 |
| 23 private: | 26 private: |
| 24 // RenderFrameObserver implementation. | 27 // RenderFrameObserver implementation. |
| 25 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 28 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
| 26 | 29 |
| 27 // blink::WebNotificationPresenter interface. | 30 // blink::WebNotificationPresenter implementation. |
| 28 virtual bool show(const blink::WebNotification& proxy); | 31 virtual bool show(const blink::WebNotification& proxy); |
| 29 virtual void cancel(const blink::WebNotification& proxy); | 32 virtual void cancel(const blink::WebNotification& proxy); |
| 30 virtual void objectDestroyed(const blink::WebNotification& proxy); | 33 virtual void objectDestroyed(const blink::WebNotification& proxy); |
| 31 virtual blink::WebNotificationPresenter::Permission checkPermission( | 34 virtual blink::WebNotificationPresenter::Permission checkPermission( |
| 32 const blink::WebSecurityOrigin& origin); | 35 const blink::WebSecurityOrigin& origin); |
| 33 | 36 |
| 37 // Sends an IPC to the browser process to display |notification| |
| 38 // accompanied by the downloaded icon. |
| 39 void DisplayNotification(const blink::WebNotification& notification, |
| 40 const SkBitmap& icon); |
| 41 |
| 42 void CancelIconDownload(const blink::WebNotification& notification); |
| 43 |
| 34 // IPC handlers. | 44 // IPC handlers. |
| 35 void OnDisplay(int id); | 45 void OnDisplay(int id); |
| 36 void OnError(int id); | 46 void OnError(int id); |
| 37 void OnClose(int id, bool by_user); | 47 void OnClose(int id, bool by_user); |
| 38 void OnClick(int id); | 48 void OnClick(int id); |
| 39 void OnNavigate(); | 49 void OnNavigate(); |
| 40 | 50 |
| 51 class IconDownloader; |
| 52 |
| 53 // A vector tracking notifications which' icon is still being downloaded. |
| 54 typedef ScopedVector<IconDownloader> PendingNotifications; |
| 55 PendingNotifications pending_notifications_; |
| 56 |
| 41 // A tracker object which manages the active notifications and the IDs | 57 // A tracker object which manages the active notifications and the IDs |
| 42 // that are used to refer to them over IPC. | 58 // that are used to refer to them over IPC. |
| 43 ActiveNotificationTracker manager_; | 59 ActiveNotificationTracker manager_; |
| 44 | 60 |
| 45 DISALLOW_COPY_AND_ASSIGN(NotificationProvider); | 61 DISALLOW_COPY_AND_ASSIGN(NotificationProvider); |
| 46 }; | 62 }; |
| 47 | 63 |
| 48 } // namespace content | 64 } // namespace content |
| 49 | 65 |
| 50 #endif // CONTENT_RENDERER_NOTIFICATION_PROVIDER_H_ | 66 #endif // CONTENT_RENDERER_NOTIFICATION_PROVIDER_H_ |
| OLD | NEW |