| 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 CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_OBJECT_PROXY_H_ | 5 #ifndef CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_OBJECT_PROXY_H_ |
| 6 #define CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_OBJECT_PROXY_H_ | 6 #define CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_OBJECT_PROXY_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/memory/scoped_ptr.h" |
| 10 #include "chrome/browser/notifications/notification_delegate.h" | 11 #include "chrome/browser/notifications/notification_delegate.h" |
| 11 | 12 |
| 12 namespace content { | 13 namespace content { |
| 13 class DesktopNotificationDelegate; | 14 class DesktopNotificationDelegate; |
| 14 class RenderFrameHost; | 15 class RenderFrameHost; |
| 15 } | 16 } |
| 16 | 17 |
| 17 // A NotificationObjectProxy stands in for the JavaScript Notification object | 18 // A NotificationObjectProxy stands in for the JavaScript Notification object |
| 18 // which corresponds to a notification toast on the desktop. It can be signaled | 19 // which corresponds to a notification toast on the desktop. It can be signaled |
| 19 // when various events occur regarding the desktop notification, and the | 20 // when various events occur regarding the desktop notification, and the |
| 20 // attached JS listeners will be invoked in the renderer or worker process. | 21 // attached JS listeners will be invoked in the renderer or worker process. |
| 21 class NotificationObjectProxy | 22 class NotificationObjectProxy |
| 22 : public NotificationDelegate { | 23 : public NotificationDelegate { |
| 23 public: | 24 public: |
| 24 // Creates a Proxy object with the necessary callback information. | 25 // Creates a Proxy object with the necessary callback information. The Proxy |
| 25 NotificationObjectProxy(content::RenderFrameHost* render_frame_host, | 26 // will take ownership of |delegate|. |
| 26 content::DesktopNotificationDelegate* delegate); | 27 NotificationObjectProxy( |
| 28 content::RenderFrameHost* render_frame_host, |
| 29 scoped_ptr<content::DesktopNotificationDelegate> delegate); |
| 27 | 30 |
| 28 // NotificationDelegate implementation. | 31 // NotificationDelegate implementation. |
| 29 virtual void Display() OVERRIDE; | 32 virtual void Display() OVERRIDE; |
| 30 virtual void Error() OVERRIDE; | 33 virtual void Error() OVERRIDE; |
| 31 virtual void Close(bool by_user) OVERRIDE; | 34 virtual void Close(bool by_user) OVERRIDE; |
| 32 virtual void Click() OVERRIDE; | 35 virtual void Click() OVERRIDE; |
| 33 virtual std::string id() const OVERRIDE; | 36 virtual std::string id() const OVERRIDE; |
| 34 virtual int process_id() const OVERRIDE; | 37 virtual int process_id() const OVERRIDE; |
| 35 virtual content::WebContents* GetWebContents() const OVERRIDE; | 38 virtual content::WebContents* GetWebContents() const OVERRIDE; |
| 36 | 39 |
| 37 protected: | 40 protected: |
| 38 friend class base::RefCountedThreadSafe<NotificationObjectProxy>; | 41 friend class base::RefCountedThreadSafe<NotificationObjectProxy>; |
| 39 | 42 |
| 40 virtual ~NotificationObjectProxy() {} | 43 virtual ~NotificationObjectProxy(); |
| 41 | 44 |
| 42 private: | 45 private: |
| 43 // Callback information to find the JS Notification object where it lives. | 46 // Callback information to find the JS Notification object where it lives. |
| 44 int render_process_id_; | 47 int render_process_id_; |
| 45 int render_frame_id_; | 48 int render_frame_id_; |
| 46 content::DesktopNotificationDelegate* delegate_; | 49 scoped_ptr<content::DesktopNotificationDelegate> delegate_; |
| 47 bool displayed_; | 50 bool displayed_; |
| 48 std::string id_; | 51 std::string id_; |
| 49 }; | 52 }; |
| 50 | 53 |
| 51 #endif // CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_OBJECT_PROXY_H_ | 54 #endif // CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_OBJECT_PROXY_H_ |
| OLD | NEW |