| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "content/browser/notifications/notification_database_data_conversions.h
" | 5 #include "content/browser/notifications/notification_database_data_conversions.h
" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 | 10 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 PlatformNotificationData::DIRECTION_RIGHT_TO_LEFT; | 45 PlatformNotificationData::DIRECTION_RIGHT_TO_LEFT; |
| 46 break; | 46 break; |
| 47 case NotificationDatabaseDataProto::NotificationData::AUTO: | 47 case NotificationDatabaseDataProto::NotificationData::AUTO: |
| 48 notification_data->direction = PlatformNotificationData::DIRECTION_AUTO; | 48 notification_data->direction = PlatformNotificationData::DIRECTION_AUTO; |
| 49 break; | 49 break; |
| 50 } | 50 } |
| 51 | 51 |
| 52 notification_data->lang = payload.lang(); | 52 notification_data->lang = payload.lang(); |
| 53 notification_data->body = base::UTF8ToUTF16(payload.body()); | 53 notification_data->body = base::UTF8ToUTF16(payload.body()); |
| 54 notification_data->tag = payload.tag(); | 54 notification_data->tag = payload.tag(); |
| 55 notification_data->image = GURL(payload.image()); |
| 55 notification_data->icon = GURL(payload.icon()); | 56 notification_data->icon = GURL(payload.icon()); |
| 56 notification_data->badge = GURL(payload.badge()); | 57 notification_data->badge = GURL(payload.badge()); |
| 57 | 58 |
| 58 if (payload.vibration_pattern().size() > 0) { | 59 if (payload.vibration_pattern().size() > 0) { |
| 59 notification_data->vibration_pattern.assign( | 60 notification_data->vibration_pattern.assign( |
| 60 payload.vibration_pattern().begin(), payload.vibration_pattern().end()); | 61 payload.vibration_pattern().begin(), payload.vibration_pattern().end()); |
| 61 } | 62 } |
| 62 | 63 |
| 63 notification_data->timestamp = | 64 notification_data->timestamp = |
| 64 base::Time::FromInternalValue(payload.timestamp()); | 65 base::Time::FromInternalValue(payload.timestamp()); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 break; | 121 break; |
| 121 case PlatformNotificationData::DIRECTION_AUTO: | 122 case PlatformNotificationData::DIRECTION_AUTO: |
| 122 payload->set_direction( | 123 payload->set_direction( |
| 123 NotificationDatabaseDataProto::NotificationData::AUTO); | 124 NotificationDatabaseDataProto::NotificationData::AUTO); |
| 124 break; | 125 break; |
| 125 } | 126 } |
| 126 | 127 |
| 127 payload->set_lang(notification_data.lang); | 128 payload->set_lang(notification_data.lang); |
| 128 payload->set_body(base::UTF16ToUTF8(notification_data.body)); | 129 payload->set_body(base::UTF16ToUTF8(notification_data.body)); |
| 129 payload->set_tag(notification_data.tag); | 130 payload->set_tag(notification_data.tag); |
| 131 payload->set_image(notification_data.image.spec()); |
| 130 payload->set_icon(notification_data.icon.spec()); | 132 payload->set_icon(notification_data.icon.spec()); |
| 131 payload->set_badge(notification_data.badge.spec()); | 133 payload->set_badge(notification_data.badge.spec()); |
| 132 | 134 |
| 133 for (size_t i = 0; i < notification_data.vibration_pattern.size(); ++i) | 135 for (size_t i = 0; i < notification_data.vibration_pattern.size(); ++i) |
| 134 payload->add_vibration_pattern(notification_data.vibration_pattern[i]); | 136 payload->add_vibration_pattern(notification_data.vibration_pattern[i]); |
| 135 | 137 |
| 136 payload->set_timestamp(notification_data.timestamp.ToInternalValue()); | 138 payload->set_timestamp(notification_data.timestamp.ToInternalValue()); |
| 137 payload->set_renotify(notification_data.renotify); | 139 payload->set_renotify(notification_data.renotify); |
| 138 payload->set_silent(notification_data.silent); | 140 payload->set_silent(notification_data.silent); |
| 139 payload->set_require_interaction(notification_data.require_interaction); | 141 payload->set_require_interaction(notification_data.require_interaction); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 message.set_notification_id(input.notification_id); | 176 message.set_notification_id(input.notification_id); |
| 175 message.set_origin(input.origin.spec()); | 177 message.set_origin(input.origin.spec()); |
| 176 message.set_service_worker_registration_id( | 178 message.set_service_worker_registration_id( |
| 177 input.service_worker_registration_id); | 179 input.service_worker_registration_id); |
| 178 message.set_allocated_notification_data(payload.release()); | 180 message.set_allocated_notification_data(payload.release()); |
| 179 | 181 |
| 180 return message.SerializeToString(output); | 182 return message.SerializeToString(output); |
| 181 } | 183 } |
| 182 | 184 |
| 183 } // namespace content | 185 } // namespace content |
| OLD | NEW |