| 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 #include "ui/message_center/notification.h" | 5 #include "ui/message_center/notification.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "ui/message_center/notification_delegate.h" | 8 #include "ui/message_center/notification_delegate.h" |
| 9 #include "ui/message_center/notification_types.h" | 9 #include "ui/message_center/notification_types.h" |
| 10 | 10 |
| 11 namespace { | 11 namespace { |
| 12 unsigned g_next_serial_number_ = 0; | 12 unsigned g_next_serial_number_ = 0; |
| 13 } | 13 } |
| 14 | 14 |
| 15 namespace message_center { | 15 namespace message_center { |
| 16 | 16 |
| 17 NotificationItem::NotificationItem(const base::string16& title, | 17 NotificationItem::NotificationItem(const base::string16& title, |
| 18 const base::string16& message) | 18 const base::string16& message) |
| 19 : title(title), | 19 : title(title), |
| 20 message(message) { | 20 message(message) { |
| 21 } | 21 } |
| 22 | 22 |
| 23 ButtonInfo::ButtonInfo(const base::string16& title) | 23 ButtonInfo::ButtonInfo(const base::string16& title) |
| 24 : title(title) { | 24 : title(title) { |
| 25 } | 25 } |
| 26 | 26 |
| 27 RichNotificationData::RichNotificationData() | 27 RichNotificationData::RichNotificationData() |
| 28 : priority(DEFAULT_PRIORITY), | 28 : priority(DEFAULT_PRIORITY), |
| 29 is_web_notification(false), |
| 29 never_timeout(false), | 30 never_timeout(false), |
| 30 timestamp(base::Time::Now()), | 31 timestamp(base::Time::Now()), |
| 31 context_message(base::string16()), | 32 context_message(base::string16()), |
| 32 progress(0), | 33 progress(0), |
| 33 should_make_spoken_feedback_for_popup_updates(true), | 34 should_make_spoken_feedback_for_popup_updates(true), |
| 34 clickable(true), | 35 clickable(true), |
| 35 silent(false) {} | 36 silent(false) {} |
| 36 | 37 |
| 37 RichNotificationData::RichNotificationData(const RichNotificationData& other) | 38 RichNotificationData::RichNotificationData(const RichNotificationData& other) |
| 38 : priority(other.priority), | 39 : priority(other.priority), |
| 40 is_web_notification(other.is_web_notification), |
| 39 never_timeout(other.never_timeout), | 41 never_timeout(other.never_timeout), |
| 40 timestamp(other.timestamp), | 42 timestamp(other.timestamp), |
| 41 context_message(other.context_message), | 43 context_message(other.context_message), |
| 42 image(other.image), | 44 image(other.image), |
| 43 small_image(other.small_image), | 45 small_image(other.small_image), |
| 44 items(other.items), | 46 items(other.items), |
| 45 progress(other.progress), | 47 progress(other.progress), |
| 46 buttons(other.buttons), | 48 buttons(other.buttons), |
| 47 should_make_spoken_feedback_for_popup_updates( | 49 should_make_spoken_feedback_for_popup_updates( |
| 48 other.should_make_spoken_feedback_for_popup_updates), | 50 other.should_make_spoken_feedback_for_popup_updates), |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 | 134 |
| 133 bool Notification::IsRead() const { | 135 bool Notification::IsRead() const { |
| 134 return is_read_ || optional_fields_.priority == MIN_PRIORITY; | 136 return is_read_ || optional_fields_.priority == MIN_PRIORITY; |
| 135 } | 137 } |
| 136 | 138 |
| 137 void Notification::CopyState(Notification* base) { | 139 void Notification::CopyState(Notification* base) { |
| 138 shown_as_popup_ = base->shown_as_popup(); | 140 shown_as_popup_ = base->shown_as_popup(); |
| 139 is_read_ = base->is_read_; | 141 is_read_ = base->is_read_; |
| 140 if (!delegate_.get()) | 142 if (!delegate_.get()) |
| 141 delegate_ = base->delegate(); | 143 delegate_ = base->delegate(); |
| 144 optional_fields_.is_web_notification = base->is_web_notification(); |
| 142 optional_fields_.never_timeout = base->never_timeout(); | 145 optional_fields_.never_timeout = base->never_timeout(); |
| 143 } | 146 } |
| 144 | 147 |
| 145 void Notification::SetButtonIcon(size_t index, const gfx::Image& icon) { | 148 void Notification::SetButtonIcon(size_t index, const gfx::Image& icon) { |
| 146 if (index >= optional_fields_.buttons.size()) | 149 if (index >= optional_fields_.buttons.size()) |
| 147 return; | 150 return; |
| 148 optional_fields_.buttons[index].icon = icon; | 151 optional_fields_.buttons[index].icon = icon; |
| 149 } | 152 } |
| 150 | 153 |
| 151 void Notification::SetSystemPriority() { | 154 void Notification::SetSystemPriority() { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 170 NOTIFICATION_TYPE_SIMPLE, notification_id, title, message, icon, | 173 NOTIFICATION_TYPE_SIMPLE, notification_id, title, message, icon, |
| 171 base::string16() /* display_source */, GURL(), | 174 base::string16() /* display_source */, GURL(), |
| 172 NotifierId(NotifierId::SYSTEM_COMPONENT, system_component_id), | 175 NotifierId(NotifierId::SYSTEM_COMPONENT, system_component_id), |
| 173 RichNotificationData(), | 176 RichNotificationData(), |
| 174 new HandleNotificationClickedDelegate(click_callback))); | 177 new HandleNotificationClickedDelegate(click_callback))); |
| 175 notification->SetSystemPriority(); | 178 notification->SetSystemPriority(); |
| 176 return notification.Pass(); | 179 return notification.Pass(); |
| 177 } | 180 } |
| 178 | 181 |
| 179 } // namespace message_center | 182 } // namespace message_center |
| OLD | NEW |