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