OLD | NEW |
| (Empty) |
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. | |
4 | |
5 #ifndef CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_OBJECT_PROXY_H_ | |
6 #define CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_OBJECT_PROXY_H_ | |
7 | |
8 #include <memory> | |
9 #include <string> | |
10 | |
11 #include "base/macros.h" | |
12 #include "chrome/browser/notifications/web_notification_delegate.h" | |
13 | |
14 class GURL; | |
15 | |
16 namespace content { | |
17 class BrowserContext; | |
18 class DesktopNotificationDelegate; | |
19 } | |
20 | |
21 // A NotificationObjectProxy stands in for the JavaScript Notification object | |
22 // which corresponds to a notification toast on the desktop. It can be signaled | |
23 // when various events occur regarding the desktop notification, and the | |
24 // attached JS listeners will be invoked in the renderer or worker process. | |
25 class NotificationObjectProxy : public WebNotificationDelegate { | |
26 public: | |
27 // Creates a Proxy object with the necessary callback information. The Proxy | |
28 // will take ownership of |delegate|. | |
29 NotificationObjectProxy( | |
30 content::BrowserContext* browser_context, | |
31 const std::string& notification_id, | |
32 const GURL& origin, | |
33 std::unique_ptr<content::DesktopNotificationDelegate> delegate); | |
34 | |
35 // NotificationDelegate implementation. | |
36 void Display() override; | |
37 void Close(bool by_user) override; | |
38 void Click() override; | |
39 void ButtonClick(int button_index) override; | |
40 | |
41 protected: | |
42 ~NotificationObjectProxy() override; | |
43 | |
44 private: | |
45 std::unique_ptr<content::DesktopNotificationDelegate> delegate_; | |
46 bool displayed_; | |
47 | |
48 DISALLOW_COPY_AND_ASSIGN(NotificationObjectProxy); | |
49 }; | |
50 | |
51 #endif // CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_OBJECT_PROXY_H_ | |
OLD | NEW |