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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 | 54 |
55 if (payload.vibration_pattern().size() > 0) { | 55 if (payload.vibration_pattern().size() > 0) { |
56 notification_data->vibration_pattern.assign( | 56 notification_data->vibration_pattern.assign( |
57 payload.vibration_pattern().begin(), payload.vibration_pattern().end()); | 57 payload.vibration_pattern().begin(), payload.vibration_pattern().end()); |
58 } | 58 } |
59 | 59 |
60 notification_data->timestamp = | 60 notification_data->timestamp = |
61 base::Time::FromInternalValue(payload.timestamp()); | 61 base::Time::FromInternalValue(payload.timestamp()); |
| 62 notification_data->renotify = payload.renotify(); |
62 notification_data->silent = payload.silent(); | 63 notification_data->silent = payload.silent(); |
63 notification_data->require_interaction = payload.require_interaction(); | 64 notification_data->require_interaction = payload.require_interaction(); |
64 | 65 |
65 if (payload.data().length()) { | 66 if (payload.data().length()) { |
66 notification_data->data.assign(payload.data().begin(), | 67 notification_data->data.assign(payload.data().begin(), |
67 payload.data().end()); | 68 payload.data().end()); |
68 } | 69 } |
69 | 70 |
70 for (const auto& payload_action : payload.actions()) { | 71 for (const auto& payload_action : payload.actions()) { |
71 PlatformNotificationAction action; | 72 PlatformNotificationAction action; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 | 107 |
107 payload->set_lang(notification_data.lang); | 108 payload->set_lang(notification_data.lang); |
108 payload->set_body(base::UTF16ToUTF8(notification_data.body)); | 109 payload->set_body(base::UTF16ToUTF8(notification_data.body)); |
109 payload->set_tag(notification_data.tag); | 110 payload->set_tag(notification_data.tag); |
110 payload->set_icon(notification_data.icon.spec()); | 111 payload->set_icon(notification_data.icon.spec()); |
111 | 112 |
112 for (size_t i = 0; i < notification_data.vibration_pattern.size(); ++i) | 113 for (size_t i = 0; i < notification_data.vibration_pattern.size(); ++i) |
113 payload->add_vibration_pattern(notification_data.vibration_pattern[i]); | 114 payload->add_vibration_pattern(notification_data.vibration_pattern[i]); |
114 | 115 |
115 payload->set_timestamp(notification_data.timestamp.ToInternalValue()); | 116 payload->set_timestamp(notification_data.timestamp.ToInternalValue()); |
| 117 payload->set_renotify(notification_data.renotify); |
116 payload->set_silent(notification_data.silent); | 118 payload->set_silent(notification_data.silent); |
117 payload->set_require_interaction(notification_data.require_interaction); | 119 payload->set_require_interaction(notification_data.require_interaction); |
118 | 120 |
119 if (notification_data.data.size()) { | 121 if (notification_data.data.size()) { |
120 payload->set_data(¬ification_data.data.front(), | 122 payload->set_data(¬ification_data.data.front(), |
121 notification_data.data.size()); | 123 notification_data.data.size()); |
122 } | 124 } |
123 | 125 |
124 for (const PlatformNotificationAction& action : notification_data.actions) { | 126 for (const PlatformNotificationAction& action : notification_data.actions) { |
125 NotificationDatabaseDataProto::NotificationAction* payload_action = | 127 NotificationDatabaseDataProto::NotificationAction* payload_action = |
126 payload->add_actions(); | 128 payload->add_actions(); |
127 payload_action->set_action(action.action); | 129 payload_action->set_action(action.action); |
128 payload_action->set_title(base::UTF16ToUTF8(action.title)); | 130 payload_action->set_title(base::UTF16ToUTF8(action.title)); |
129 payload_action->set_icon(action.icon.spec()); | 131 payload_action->set_icon(action.icon.spec()); |
130 } | 132 } |
131 | 133 |
132 NotificationDatabaseDataProto message; | 134 NotificationDatabaseDataProto message; |
133 message.set_notification_id(input.notification_id); | 135 message.set_notification_id(input.notification_id); |
134 message.set_origin(input.origin.spec()); | 136 message.set_origin(input.origin.spec()); |
135 message.set_service_worker_registration_id( | 137 message.set_service_worker_registration_id( |
136 input.service_worker_registration_id); | 138 input.service_worker_registration_id); |
137 message.set_allocated_notification_data(payload.release()); | 139 message.set_allocated_notification_data(payload.release()); |
138 | 140 |
139 return message.SerializeToString(output); | 141 return message.SerializeToString(output); |
140 } | 142 } |
141 | 143 |
142 } // namespace content | 144 } // namespace content |
OLD | NEW |