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