| 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 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 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 never_timeout(false), | 29 never_timeout(false), |
| 30 timestamp(base::Time::Now()), | 30 timestamp(base::Time::Now()), |
| 31 context_message(base::string16()), |
| 31 progress(0), | 32 progress(0), |
| 32 should_make_spoken_feedback_for_popup_updates(true), | 33 should_make_spoken_feedback_for_popup_updates(true), |
| 33 clickable(true), | 34 clickable(true), |
| 34 silent(false) {} | 35 silent(false) {} |
| 35 | 36 |
| 36 RichNotificationData::RichNotificationData(const RichNotificationData& other) | 37 RichNotificationData::RichNotificationData(const RichNotificationData& other) |
| 37 : priority(other.priority), | 38 : priority(other.priority), |
| 38 never_timeout(other.never_timeout), | 39 never_timeout(other.never_timeout), |
| 39 timestamp(other.timestamp), | 40 timestamp(other.timestamp), |
| 40 context_message(other.context_message), | 41 context_message(other.context_message), |
| 41 image(other.image), | 42 image(other.image), |
| 42 small_image(other.small_image), | 43 small_image(other.small_image), |
| 43 items(other.items), | 44 items(other.items), |
| 44 progress(other.progress), | 45 progress(other.progress), |
| 45 buttons(other.buttons), | 46 buttons(other.buttons), |
| 46 should_make_spoken_feedback_for_popup_updates( | 47 should_make_spoken_feedback_for_popup_updates( |
| 47 other.should_make_spoken_feedback_for_popup_updates), | 48 other.should_make_spoken_feedback_for_popup_updates), |
| 48 clickable(other.clickable), | 49 clickable(other.clickable), |
| 49 vibration_pattern(other.vibration_pattern), | 50 vibration_pattern(other.vibration_pattern), |
| 50 silent(other.silent) {} | 51 silent(other.silent) {} |
| 51 | 52 |
| 52 RichNotificationData::~RichNotificationData() {} | 53 RichNotificationData::~RichNotificationData() {} |
| 53 | 54 |
| 54 Notification::Notification(NotificationType type, | 55 Notification::Notification(NotificationType type, |
| 55 const std::string& id, | 56 const std::string& id, |
| 56 const base::string16& title, | 57 const base::string16& title, |
| 57 const base::string16& message, | 58 const base::string16& message, |
| 58 const gfx::Image& icon, | 59 const gfx::Image& icon, |
| 59 const base::string16& display_source, | 60 const base::string16& display_source, |
| 61 const GURL& origin_url, |
| 60 const NotifierId& notifier_id, | 62 const NotifierId& notifier_id, |
| 61 const RichNotificationData& optional_fields, | 63 const RichNotificationData& optional_fields, |
| 62 NotificationDelegate* delegate) | 64 NotificationDelegate* delegate) |
| 63 : type_(type), | 65 : type_(type), |
| 64 id_(id), | 66 id_(id), |
| 65 title_(title), | 67 title_(title), |
| 66 message_(message), | 68 message_(message), |
| 67 icon_(icon), | 69 icon_(icon), |
| 68 display_source_(display_source), | 70 display_source_(display_source), |
| 71 origin_url_(origin_url), |
| 69 notifier_id_(notifier_id), | 72 notifier_id_(notifier_id), |
| 70 serial_number_(g_next_serial_number_++), | 73 serial_number_(g_next_serial_number_++), |
| 71 optional_fields_(optional_fields), | 74 optional_fields_(optional_fields), |
| 72 shown_as_popup_(false), | 75 shown_as_popup_(false), |
| 73 is_read_(false), | 76 is_read_(false), |
| 74 delegate_(delegate) {} | 77 delegate_(delegate) {} |
| 75 | 78 |
| 76 Notification::Notification(const std::string& id, const Notification& other) | 79 Notification::Notification(const std::string& id, const Notification& other) |
| 77 : type_(other.type_), | 80 : type_(other.type_), |
| 78 id_(id), | 81 id_(id), |
| 79 title_(other.title_), | 82 title_(other.title_), |
| 80 message_(other.message_), | 83 message_(other.message_), |
| 81 icon_(other.icon_), | 84 icon_(other.icon_), |
| 82 display_source_(other.display_source_), | 85 display_source_(other.display_source_), |
| 86 origin_url_(other.origin_url_), |
| 83 notifier_id_(other.notifier_id_), | 87 notifier_id_(other.notifier_id_), |
| 84 serial_number_(other.serial_number_), | 88 serial_number_(other.serial_number_), |
| 85 optional_fields_(other.optional_fields_), | 89 optional_fields_(other.optional_fields_), |
| 86 shown_as_popup_(other.shown_as_popup_), | 90 shown_as_popup_(other.shown_as_popup_), |
| 87 is_read_(other.is_read_), | 91 is_read_(other.is_read_), |
| 88 delegate_(other.delegate_) { | 92 delegate_(other.delegate_) {} |
| 89 } | |
| 90 | 93 |
| 91 Notification::Notification(const Notification& other) | 94 Notification::Notification(const Notification& other) |
| 92 : type_(other.type_), | 95 : type_(other.type_), |
| 93 id_(other.id_), | 96 id_(other.id_), |
| 94 title_(other.title_), | 97 title_(other.title_), |
| 95 message_(other.message_), | 98 message_(other.message_), |
| 96 icon_(other.icon_), | 99 icon_(other.icon_), |
| 97 display_source_(other.display_source_), | 100 display_source_(other.display_source_), |
| 101 origin_url_(other.origin_url_), |
| 98 notifier_id_(other.notifier_id_), | 102 notifier_id_(other.notifier_id_), |
| 99 serial_number_(other.serial_number_), | 103 serial_number_(other.serial_number_), |
| 100 optional_fields_(other.optional_fields_), | 104 optional_fields_(other.optional_fields_), |
| 101 shown_as_popup_(other.shown_as_popup_), | 105 shown_as_popup_(other.shown_as_popup_), |
| 102 is_read_(other.is_read_), | 106 is_read_(other.is_read_), |
| 103 delegate_(other.delegate_) {} | 107 delegate_(other.delegate_) {} |
| 104 | 108 |
| 105 Notification& Notification::operator=(const Notification& other) { | 109 Notification& Notification::operator=(const Notification& other) { |
| 106 type_ = other.type_; | 110 type_ = other.type_; |
| 107 id_ = other.id_; | 111 id_ = other.id_; |
| 108 title_ = other.title_; | 112 title_ = other.title_; |
| 109 message_ = other.message_; | 113 message_ = other.message_; |
| 110 icon_ = other.icon_; | 114 icon_ = other.icon_; |
| 111 display_source_ = other.display_source_; | 115 display_source_ = other.display_source_; |
| 116 origin_url_ = other.origin_url_; |
| 112 notifier_id_ = other.notifier_id_; | 117 notifier_id_ = other.notifier_id_; |
| 113 serial_number_ = other.serial_number_; | 118 serial_number_ = other.serial_number_; |
| 114 optional_fields_ = other.optional_fields_; | 119 optional_fields_ = other.optional_fields_; |
| 115 shown_as_popup_ = other.shown_as_popup_; | 120 shown_as_popup_ = other.shown_as_popup_; |
| 116 is_read_ = other.is_read_; | 121 is_read_ = other.is_read_; |
| 117 delegate_ = other.delegate_; | 122 delegate_ = other.delegate_; |
| 118 | 123 |
| 119 return *this; | 124 return *this; |
| 120 } | 125 } |
| 121 | 126 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 145 } | 150 } |
| 146 | 151 |
| 147 // static | 152 // static |
| 148 scoped_ptr<Notification> Notification::CreateSystemNotification( | 153 scoped_ptr<Notification> Notification::CreateSystemNotification( |
| 149 const std::string& notification_id, | 154 const std::string& notification_id, |
| 150 const base::string16& title, | 155 const base::string16& title, |
| 151 const base::string16& message, | 156 const base::string16& message, |
| 152 const gfx::Image& icon, | 157 const gfx::Image& icon, |
| 153 const std::string& system_component_id, | 158 const std::string& system_component_id, |
| 154 const base::Closure& click_callback) { | 159 const base::Closure& click_callback) { |
| 155 scoped_ptr<Notification> notification( | 160 scoped_ptr<Notification> notification(new Notification( |
| 156 new Notification( | 161 NOTIFICATION_TYPE_SIMPLE, notification_id, title, message, icon, |
| 157 NOTIFICATION_TYPE_SIMPLE, | 162 base::string16() /* display_source */, GURL(), |
| 158 notification_id, | 163 NotifierId(NotifierId::SYSTEM_COMPONENT, system_component_id), |
| 159 title, | 164 RichNotificationData(), |
| 160 message, | 165 new HandleNotificationClickedDelegate(click_callback))); |
| 161 icon, | |
| 162 base::string16() /* display_source */, | |
| 163 NotifierId(NotifierId::SYSTEM_COMPONENT, system_component_id), | |
| 164 RichNotificationData(), | |
| 165 new HandleNotificationClickedDelegate(click_callback))); | |
| 166 notification->SetSystemPriority(); | 166 notification->SetSystemPriority(); |
| 167 return notification.Pass(); | 167 return notification.Pass(); |
| 168 } | 168 } |
| 169 | 169 |
| 170 } // namespace message_center | 170 } // namespace message_center |
| OLD | NEW |