| 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 | 19 |
| 20 namespace message_center { | 20 namespace message_center { |
| 21 | 21 |
| 22 struct MESSAGE_CENTER_EXPORT NotificationItem { | 22 struct MESSAGE_CENTER_EXPORT NotificationItem { |
| 23 string16 title; | 23 base::string16 title; |
| 24 string16 message; | 24 base::string16 message; |
| 25 | 25 |
| 26 NotificationItem(const string16& title, const string16& message); | 26 NotificationItem(const base::string16& title, const base::string16& message); |
| 27 }; | 27 }; |
| 28 | 28 |
| 29 struct MESSAGE_CENTER_EXPORT ButtonInfo { | 29 struct MESSAGE_CENTER_EXPORT ButtonInfo { |
| 30 string16 title; | 30 base::string16 title; |
| 31 gfx::Image icon; | 31 gfx::Image icon; |
| 32 | 32 |
| 33 ButtonInfo(const string16& title); | 33 ButtonInfo(const base::string16& title); |
| 34 }; | 34 }; |
| 35 | 35 |
| 36 class MESSAGE_CENTER_EXPORT RichNotificationData { | 36 class MESSAGE_CENTER_EXPORT RichNotificationData { |
| 37 public: | 37 public: |
| 38 RichNotificationData(); | 38 RichNotificationData(); |
| 39 RichNotificationData(const RichNotificationData& other); | 39 RichNotificationData(const RichNotificationData& other); |
| 40 ~RichNotificationData(); | 40 ~RichNotificationData(); |
| 41 | 41 |
| 42 int priority; | 42 int priority; |
| 43 bool never_timeout; | 43 bool never_timeout; |
| 44 base::Time timestamp; | 44 base::Time timestamp; |
| 45 string16 expanded_message; | 45 base::string16 expanded_message; |
| 46 string16 context_message; | 46 base::string16 context_message; |
| 47 gfx::Image image; | 47 gfx::Image image; |
| 48 std::vector<NotificationItem> items; | 48 std::vector<NotificationItem> items; |
| 49 int progress; | 49 int progress; |
| 50 std::vector<ButtonInfo> buttons; | 50 std::vector<ButtonInfo> buttons; |
| 51 bool should_make_spoken_feedback_for_popup_updates; | 51 bool should_make_spoken_feedback_for_popup_updates; |
| 52 bool clickable; | 52 bool clickable; |
| 53 }; | 53 }; |
| 54 | 54 |
| 55 class MESSAGE_CENTER_EXPORT Notification { | 55 class MESSAGE_CENTER_EXPORT Notification { |
| 56 public: | 56 public: |
| 57 Notification(NotificationType type, | 57 Notification(NotificationType type, |
| 58 const std::string& id, | 58 const std::string& id, |
| 59 const string16& title, | 59 const base::string16& title, |
| 60 const string16& message, | 60 const base::string16& message, |
| 61 const gfx::Image& icon, | 61 const gfx::Image& icon, |
| 62 const string16& display_source, | 62 const base::string16& display_source, |
| 63 const NotifierId& notifier_id, | 63 const NotifierId& notifier_id, |
| 64 const RichNotificationData& optional_fields, | 64 const RichNotificationData& optional_fields, |
| 65 NotificationDelegate* delegate); | 65 NotificationDelegate* delegate); |
| 66 | 66 |
| 67 Notification(const Notification& other); | 67 Notification(const Notification& other); |
| 68 Notification& operator=(const Notification& other); | 68 Notification& operator=(const Notification& other); |
| 69 virtual ~Notification(); | 69 virtual ~Notification(); |
| 70 | 70 |
| 71 // Copies the internal on-memory state from |base|, i.e. shown_as_popup, | 71 // Copies the internal on-memory state from |base|, i.e. shown_as_popup, |
| 72 // is_read, is_expanded, and never_timeout. | 72 // is_read, is_expanded, and never_timeout. |
| 73 void CopyState(Notification* base); | 73 void CopyState(Notification* base); |
| 74 | 74 |
| 75 NotificationType type() const { return type_; } | 75 NotificationType type() const { return type_; } |
| 76 void set_type(NotificationType type) { type_ = type; } | 76 void set_type(NotificationType type) { type_ = type; } |
| 77 | 77 |
| 78 const std::string& id() const { return id_; } | 78 const std::string& id() const { return id_; } |
| 79 | 79 |
| 80 const string16& title() const { return title_; } | 80 const base::string16& title() const { return title_; } |
| 81 void set_title(const string16& title) { title_ = title; } | 81 void set_title(const base::string16& title) { title_ = title; } |
| 82 | 82 |
| 83 const string16& message() const { return message_; } | 83 const base::string16& message() const { return message_; } |
| 84 void set_message(const string16& message) { message_ = message; } | 84 void set_message(const base::string16& message) { message_ = message; } |
| 85 | 85 |
| 86 // A display string for the source of the notification. | 86 // A display string for the source of the notification. |
| 87 const string16& display_source() const { return display_source_; } | 87 const base::string16& display_source() const { return display_source_; } |
| 88 | 88 |
| 89 const NotifierId& notifier_id() const { return notifier_id_; } | 89 const NotifierId& notifier_id() const { return notifier_id_; } |
| 90 | 90 |
| 91 void set_profile_id(const std::string& profile_id) { | 91 void set_profile_id(const std::string& profile_id) { |
| 92 notifier_id_.profile_id = profile_id; | 92 notifier_id_.profile_id = profile_id; |
| 93 } | 93 } |
| 94 | 94 |
| 95 // Begin unpacked values from optional_fields. | 95 // Begin unpacked values from optional_fields. |
| 96 int priority() const { return optional_fields_.priority; } | 96 int priority() const { return optional_fields_.priority; } |
| 97 void set_priority(int priority) { optional_fields_.priority = priority; } | 97 void set_priority(int priority) { optional_fields_.priority = priority; } |
| 98 | 98 |
| 99 base::Time timestamp() const { return optional_fields_.timestamp; } | 99 base::Time timestamp() const { return optional_fields_.timestamp; } |
| 100 void set_timestamp(const base::Time& timestamp) { | 100 void set_timestamp(const base::Time& timestamp) { |
| 101 optional_fields_.timestamp = timestamp; | 101 optional_fields_.timestamp = timestamp; |
| 102 } | 102 } |
| 103 | 103 |
| 104 const string16& expanded_message() const { | 104 const base::string16& expanded_message() const { |
| 105 return optional_fields_.expanded_message; | 105 return optional_fields_.expanded_message; |
| 106 } | 106 } |
| 107 void set_expanded_message(const string16& expanded_message) { | 107 void set_expanded_message(const base::string16& expanded_message) { |
| 108 optional_fields_.expanded_message = expanded_message; | 108 optional_fields_.expanded_message = expanded_message; |
| 109 } | 109 } |
| 110 | 110 |
| 111 const string16& context_message() const { | 111 const base::string16& context_message() const { |
| 112 return optional_fields_.context_message; | 112 return optional_fields_.context_message; |
| 113 } | 113 } |
| 114 void set_context_message(const string16& context_message) { | 114 void set_context_message(const base::string16& context_message) { |
| 115 optional_fields_.context_message = context_message; | 115 optional_fields_.context_message = context_message; |
| 116 } | 116 } |
| 117 | 117 |
| 118 const std::vector<NotificationItem>& items() const { | 118 const std::vector<NotificationItem>& items() const { |
| 119 return optional_fields_.items; | 119 return optional_fields_.items; |
| 120 } | 120 } |
| 121 void set_items(const std::vector<NotificationItem>& items) { | 121 void set_items(const std::vector<NotificationItem>& items) { |
| 122 optional_fields_.items = items; | 122 optional_fields_.items = items; |
| 123 } | 123 } |
| 124 | 124 |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 const base::string16& message, | 198 const base::string16& message, |
| 199 const gfx::Image& icon, | 199 const gfx::Image& icon, |
| 200 const std::string& system_component_id, | 200 const std::string& system_component_id, |
| 201 const base::Closure& click_callback); | 201 const base::Closure& click_callback); |
| 202 | 202 |
| 203 protected: | 203 protected: |
| 204 // The type of notification we'd like displayed. | 204 // The type of notification we'd like displayed. |
| 205 NotificationType type_; | 205 NotificationType type_; |
| 206 | 206 |
| 207 std::string id_; | 207 std::string id_; |
| 208 string16 title_; | 208 base::string16 title_; |
| 209 string16 message_; | 209 base::string16 message_; |
| 210 | 210 |
| 211 // Image data for the associated icon, used by Ash when available. | 211 // Image data for the associated icon, used by Ash when available. |
| 212 gfx::Image icon_; | 212 gfx::Image icon_; |
| 213 | 213 |
| 214 // The display string for the source of the notification. Could be | 214 // The display string for the source of the notification. Could be |
| 215 // the same as origin_url_, or the name of an extension. | 215 // the same as origin_url_, or the name of an extension. |
| 216 string16 display_source_; | 216 base::string16 display_source_; |
| 217 | 217 |
| 218 private: | 218 private: |
| 219 NotifierId notifier_id_; | 219 NotifierId notifier_id_; |
| 220 unsigned serial_number_; | 220 unsigned serial_number_; |
| 221 RichNotificationData optional_fields_; | 221 RichNotificationData optional_fields_; |
| 222 bool shown_as_popup_; // True if this has been shown as a popup. | 222 bool shown_as_popup_; // True if this has been shown as a popup. |
| 223 bool is_read_; // True if this has been seen in the message center. | 223 bool is_read_; // True if this has been seen in the message center. |
| 224 bool is_expanded_; // True if this has been expanded in the message center. | 224 bool is_expanded_; // True if this has been expanded in the message center. |
| 225 | 225 |
| 226 // A proxy object that allows access back to the JavaScript object that | 226 // A proxy object that allows access back to the JavaScript object that |
| 227 // represents the notification, for firing events. | 227 // represents the notification, for firing events. |
| 228 scoped_refptr<NotificationDelegate> delegate_; | 228 scoped_refptr<NotificationDelegate> delegate_; |
| 229 }; | 229 }; |
| 230 | 230 |
| 231 } // namespace message_center | 231 } // namespace message_center |
| 232 | 232 |
| 233 #endif // UI_MESSAGE_CENTER_NOTIFICATION_H_ | 233 #endif // UI_MESSAGE_CENTER_NOTIFICATION_H_ |
| OLD | NEW |