OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 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 | 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_H_ | 5 #ifndef CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_H_ |
6 #define CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_H_ | 6 #define CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_H_ |
7 | 7 |
| 8 #include <string> |
| 9 |
8 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
9 #include "chrome/browser/notifications/notification_object_proxy.h" | 11 #include "chrome/browser/notifications/notification_object_proxy.h" |
10 #include "googleurl/src/gurl.h" | 12 #include "googleurl/src/gurl.h" |
11 | 13 |
12 // Representation of an notification to be shown to the user. All | 14 // Representation of an notification to be shown to the user. All |
13 // notifications at this level are HTML, although they may be | 15 // notifications at this level are HTML, although they may be |
14 // data: URLs representing simple text+icon notifications. | 16 // data: URLs representing simple text+icon notifications. |
15 class Notification { | 17 class Notification { |
16 public: | 18 public: |
17 Notification(const GURL& origin_url, const GURL& content_url, | 19 Notification(const GURL& origin_url, const GURL& content_url, |
| 20 const std::wstring& display_source, |
18 NotificationObjectProxy* proxy) | 21 NotificationObjectProxy* proxy) |
19 : origin_url_(origin_url), | 22 : origin_url_(origin_url), |
20 content_url_(content_url), | 23 content_url_(content_url), |
| 24 display_source_(display_source), |
21 proxy_(proxy) { | 25 proxy_(proxy) { |
22 } | 26 } |
23 | 27 |
24 Notification(const Notification& notification) | 28 Notification(const Notification& notification) |
25 : origin_url_(notification.origin_url()), | 29 : origin_url_(notification.origin_url()), |
26 content_url_(notification.content_url()), | 30 content_url_(notification.content_url()), |
| 31 display_source_(notification.display_source()), |
27 proxy_(notification.proxy()) { | 32 proxy_(notification.proxy()) { |
28 } | 33 } |
29 | 34 |
30 // The URL (may be data:) containing the contents for the notification. | 35 // The URL (may be data:) containing the contents for the notification. |
31 const GURL& content_url() const { return content_url_; } | 36 const GURL& content_url() const { return content_url_; } |
32 | 37 |
33 // The origin URL of the script which requested the notification. | 38 // The origin URL of the script which requested the notification. |
34 const GURL& origin_url() const { return origin_url_; } | 39 const GURL& origin_url() const { return origin_url_; } |
35 | 40 |
| 41 // A display string for the source of the notification. |
| 42 const std::wstring& display_source() const { return display_source_; } |
| 43 |
36 void Display() const { proxy()->Display(); } | 44 void Display() const { proxy()->Display(); } |
37 void Error() const { proxy()->Error(); } | 45 void Error() const { proxy()->Error(); } |
38 void Close(bool by_user) const { proxy()->Close(by_user); } | 46 void Close(bool by_user) const { proxy()->Close(by_user); } |
39 | 47 |
40 bool IsSame(const Notification& other) const { | 48 bool IsSame(const Notification& other) const { |
41 return (*proxy_).IsSame(*(other.proxy())); | 49 return (*proxy_).IsSame(*(other.proxy())); |
42 } | 50 } |
43 | 51 |
44 private: | 52 private: |
45 NotificationObjectProxy* proxy() const { return proxy_.get(); } | 53 NotificationObjectProxy* proxy() const { return proxy_.get(); } |
46 | 54 |
47 // The Origin of the page/worker which created this notification. | 55 // The Origin of the page/worker which created this notification. |
48 GURL origin_url_; | 56 GURL origin_url_; |
49 | 57 |
50 // The URL of the HTML content of the toast (may be a data: URL for simple | 58 // The URL of the HTML content of the toast (may be a data: URL for simple |
51 // string-based notifications). | 59 // string-based notifications). |
52 GURL content_url_; | 60 GURL content_url_; |
53 | 61 |
| 62 // The display string for the source of the notification. Could be |
| 63 // the same as origin_url_, or the name of an extension. |
| 64 std::wstring display_source_; |
| 65 |
54 // A proxy object that allows access back to the JavaScript object that | 66 // A proxy object that allows access back to the JavaScript object that |
55 // represents the notification, for firing events. | 67 // represents the notification, for firing events. |
56 scoped_refptr<NotificationObjectProxy> proxy_; | 68 scoped_refptr<NotificationObjectProxy> proxy_; |
57 | 69 |
58 // Disallow assign. Copy constructor written above. | 70 // Disallow assign. Copy constructor written above. |
59 void operator=(const Notification&); | 71 void operator=(const Notification&); |
60 }; | 72 }; |
61 | 73 |
62 #endif // CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_H_ | 74 #endif // CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_H_ |
OLD | NEW |