| 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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 | 61 |
| 62 if (payload.data().length()) { | 62 if (payload.data().length()) { |
| 63 notification_data->data.assign(payload.data().begin(), | 63 notification_data->data.assign(payload.data().begin(), |
| 64 payload.data().end()); | 64 payload.data().end()); |
| 65 } | 65 } |
| 66 | 66 |
| 67 for (const auto& payload_action : payload.actions()) { | 67 for (const auto& payload_action : payload.actions()) { |
| 68 PlatformNotificationAction action; | 68 PlatformNotificationAction action; |
| 69 action.action = payload_action.action(); | 69 action.action = payload_action.action(); |
| 70 action.title = base::UTF8ToUTF16(payload_action.title()); | 70 action.title = base::UTF8ToUTF16(payload_action.title()); |
| 71 action.icon = GURL(payload_action.icon()); |
| 71 notification_data->actions.push_back(action); | 72 notification_data->actions.push_back(action); |
| 72 } | 73 } |
| 73 | 74 |
| 74 return true; | 75 return true; |
| 75 } | 76 } |
| 76 | 77 |
| 77 bool SerializeNotificationDatabaseData(const NotificationDatabaseData& input, | 78 bool SerializeNotificationDatabaseData(const NotificationDatabaseData& input, |
| 78 std::string* output) { | 79 std::string* output) { |
| 79 DCHECK(output); | 80 DCHECK(output); |
| 80 | 81 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 if (notification_data.data.size()) { | 115 if (notification_data.data.size()) { |
| 115 payload->set_data(¬ification_data.data.front(), | 116 payload->set_data(¬ification_data.data.front(), |
| 116 notification_data.data.size()); | 117 notification_data.data.size()); |
| 117 } | 118 } |
| 118 | 119 |
| 119 for (const PlatformNotificationAction& action : notification_data.actions) { | 120 for (const PlatformNotificationAction& action : notification_data.actions) { |
| 120 NotificationDatabaseDataProto::NotificationAction* payload_action = | 121 NotificationDatabaseDataProto::NotificationAction* payload_action = |
| 121 payload->add_actions(); | 122 payload->add_actions(); |
| 122 payload_action->set_action(action.action); | 123 payload_action->set_action(action.action); |
| 123 payload_action->set_title(base::UTF16ToUTF8(action.title)); | 124 payload_action->set_title(base::UTF16ToUTF8(action.title)); |
| 125 payload_action->set_icon(action.icon.spec()); |
| 124 } | 126 } |
| 125 | 127 |
| 126 NotificationDatabaseDataProto message; | 128 NotificationDatabaseDataProto message; |
| 127 message.set_notification_id(input.notification_id); | 129 message.set_notification_id(input.notification_id); |
| 128 message.set_origin(input.origin.spec()); | 130 message.set_origin(input.origin.spec()); |
| 129 message.set_service_worker_registration_id( | 131 message.set_service_worker_registration_id( |
| 130 input.service_worker_registration_id); | 132 input.service_worker_registration_id); |
| 131 message.set_allocated_notification_data(payload.release()); | 133 message.set_allocated_notification_data(payload.release()); |
| 132 | 134 |
| 133 return message.SerializeToString(output); | 135 return message.SerializeToString(output); |
| 134 } | 136 } |
| 135 | 137 |
| 136 } // namespace content | 138 } // namespace content |
| OLD | NEW |