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