[email protected] | 4bb33630 | 2009-10-12 05:44:26 | [diff] [blame] | 1 | // Copyright (c) 2009 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. | ||||
4 | |||||
5 | #ifndef CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_OBJECT_PROXY_H_ | ||||
6 | #define CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_OBJECT_PROXY_H_ | ||||
[email protected] | 32b76ef | 2010-07-26 23:08:24 | [diff] [blame^] | 7 | #pragma once |
[email protected] | 4bb33630 | 2009-10-12 05:44:26 | [diff] [blame] | 8 | |
[email protected] | 3b84575 | 2010-03-17 01:19:06 | [diff] [blame] | 9 | #include <string> |
10 | |||||
11 | #include "chrome/browser/notifications/notification_delegate.h" | ||||
[email protected] | 4bb33630 | 2009-10-12 05:44:26 | [diff] [blame] | 12 | |
13 | class MessageLoop; | ||||
14 | namespace IPC { | ||||
15 | class Message; | ||||
16 | } | ||||
17 | |||||
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. | ||||
[email protected] | 11f485728 | 2009-11-13 19:56:17 | [diff] [blame] | 22 | class NotificationObjectProxy |
[email protected] | 3b84575 | 2010-03-17 01:19:06 | [diff] [blame] | 23 | : public NotificationDelegate { |
[email protected] | 4bb33630 | 2009-10-12 05:44:26 | [diff] [blame] | 24 | public: |
25 | // Creates a Proxy object with the necessary callback information. | ||||
26 | NotificationObjectProxy(int process_id, int route_id, | ||||
27 | int notification_id, bool worker); | ||||
28 | |||||
[email protected] | 3b84575 | 2010-03-17 01:19:06 | [diff] [blame] | 29 | // NotificationDelegate implementation. |
[email protected] | 8b7135d6aa | 2009-11-11 17:40:31 | [diff] [blame] | 30 | virtual void Display(); |
[email protected] | 8b7135d6aa | 2009-11-11 17:40:31 | [diff] [blame] | 31 | virtual void Error(); |
[email protected] | 8b7135d6aa | 2009-11-11 17:40:31 | [diff] [blame] | 32 | virtual void Close(bool by_user); |
[email protected] | 3b84575 | 2010-03-17 01:19:06 | [diff] [blame] | 33 | virtual std::string id() const; |
[email protected] | b52448bb | 2009-11-04 21:29:11 | [diff] [blame] | 34 | |
[email protected] | 8b7135d6aa | 2009-11-11 17:40:31 | [diff] [blame] | 35 | protected: |
[email protected] | 7991a23 | 2009-11-06 01:55:48 | [diff] [blame] | 36 | friend class base::RefCountedThreadSafe<NotificationObjectProxy>; |
37 | |||||
[email protected] | 8b7135d6aa | 2009-11-11 17:40:31 | [diff] [blame] | 38 | virtual ~NotificationObjectProxy() {} |
[email protected] | 7991a23 | 2009-11-06 01:55:48 | [diff] [blame] | 39 | |
[email protected] | 8b7135d6aa | 2009-11-11 17:40:31 | [diff] [blame] | 40 | private: |
[email protected] | 4bb33630 | 2009-10-12 05:44:26 | [diff] [blame] | 41 | // Called on UI thread to schedule a message for sending. |
42 | void DeliverMessage(IPC::Message* message); | ||||
43 | |||||
44 | // Called via Task on IO thread to actually send a message to a notification. | ||||
45 | void Send(IPC::Message* message); | ||||
46 | |||||
47 | // Callback information to find the JS Notification object where it lives. | ||||
48 | int process_id_; | ||||
49 | int route_id_; | ||||
50 | int notification_id_; | ||||
51 | bool worker_; | ||||
52 | }; | ||||
53 | |||||
54 | #endif // CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_OBJECT_PROXY_H_ |