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