OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 UI_MESSAGE_CENTER_NOTIFICATION_H_ | 5 #ifndef UI_MESSAGE_CENTER_NOTIFICATION_H_ |
6 #define UI_MESSAGE_CENTER_NOTIFICATION_H_ | 6 #define UI_MESSAGE_CENTER_NOTIFICATION_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/strings/string16.h" | 11 #include "base/strings/string16.h" |
12 #include "base/time/time.h" | 12 #include "base/time/time.h" |
13 #include "base/values.h" | 13 #include "base/values.h" |
14 #include "ui/gfx/image/image.h" | 14 #include "ui/gfx/image/image.h" |
15 #include "ui/message_center/message_center_export.h" | 15 #include "ui/message_center/message_center_export.h" |
16 #include "ui/message_center/notification_delegate.h" | 16 #include "ui/message_center/notification_delegate.h" |
17 #include "ui/message_center/notification_types.h" | 17 #include "ui/message_center/notification_types.h" |
18 #include "ui/message_center/notifier_settings.h" | 18 #include "ui/message_center/notifier_settings.h" |
| 19 #include "url/gurl.h" |
19 | 20 |
20 namespace message_center { | 21 namespace message_center { |
21 | 22 |
22 struct MESSAGE_CENTER_EXPORT NotificationItem { | 23 struct MESSAGE_CENTER_EXPORT NotificationItem { |
23 base::string16 title; | 24 base::string16 title; |
24 base::string16 message; | 25 base::string16 message; |
25 | 26 |
26 NotificationItem(const base::string16& title, const base::string16& message); | 27 NotificationItem(const base::string16& title, const base::string16& message); |
27 }; | 28 }; |
28 | 29 |
(...skipping 26 matching lines...) Expand all Loading... |
55 }; | 56 }; |
56 | 57 |
57 class MESSAGE_CENTER_EXPORT Notification { | 58 class MESSAGE_CENTER_EXPORT Notification { |
58 public: | 59 public: |
59 Notification(NotificationType type, | 60 Notification(NotificationType type, |
60 const std::string& id, | 61 const std::string& id, |
61 const base::string16& title, | 62 const base::string16& title, |
62 const base::string16& message, | 63 const base::string16& message, |
63 const gfx::Image& icon, | 64 const gfx::Image& icon, |
64 const base::string16& display_source, | 65 const base::string16& display_source, |
| 66 const GURL& origin_url, |
65 const NotifierId& notifier_id, | 67 const NotifierId& notifier_id, |
66 const RichNotificationData& optional_fields, | 68 const RichNotificationData& optional_fields, |
67 NotificationDelegate* delegate); | 69 NotificationDelegate* delegate); |
68 | 70 |
69 Notification(const std::string& id, const Notification& other); | 71 Notification(const std::string& id, const Notification& other); |
70 | 72 |
71 Notification(const Notification& other); | 73 Notification(const Notification& other); |
72 | 74 |
73 virtual ~Notification(); | 75 virtual ~Notification(); |
74 | 76 |
(...skipping 10 matching lines...) Expand all Loading... |
85 // Use this id against the MessageCenter interface but not the | 87 // Use this id against the MessageCenter interface but not the |
86 // NotificationUIManager interface. | 88 // NotificationUIManager interface. |
87 const std::string& id() const { return id_; } | 89 const std::string& id() const { return id_; } |
88 | 90 |
89 const base::string16& title() const { return title_; } | 91 const base::string16& title() const { return title_; } |
90 void set_title(const base::string16& title) { title_ = title; } | 92 void set_title(const base::string16& title) { title_ = title; } |
91 | 93 |
92 const base::string16& message() const { return message_; } | 94 const base::string16& message() const { return message_; } |
93 void set_message(const base::string16& message) { message_ = message; } | 95 void set_message(const base::string16& message) { message_ = message; } |
94 | 96 |
| 97 // The origin URL of the script which requested the notification. |
| 98 // Can be empty if the notification is requested by an extension or |
| 99 // Chrome app. |
| 100 const GURL& origin_url() const { return origin_url_; } |
| 101 |
95 // A display string for the source of the notification. | 102 // A display string for the source of the notification. |
96 const base::string16& display_source() const { return display_source_; } | 103 const base::string16& display_source() const { return display_source_; } |
97 | 104 |
98 const NotifierId& notifier_id() const { return notifier_id_; } | 105 const NotifierId& notifier_id() const { return notifier_id_; } |
99 | 106 |
100 void set_profile_id(const std::string& profile_id) { | 107 void set_profile_id(const std::string& profile_id) { |
101 notifier_id_.profile_id = profile_id; | 108 notifier_id_.profile_id = profile_id; |
102 } | 109 } |
103 | 110 |
104 // Begin unpacked values from optional_fields. | 111 // Begin unpacked values from optional_fields. |
(...skipping 11 matching lines...) Expand all Loading... |
116 | 123 |
117 // This property currently has no effect on non-Android platforms. | 124 // This property currently has no effect on non-Android platforms. |
118 bool silent() const { return optional_fields_.silent; } | 125 bool silent() const { return optional_fields_.silent; } |
119 void set_silent(bool silent) { optional_fields_.silent = silent; } | 126 void set_silent(bool silent) { optional_fields_.silent = silent; } |
120 | 127 |
121 base::Time timestamp() const { return optional_fields_.timestamp; } | 128 base::Time timestamp() const { return optional_fields_.timestamp; } |
122 void set_timestamp(const base::Time& timestamp) { | 129 void set_timestamp(const base::Time& timestamp) { |
123 optional_fields_.timestamp = timestamp; | 130 optional_fields_.timestamp = timestamp; |
124 } | 131 } |
125 | 132 |
126 const base::string16& context_message() const { | 133 const base::string16 context_message() const { |
127 return optional_fields_.context_message; | 134 return optional_fields_.context_message; |
128 } | 135 } |
| 136 |
129 void set_context_message(const base::string16& context_message) { | 137 void set_context_message(const base::string16& context_message) { |
130 optional_fields_.context_message = context_message; | 138 optional_fields_.context_message = context_message; |
131 } | 139 } |
132 | 140 |
| 141 // Decides if the notification origin should be used as a context message |
| 142 bool UseOriginAsContextMessage() const; |
| 143 |
133 const std::vector<NotificationItem>& items() const { | 144 const std::vector<NotificationItem>& items() const { |
134 return optional_fields_.items; | 145 return optional_fields_.items; |
135 } | 146 } |
136 void set_items(const std::vector<NotificationItem>& items) { | 147 void set_items(const std::vector<NotificationItem>& items) { |
137 optional_fields_.items = items; | 148 optional_fields_.items = items; |
138 } | 149 } |
139 | 150 |
140 int progress() const { return optional_fields_.progress; } | 151 int progress() const { return optional_fields_.progress; } |
141 void set_progress(int progress) { optional_fields_.progress = progress; } | 152 void set_progress(int progress) { optional_fields_.progress = progress; } |
142 // End unpacked values. | 153 // End unpacked values. |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 base::string16 message_; | 237 base::string16 message_; |
227 | 238 |
228 // Image data for the associated icon, used by Ash when available. | 239 // Image data for the associated icon, used by Ash when available. |
229 gfx::Image icon_; | 240 gfx::Image icon_; |
230 | 241 |
231 // The display string for the source of the notification. Could be | 242 // The display string for the source of the notification. Could be |
232 // the same as origin_url_, or the name of an extension. | 243 // the same as origin_url_, or the name of an extension. |
233 base::string16 display_source_; | 244 base::string16 display_source_; |
234 | 245 |
235 private: | 246 private: |
| 247 // The origin URL of the script which requested the notification. |
| 248 // Can be empty if requested through a chrome app or extension or if |
| 249 // it's a system notification. |
| 250 GURL origin_url_; |
236 NotifierId notifier_id_; | 251 NotifierId notifier_id_; |
237 unsigned serial_number_; | 252 unsigned serial_number_; |
238 RichNotificationData optional_fields_; | 253 RichNotificationData optional_fields_; |
239 bool shown_as_popup_; // True if this has been shown as a popup. | 254 bool shown_as_popup_; // True if this has been shown as a popup. |
240 bool is_read_; // True if this has been seen in the message center. | 255 bool is_read_; // True if this has been seen in the message center. |
241 | 256 |
242 // A proxy object that allows access back to the JavaScript object that | 257 // A proxy object that allows access back to the JavaScript object that |
243 // represents the notification, for firing events. | 258 // represents the notification, for firing events. |
244 scoped_refptr<NotificationDelegate> delegate_; | 259 scoped_refptr<NotificationDelegate> delegate_; |
245 }; | 260 }; |
246 | 261 |
247 } // namespace message_center | 262 } // namespace message_center |
248 | 263 |
249 #endif // UI_MESSAGE_CENTER_NOTIFICATION_H_ | 264 #endif // UI_MESSAGE_CENTER_NOTIFICATION_H_ |
OLD | NEW |