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 "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 break; | 44 break; |
45 case NotificationDatabaseDataProto::NotificationData::AUTO: | 45 case NotificationDatabaseDataProto::NotificationData::AUTO: |
46 notification_data->direction = PlatformNotificationData::DIRECTION_AUTO; | 46 notification_data->direction = PlatformNotificationData::DIRECTION_AUTO; |
47 break; | 47 break; |
48 } | 48 } |
49 | 49 |
50 notification_data->lang = payload.lang(); | 50 notification_data->lang = payload.lang(); |
51 notification_data->body = base::UTF8ToUTF16(payload.body()); | 51 notification_data->body = base::UTF8ToUTF16(payload.body()); |
52 notification_data->tag = payload.tag(); | 52 notification_data->tag = payload.tag(); |
53 notification_data->icon = GURL(payload.icon()); | 53 notification_data->icon = GURL(payload.icon()); |
| 54 notification_data->badge = GURL(payload.badge()); |
54 | 55 |
55 if (payload.vibration_pattern().size() > 0) { | 56 if (payload.vibration_pattern().size() > 0) { |
56 notification_data->vibration_pattern.assign( | 57 notification_data->vibration_pattern.assign( |
57 payload.vibration_pattern().begin(), payload.vibration_pattern().end()); | 58 payload.vibration_pattern().begin(), payload.vibration_pattern().end()); |
58 } | 59 } |
59 | 60 |
60 notification_data->timestamp = | 61 notification_data->timestamp = |
61 base::Time::FromInternalValue(payload.timestamp()); | 62 base::Time::FromInternalValue(payload.timestamp()); |
62 notification_data->renotify = payload.renotify(); | 63 notification_data->renotify = payload.renotify(); |
63 notification_data->silent = payload.silent(); | 64 notification_data->silent = payload.silent(); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 case PlatformNotificationData::DIRECTION_AUTO: | 103 case PlatformNotificationData::DIRECTION_AUTO: |
103 payload->set_direction( | 104 payload->set_direction( |
104 NotificationDatabaseDataProto::NotificationData::AUTO); | 105 NotificationDatabaseDataProto::NotificationData::AUTO); |
105 break; | 106 break; |
106 } | 107 } |
107 | 108 |
108 payload->set_lang(notification_data.lang); | 109 payload->set_lang(notification_data.lang); |
109 payload->set_body(base::UTF16ToUTF8(notification_data.body)); | 110 payload->set_body(base::UTF16ToUTF8(notification_data.body)); |
110 payload->set_tag(notification_data.tag); | 111 payload->set_tag(notification_data.tag); |
111 payload->set_icon(notification_data.icon.spec()); | 112 payload->set_icon(notification_data.icon.spec()); |
| 113 payload->set_badge(notification_data.badge.spec()); |
112 | 114 |
113 for (size_t i = 0; i < notification_data.vibration_pattern.size(); ++i) | 115 for (size_t i = 0; i < notification_data.vibration_pattern.size(); ++i) |
114 payload->add_vibration_pattern(notification_data.vibration_pattern[i]); | 116 payload->add_vibration_pattern(notification_data.vibration_pattern[i]); |
115 | 117 |
116 payload->set_timestamp(notification_data.timestamp.ToInternalValue()); | 118 payload->set_timestamp(notification_data.timestamp.ToInternalValue()); |
117 payload->set_renotify(notification_data.renotify); | 119 payload->set_renotify(notification_data.renotify); |
118 payload->set_silent(notification_data.silent); | 120 payload->set_silent(notification_data.silent); |
119 payload->set_require_interaction(notification_data.require_interaction); | 121 payload->set_require_interaction(notification_data.require_interaction); |
120 | 122 |
121 if (notification_data.data.size()) { | 123 if (notification_data.data.size()) { |
(...skipping 13 matching lines...) Expand all Loading... |
135 message.set_notification_id(input.notification_id); | 137 message.set_notification_id(input.notification_id); |
136 message.set_origin(input.origin.spec()); | 138 message.set_origin(input.origin.spec()); |
137 message.set_service_worker_registration_id( | 139 message.set_service_worker_registration_id( |
138 input.service_worker_registration_id); | 140 input.service_worker_registration_id); |
139 message.set_allocated_notification_data(payload.release()); | 141 message.set_allocated_notification_data(payload.release()); |
140 | 142 |
141 return message.SerializeToString(output); | 143 return message.SerializeToString(output); |
142 } | 144 } |
143 | 145 |
144 } // namespace content | 146 } // namespace content |
OLD | NEW |