Chromium Code Reviews| Index: content/browser/notifications/notification_database_data_conversions.cc |
| diff --git a/content/browser/notifications/notification_database_data_conversions.cc b/content/browser/notifications/notification_database_data_conversions.cc |
| index 11cdd48705b055d8b02b0b6099ceb907562e4936..5131677c04aef85d4032492c6be79ab8bc9dd2c2 100644 |
| --- a/content/browser/notifications/notification_database_data_conversions.cc |
| +++ b/content/browser/notifications/notification_database_data_conversions.cc |
| @@ -73,9 +73,27 @@ bool DeserializeNotificationDatabaseData(const std::string& input, |
| for (const auto& payload_action : payload.actions()) { |
| PlatformNotificationAction action; |
| + |
| + switch (payload_action.type()) { |
| + case NotificationDatabaseDataProto::NotificationAction::BUTTON: |
| + action.type = PLATFORM_NOTIFICATION_ACTION_TYPE_BUTTON; |
| + break; |
| + case NotificationDatabaseDataProto::NotificationAction::TEXT: |
| + action.type = PLATFORM_NOTIFICATION_ACTION_TYPE_TEXT; |
| + break; |
| + default: |
| + NOTREACHED(); |
| + } |
| + |
| action.action = payload_action.action(); |
| action.title = base::UTF8ToUTF16(payload_action.title()); |
| action.icon = GURL(payload_action.icon()); |
| + if (payload_action.has_placeholder()) { |
| + action.placeholder = base::NullableString16( |
| + base::UTF8ToUTF16(payload_action.placeholder()), false); |
| + } else { |
| + action.placeholder = base::NullableString16(); |
|
Peter Beverloo
2016/04/06 17:22:00
nit: this should be done implicitly by the constru
Nina
2016/04/07 10:59:09
Indeed! Removed.
|
| + } |
| notification_data->actions.push_back(action); |
| } |
| @@ -130,9 +148,28 @@ bool SerializeNotificationDatabaseData(const NotificationDatabaseData& input, |
| for (const PlatformNotificationAction& action : notification_data.actions) { |
| NotificationDatabaseDataProto::NotificationAction* payload_action = |
| payload->add_actions(); |
| + |
| + switch (action.type) { |
| + case PLATFORM_NOTIFICATION_ACTION_TYPE_BUTTON: |
| + payload_action->set_type( |
| + NotificationDatabaseDataProto::NotificationAction::BUTTON); |
| + break; |
| + case PLATFORM_NOTIFICATION_ACTION_TYPE_TEXT: |
| + payload_action->set_type( |
| + NotificationDatabaseDataProto::NotificationAction::TEXT); |
| + break; |
| + default: |
| + NOTREACHED() << "Unknown action type: " << action.type; |
| + } |
| + |
| payload_action->set_action(action.action); |
| payload_action->set_title(base::UTF16ToUTF8(action.title)); |
| payload_action->set_icon(action.icon.spec()); |
| + |
| + if (!action.placeholder.is_null()) { |
| + payload_action->set_placeholder( |
| + base::UTF16ToUTF8(action.placeholder.string())); |
| + } |
| } |
| NotificationDatabaseDataProto message; |