| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/notifications/sync_notifier/synced_notification.h" | 5 #include "chrome/browser/notifications/sync_notifier/synced_notification.h" |
| 6 | 6 |
| 7 #include "sync/protocol/sync.pb.h" | 7 #include "sync/protocol/sync.pb.h" |
| 8 #include "sync/protocol/synced_notification_specifics.pb.h" | 8 #include "sync/protocol/synced_notification_specifics.pb.h" |
| 9 #include "ui/message_center/notification_types.h" |
| 9 | 10 |
| 10 namespace { | 11 namespace { |
| 11 const char kExtensionScheme[] = "chrome-extension://"; | 12 const char kExtensionScheme[] = "chrome-extension://"; |
| 12 } // namespace | 13 } // namespace |
| 13 | 14 |
| 14 namespace notifier { | 15 namespace notifier { |
| 15 | 16 |
| 16 COMPILE_ASSERT(static_cast<sync_pb::CoalescedSyncedNotification_ReadState>( | 17 COMPILE_ASSERT(static_cast<sync_pb::CoalescedSyncedNotification_ReadState>( |
| 17 SyncedNotification::kUnread) == | 18 SyncedNotification::kUnread) == |
| 18 sync_pb::CoalescedSyncedNotification_ReadState_UNREAD, | 19 sync_pb::CoalescedSyncedNotification_ReadState_UNREAD, |
| 19 local_enum_must_match_protobuf_enum); | 20 local_enum_must_match_protobuf_enum); |
| 20 COMPILE_ASSERT(static_cast<sync_pb::CoalescedSyncedNotification_ReadState>( | 21 COMPILE_ASSERT(static_cast<sync_pb::CoalescedSyncedNotification_ReadState>( |
| 21 SyncedNotification::kRead) == | 22 SyncedNotification::kRead) == |
| 22 sync_pb::CoalescedSyncedNotification_ReadState_READ, | 23 sync_pb::CoalescedSyncedNotification_ReadState_READ, |
| 23 local_enum_must_match_protobuf_enum); | 24 local_enum_must_match_protobuf_enum); |
| 24 COMPILE_ASSERT(static_cast<sync_pb::CoalescedSyncedNotification_ReadState>( | 25 COMPILE_ASSERT(static_cast<sync_pb::CoalescedSyncedNotification_ReadState>( |
| 25 SyncedNotification::kDismissed) == | 26 SyncedNotification::kDismissed) == |
| 26 sync_pb::CoalescedSyncedNotification_ReadState_DISMISSED, | 27 sync_pb::CoalescedSyncedNotification_ReadState_DISMISSED, |
| 27 local_enum_must_match_protobuf_enum); | 28 local_enum_must_match_protobuf_enum); |
| 28 | 29 |
| 29 SyncedNotification::SyncedNotification(const syncer::SyncData& sync_data) { | 30 SyncedNotification::SyncedNotification(const syncer::SyncData& sync_data) { |
| 30 Update(sync_data); | 31 Update(sync_data); |
| 31 } | 32 } |
| 32 | 33 |
| 33 SyncedNotification::~SyncedNotification() {} | 34 SyncedNotification::~SyncedNotification() {} |
| 34 | 35 |
| 35 void SyncedNotification::Update(const syncer::SyncData& sync_data) { | 36 void SyncedNotification::Update(const syncer::SyncData& sync_data) { |
| 37 // TODO(petewil): Let's add checking that the notification looks valid. |
| 36 specifics_.CopyFrom(sync_data.GetSpecifics().synced_notification()); | 38 specifics_.CopyFrom(sync_data.GetSpecifics().synced_notification()); |
| 37 } | 39 } |
| 38 | 40 |
| 39 sync_pb::EntitySpecifics SyncedNotification::GetEntitySpecifics() const { | 41 sync_pb::EntitySpecifics SyncedNotification::GetEntitySpecifics() const { |
| 40 sync_pb::EntitySpecifics entity_specifics; | 42 sync_pb::EntitySpecifics entity_specifics; |
| 41 entity_specifics.mutable_synced_notification()->CopyFrom(specifics_); | 43 entity_specifics.mutable_synced_notification()->CopyFrom(specifics_); |
| 42 return entity_specifics; | 44 return entity_specifics; |
| 43 } | 45 } |
| 44 | 46 |
| 45 std::string SyncedNotification::title() const { | |
| 46 return ExtractTitle(); | |
| 47 } | |
| 48 | |
| 49 std::string SyncedNotification::heading() const { | |
| 50 return ExtractHeading(); | |
| 51 } | |
| 52 | |
| 53 std::string SyncedNotification::description() const { | |
| 54 return ExtractDescription(); | |
| 55 } | |
| 56 | |
| 57 std::string SyncedNotification::app_id() const { | |
| 58 return ExtractAppId(); | |
| 59 } | |
| 60 | |
| 61 std::string SyncedNotification::key() const { | |
| 62 return ExtractKey(); | |
| 63 } | |
| 64 | |
| 65 GURL SyncedNotification::origin_url() const { | |
| 66 return ExtractOriginUrl(); | |
| 67 } | |
| 68 | |
| 69 GURL SyncedNotification::app_icon_url() const { | |
| 70 return ExtractAppIconUrl(); | |
| 71 } | |
| 72 | |
| 73 GURL SyncedNotification::image_url() const { | |
| 74 return ExtractImageUrl(); | |
| 75 } | |
| 76 | |
| 77 std::string SyncedNotification::first_external_id() const { | |
| 78 return ExtractFirstExternalId(); | |
| 79 } | |
| 80 | |
| 81 std::string SyncedNotification::notification_id() const { | |
| 82 return ExtractNotificationId(); | |
| 83 } | |
| 84 | |
| 85 std::string SyncedNotification::text() const { | |
| 86 return ExtractText(); | |
| 87 } | |
| 88 | |
| 89 SyncedNotification::ReadState SyncedNotification::read_state() const { | |
| 90 return ExtractReadState(); | |
| 91 } | |
| 92 | |
| 93 // TODO(petewil): Consider the timestamp too once it gets added to the protobuf. | 47 // TODO(petewil): Consider the timestamp too once it gets added to the protobuf. |
| 48 // TODO: add more fields in here |
| 94 bool SyncedNotification::EqualsIgnoringReadState( | 49 bool SyncedNotification::EqualsIgnoringReadState( |
| 95 const SyncedNotification& other) const { | 50 const SyncedNotification& other) const { |
| 96 return (title() == other.title() && | 51 return (GetTitle() == other.GetTitle() && |
| 97 app_id() == other.app_id() && | 52 GetAppId() == other.GetAppId() && |
| 98 key() == other.key() && | 53 GetKey() == other.GetKey() && |
| 99 text() == other.text() && | 54 GetText() == other.GetText() && |
| 100 origin_url() == other.origin_url() && | 55 GetOriginUrl() == other.GetOriginUrl() && |
| 101 app_icon_url() == other.app_icon_url() && | 56 GetAppIconUrl() == other.GetAppIconUrl() && |
| 102 image_url() == other.image_url() ); | 57 GetImageUrl() == other.GetImageUrl() ); |
| 103 } | |
| 104 | |
| 105 bool SyncedNotification::IdMatches(const SyncedNotification& other) const { | |
| 106 // Two notifications have the same ID if the <appId/coalescingKey> pair | |
| 107 // matches. | |
| 108 return (notification_id() == other.notification_id()); | |
| 109 } | 58 } |
| 110 | 59 |
| 111 // Set the read state on the notification, returns true for success. | 60 // Set the read state on the notification, returns true for success. |
| 112 void SyncedNotification::SetReadState(const ReadState& read_state) { | 61 void SyncedNotification::SetReadState(const ReadState& read_state) { |
| 113 | 62 |
| 114 // convert the read state to the protobuf type for read state | 63 // convert the read state to the protobuf type for read state |
| 115 if (kDismissed == read_state) | 64 if (kDismissed == read_state) |
| 116 specifics_.mutable_coalesced_notification()->set_read_state( | 65 specifics_.mutable_coalesced_notification()->set_read_state( |
| 117 sync_pb::CoalescedSyncedNotification_ReadState_DISMISSED); | 66 sync_pb::CoalescedSyncedNotification_ReadState_DISMISSED); |
| 118 else if (kUnread == read_state) | 67 else if (kUnread == read_state) |
| 119 specifics_.mutable_coalesced_notification()->set_read_state( | 68 specifics_.mutable_coalesced_notification()->set_read_state( |
| 120 sync_pb::CoalescedSyncedNotification_ReadState_UNREAD); | 69 sync_pb::CoalescedSyncedNotification_ReadState_UNREAD); |
| 121 else if (kRead == read_state) | 70 else if (kRead == read_state) |
| 122 specifics_.mutable_coalesced_notification()->set_read_state( | 71 specifics_.mutable_coalesced_notification()->set_read_state( |
| 123 sync_pb::CoalescedSyncedNotification_ReadState_READ); | 72 sync_pb::CoalescedSyncedNotification_ReadState_READ); |
| 124 else | 73 else |
| 125 NOTREACHED(); | 74 NOTREACHED(); |
| 126 } | 75 } |
| 127 | 76 |
| 128 void SyncedNotification::NotificationHasBeenRead() { | |
| 129 SetReadState(kRead); | |
| 130 } | |
| 131 | |
| 132 void SyncedNotification::NotificationHasBeenDismissed() { | 77 void SyncedNotification::NotificationHasBeenDismissed() { |
| 133 SetReadState(kDismissed); | 78 SetReadState(kDismissed); |
| 134 } | 79 } |
| 135 | 80 |
| 136 std::string SyncedNotification::ExtractFirstExternalId() const { | 81 std::string SyncedNotification::GetTitle() const { |
| 137 if (!specifics_.has_coalesced_notification() || | |
| 138 specifics_.coalesced_notification().notification_size() < 1 || | |
| 139 !specifics_.coalesced_notification().notification(0).has_external_id()) | |
| 140 return std::string(); | |
| 141 | |
| 142 return specifics_.coalesced_notification().notification(0).external_id(); | |
| 143 } | |
| 144 | |
| 145 std::string SyncedNotification::ExtractTitle() const { | |
| 146 if (!specifics_.coalesced_notification().render_info().expanded_info(). | 82 if (!specifics_.coalesced_notification().render_info().expanded_info(). |
| 147 simple_expanded_layout().has_title()) | 83 simple_expanded_layout().has_title()) |
| 148 return ""; | 84 return std::string(); |
| 149 | 85 |
| 150 return specifics_.coalesced_notification().render_info().expanded_info(). | 86 return specifics_.coalesced_notification().render_info().expanded_info(). |
| 151 simple_expanded_layout().title(); | 87 simple_expanded_layout().title(); |
| 152 } | 88 } |
| 153 | 89 |
| 154 std::string SyncedNotification::ExtractHeading() const { | 90 std::string SyncedNotification::GetHeading() const { |
| 155 if (!specifics_.coalesced_notification().render_info().collapsed_info(). | 91 if (!specifics_.coalesced_notification().render_info().collapsed_info(). |
| 156 simple_collapsed_layout().has_heading()) | 92 simple_collapsed_layout().has_heading()) |
| 157 return ""; | 93 return std::string(); |
| 158 | 94 |
| 159 return specifics_.coalesced_notification().render_info().collapsed_info(). | 95 return specifics_.coalesced_notification().render_info().collapsed_info(). |
| 160 simple_collapsed_layout().heading(); | 96 simple_collapsed_layout().heading(); |
| 161 } | 97 } |
| 162 | 98 |
| 163 std::string SyncedNotification::ExtractDescription() const { | 99 std::string SyncedNotification::GetDescription() const { |
| 164 if (!specifics_.coalesced_notification().render_info().collapsed_info(). | 100 if (!specifics_.coalesced_notification().render_info().collapsed_info(). |
| 165 simple_collapsed_layout().has_description()) | 101 simple_collapsed_layout().has_description()) |
| 166 return ""; | 102 return std::string(); |
| 167 | 103 |
| 168 return specifics_.coalesced_notification().render_info().collapsed_info(). | 104 return specifics_.coalesced_notification().render_info().collapsed_info(). |
| 169 simple_collapsed_layout().description(); | 105 simple_collapsed_layout().description(); |
| 170 } | 106 } |
| 171 | 107 |
| 172 std::string SyncedNotification::ExtractAppId() const { | 108 std::string SyncedNotification::GetAppId() const { |
| 173 if (!specifics_.coalesced_notification().has_app_id()) | 109 if (!specifics_.coalesced_notification().has_app_id()) |
| 174 return ""; | 110 return std::string(); |
| 175 return specifics_.coalesced_notification().app_id(); | 111 return specifics_.coalesced_notification().app_id(); |
| 176 } | 112 } |
| 177 | 113 |
| 178 std::string SyncedNotification::ExtractKey() const { | 114 std::string SyncedNotification::GetKey() const { |
| 179 if (!specifics_.coalesced_notification().has_key()) | 115 if (!specifics_.coalesced_notification().has_key()) |
| 180 return ""; | 116 return std::string(); |
| 181 return specifics_.coalesced_notification().key(); | 117 return specifics_.coalesced_notification().key(); |
| 182 } | 118 } |
| 183 | 119 |
| 184 GURL SyncedNotification::ExtractOriginUrl() const { | 120 GURL SyncedNotification::GetOriginUrl() const { |
| 185 std::string origin_url(kExtensionScheme); | 121 std::string origin_url(kExtensionScheme); |
| 186 origin_url += app_id(); | 122 origin_url += GetAppId(); |
| 187 return GURL(origin_url); | 123 return GURL(origin_url); |
| 188 } | 124 } |
| 189 | 125 |
| 190 GURL SyncedNotification::ExtractAppIconUrl() const { | 126 // TODO(petewil): This only returns the first icon. We should make all the |
| 127 // icons available. |
| 128 GURL SyncedNotification::GetAppIconUrl() const { |
| 191 if (specifics_.coalesced_notification().render_info().expanded_info(). | 129 if (specifics_.coalesced_notification().render_info().expanded_info(). |
| 192 collapsed_info_size() == 0) | 130 collapsed_info_size() == 0) |
| 193 return GURL(); | 131 return GURL(); |
| 194 | 132 |
| 195 if (!specifics_.coalesced_notification().render_info().expanded_info(). | 133 if (!specifics_.coalesced_notification().render_info().expanded_info(). |
| 196 collapsed_info(0).simple_collapsed_layout().has_app_icon()) | 134 collapsed_info(0).simple_collapsed_layout().has_app_icon()) |
| 197 return GURL(); | 135 return GURL(); |
| 198 | 136 |
| 199 return GURL(specifics_.coalesced_notification().render_info(). | 137 return GURL(specifics_.coalesced_notification().render_info(). |
| 200 expanded_info().collapsed_info(0).simple_collapsed_layout(). | 138 expanded_info().collapsed_info(0).simple_collapsed_layout(). |
| 201 app_icon().url()); | 139 app_icon().url()); |
| 202 } | 140 } |
| 203 | 141 |
| 204 // TODO(petewil): This currenly only handles the first image from the first | 142 // TODO(petewil): This currenly only handles the first image from the first |
| 205 // collapsed item, someday return all images. | 143 // collapsed item, someday return all images. |
| 206 GURL SyncedNotification::ExtractImageUrl() const { | 144 GURL SyncedNotification::GetImageUrl() const { |
| 207 if (specifics_.coalesced_notification().render_info().expanded_info(). | 145 if (specifics_.coalesced_notification().render_info().expanded_info(). |
| 208 simple_expanded_layout().media_size() == 0) | 146 simple_expanded_layout().media_size() == 0) |
| 209 return GURL(); | 147 return GURL(); |
| 210 | 148 |
| 211 if (!specifics_.coalesced_notification().render_info().expanded_info(). | 149 if (!specifics_.coalesced_notification().render_info().expanded_info(). |
| 212 simple_expanded_layout().media(0).image().has_url()) | 150 simple_expanded_layout().media(0).image().has_url()) |
| 213 return GURL(); | 151 return GURL(); |
| 214 | 152 |
| 215 return GURL(specifics_.coalesced_notification().render_info(). | 153 return GURL(specifics_.coalesced_notification().render_info(). |
| 216 expanded_info().simple_expanded_layout().media(0).image().url()); | 154 expanded_info().simple_expanded_layout().media(0).image().url()); |
| 217 } | 155 } |
| 218 | 156 |
| 219 std::string SyncedNotification::ExtractText() const { | 157 std::string SyncedNotification::GetText() const { |
| 220 if (!specifics_.coalesced_notification().render_info().expanded_info(). | 158 if (!specifics_.coalesced_notification().render_info().expanded_info(). |
| 221 simple_expanded_layout().has_text()) | 159 simple_expanded_layout().has_text()) |
| 222 return ""; | 160 return std::string(); |
| 223 | 161 |
| 224 return specifics_.coalesced_notification().render_info().expanded_info(). | 162 return specifics_.coalesced_notification().render_info().expanded_info(). |
| 225 simple_expanded_layout().text(); | 163 simple_expanded_layout().text(); |
| 226 } | 164 } |
| 227 | 165 |
| 228 SyncedNotification::ReadState SyncedNotification::ExtractReadState() const { | 166 SyncedNotification::ReadState SyncedNotification::GetReadState() const { |
| 229 DCHECK(specifics_.coalesced_notification().has_read_state()); | 167 DCHECK(specifics_.coalesced_notification().has_read_state()); |
| 230 | 168 |
| 231 sync_pb::CoalescedSyncedNotification_ReadState found_read_state = | 169 sync_pb::CoalescedSyncedNotification_ReadState found_read_state = |
| 232 specifics_.coalesced_notification().read_state(); | 170 specifics_.coalesced_notification().read_state(); |
| 233 | 171 |
| 234 if (found_read_state == | 172 if (found_read_state == |
| 235 sync_pb::CoalescedSyncedNotification_ReadState_DISMISSED) { | 173 sync_pb::CoalescedSyncedNotification_ReadState_DISMISSED) { |
| 236 return kDismissed; | 174 return kDismissed; |
| 237 } else if (found_read_state == | 175 } else if (found_read_state == |
| 238 sync_pb::CoalescedSyncedNotification_ReadState_UNREAD) { | 176 sync_pb::CoalescedSyncedNotification_ReadState_UNREAD) { |
| 239 return kUnread; | 177 return kUnread; |
| 240 } else if (found_read_state == | 178 } else if (found_read_state == |
| 241 sync_pb::CoalescedSyncedNotification_ReadState_READ) { | 179 sync_pb::CoalescedSyncedNotification_ReadState_READ) { |
| 242 return kRead; | 180 return kRead; |
| 243 } else { | 181 } else { |
| 244 NOTREACHED(); | 182 NOTREACHED(); |
| 245 return static_cast<SyncedNotification::ReadState>(found_read_state); | 183 return static_cast<SyncedNotification::ReadState>(found_read_state); |
| 246 } | 184 } |
| 247 } | 185 } |
| 248 | 186 |
| 249 std::string SyncedNotification::ExtractNotificationId() const { | 187 // Time in milliseconds since the unix epoch, or 0 if not available. |
| 250 return key(); | 188 uint64 SyncedNotification::GetCreationTime() const { |
| 189 if (!specifics_.coalesced_notification().has_creation_time_msec()) |
| 190 return 0; |
| 191 |
| 192 return specifics_.coalesced_notification().creation_time_msec(); |
| 193 } |
| 194 |
| 195 int SyncedNotification::GetPriority() const { |
| 196 if (!specifics_.coalesced_notification().has_priority()) |
| 197 return kUndefinedPriority; |
| 198 int protobuf_priority = specifics_.coalesced_notification().priority(); |
| 199 |
| 200 #if defined(ENABLE_MESSAGE_CENTER) |
| 201 // Convert the prioroty to the scheme used by the notification center. |
| 202 if (protobuf_priority == |
| 203 sync_pb::CoalescedSyncedNotification_Priority_LOW) { |
| 204 return message_center::LOW_PRIORITY; |
| 205 } else if (protobuf_priority == |
| 206 sync_pb::CoalescedSyncedNotification_Priority_STANDARD) { |
| 207 return message_center::DEFAULT_PRIORITY; |
| 208 } else if (protobuf_priority == |
| 209 sync_pb::CoalescedSyncedNotification_Priority_HIGH) { |
| 210 return message_center::HIGH_PRIORITY; |
| 211 } else { |
| 212 // Complain if this is a new priority we have not seen before. |
| 213 DCHECK(protobuf_priority < |
| 214 sync_pb::CoalescedSyncedNotification_Priority_LOW || |
| 215 sync_pb::CoalescedSyncedNotification_Priority_HIGH < |
| 216 protobuf_priority); |
| 217 return kUndefinedPriority; |
| 218 } |
| 219 |
| 220 #else // ENABLE_MESSAGE_CENTER |
| 221 return protobuf_priority; |
| 222 |
| 223 #endif // ENABLE_MESSAGE_CENTER |
| 224 } |
| 225 |
| 226 int SyncedNotification::GetNotificationCount() const { |
| 227 return specifics_.coalesced_notification().render_info(). |
| 228 expanded_info().collapsed_info_size(); |
| 229 } |
| 230 |
| 231 int SyncedNotification::GetButtonCount() const { |
| 232 return specifics_.coalesced_notification().render_info().collapsed_info(). |
| 233 target_size(); |
| 234 } |
| 235 |
| 236 std::string SyncedNotification::GetDefaultDestinationTitle() const { |
| 237 if (!specifics_.coalesced_notification().render_info().collapsed_info(). |
| 238 default_destination().icon().has_alt_text()) { |
| 239 return std::string(); |
| 240 } |
| 241 return specifics_.coalesced_notification().render_info().collapsed_info(). |
| 242 default_destination().icon().alt_text(); |
| 243 } |
| 244 |
| 245 std::string SyncedNotification::GetDefaultDestinationIconUrl() const { |
| 246 if (!specifics_.coalesced_notification().render_info().collapsed_info(). |
| 247 default_destination().icon().has_url()) { |
| 248 return std::string(); |
| 249 } |
| 250 return specifics_.coalesced_notification().render_info().collapsed_info(). |
| 251 default_destination().icon().url(); |
| 252 } |
| 253 |
| 254 std::string SyncedNotification::GetDefaultDestinationUrl() const { |
| 255 if (!specifics_.coalesced_notification().render_info().collapsed_info(). |
| 256 default_destination().has_url()) { |
| 257 return std::string(); |
| 258 } |
| 259 return specifics_.coalesced_notification().render_info().collapsed_info(). |
| 260 default_destination().url(); |
| 261 } |
| 262 |
| 263 std::string SyncedNotification::GetButtonOneTitle() const { |
| 264 // Must ensure that we have a target before trying to access it. |
| 265 if (GetButtonCount() < 1) |
| 266 return std::string(); |
| 267 if (!specifics_.coalesced_notification().render_info().collapsed_info(). |
| 268 target(0).action().icon().has_alt_text()) { |
| 269 return std::string(); |
| 270 } |
| 271 return specifics_.coalesced_notification().render_info().collapsed_info(). |
| 272 target(0).action().icon().alt_text(); |
| 273 } |
| 274 |
| 275 std::string SyncedNotification::GetButtonOneIconUrl() const { |
| 276 // Must ensure that we have a target before trying to access it. |
| 277 if (GetButtonCount() < 1) |
| 278 return std::string(); |
| 279 if (!specifics_.coalesced_notification().render_info().collapsed_info(). |
| 280 target(0).action().icon().has_url()) { |
| 281 return std::string(); |
| 282 } |
| 283 return specifics_.coalesced_notification().render_info().collapsed_info(). |
| 284 target(0).action().icon().url(); |
| 285 } |
| 286 |
| 287 std::string SyncedNotification::GetButtonOneUrl() const { |
| 288 // Must ensure that we have a target before trying to access it. |
| 289 if (GetButtonCount() < 1) |
| 290 return std::string(); |
| 291 if (!specifics_.coalesced_notification().render_info().collapsed_info(). |
| 292 target(0).action().has_url()) { |
| 293 return std::string(); |
| 294 } |
| 295 return specifics_.coalesced_notification().render_info().collapsed_info(). |
| 296 target(0).action().url(); |
| 297 } |
| 298 |
| 299 std::string SyncedNotification::GetButtonTwoTitle() const { |
| 300 // Must ensure that we have a target before trying to access it. |
| 301 if (GetButtonCount() < 2) |
| 302 return std::string(); |
| 303 if (!specifics_.coalesced_notification().render_info().collapsed_info(). |
| 304 target(1).action().icon().has_alt_text()) { |
| 305 return std::string(); |
| 306 } |
| 307 return specifics_.coalesced_notification().render_info().collapsed_info(). |
| 308 target(1).action().icon().alt_text(); |
| 309 } |
| 310 |
| 311 std::string SyncedNotification::GetButtonTwoIconUrl() const { |
| 312 // Must ensure that we have a target before trying to access it. |
| 313 if (GetButtonCount() < 2) |
| 314 return std::string(); |
| 315 if (!specifics_.coalesced_notification().render_info().collapsed_info(). |
| 316 target(1).action().icon().has_url()) { |
| 317 return std::string(); |
| 318 } |
| 319 return specifics_.coalesced_notification().render_info().collapsed_info(). |
| 320 target(1).action().icon().url(); |
| 321 } |
| 322 |
| 323 std::string SyncedNotification::GetButtonTwoUrl() const { |
| 324 // Must ensure that we have a target before trying to access it. |
| 325 if (GetButtonCount() < 2) |
| 326 return std::string(); |
| 327 if (!specifics_.coalesced_notification().render_info().collapsed_info(). |
| 328 target(1).action().has_url()) { |
| 329 return std::string(); |
| 330 } |
| 331 return specifics_.coalesced_notification().render_info().collapsed_info(). |
| 332 target(1).action().url(); |
| 333 } |
| 334 |
| 335 std::string SyncedNotification::GetContainedNotificationTitle( |
| 336 int index) const { |
| 337 if (specifics_.coalesced_notification().render_info().expanded_info(). |
| 338 collapsed_info_size() < index + 1) |
| 339 return std::string(); |
| 340 |
| 341 return specifics_.coalesced_notification().render_info().expanded_info(). |
| 342 collapsed_info(index).simple_collapsed_layout().heading(); |
| 343 } |
| 344 |
| 345 std::string SyncedNotification::GetContainedNotificationMessage( |
| 346 int index) const { |
| 347 if (specifics_.coalesced_notification().render_info().expanded_info(). |
| 348 collapsed_info_size() < index + 1) |
| 349 return std::string(); |
| 350 |
| 351 return specifics_.coalesced_notification().render_info().expanded_info(). |
| 352 collapsed_info(index).simple_collapsed_layout().description(); |
| 251 } | 353 } |
| 252 | 354 |
| 253 } // namespace notifier | 355 } // namespace notifier |
| OLD | NEW |