| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/type_converters.h" | 5 #include "content/browser/notifications/type_converters.h" |
| 6 | 6 |
| 7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
| 8 #include "base/time/time.h" | 8 #include "base/time/time.h" |
| 9 #include "skia/public/type_converters.h" |
| 9 | 10 |
| 10 using blink::mojom::NotificationDirection; | 11 using blink::mojom::NotificationDirection; |
| 12 using blink::mojom::NotificationResourcesPtr; |
| 13 using content::NotificationResources; |
| 11 using content::PlatformNotificationData; | 14 using content::PlatformNotificationData; |
| 12 | 15 |
| 13 namespace mojo { | 16 namespace mojo { |
| 14 | 17 |
| 15 PlatformNotificationData | 18 PlatformNotificationData |
| 16 TypeConverter<PlatformNotificationData, blink::mojom::NotificationPtr>::Convert( | 19 TypeConverter<PlatformNotificationData, blink::mojom::NotificationPtr>::Convert( |
| 17 const blink::mojom::NotificationPtr& notification) { | 20 const blink::mojom::NotificationPtr& notification) { |
| 18 PlatformNotificationData notification_data; | 21 PlatformNotificationData notification_data; |
| 19 | 22 |
| 20 notification_data.title = base::UTF8ToUTF16(notification->title.get()); | 23 notification_data.title = base::UTF8ToUTF16(notification->title.get()); |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 action->icon = data_action.icon.spec(); | 132 action->icon = data_action.icon.spec(); |
| 130 if (!data_action.placeholder.is_null()) | 133 if (!data_action.placeholder.is_null()) |
| 131 action->placeholder = base::UTF16ToUTF8(data_action.placeholder.string()); | 134 action->placeholder = base::UTF16ToUTF8(data_action.placeholder.string()); |
| 132 | 135 |
| 133 notification->actions.push_back(std::move(action)); | 136 notification->actions.push_back(std::move(action)); |
| 134 } | 137 } |
| 135 | 138 |
| 136 return notification; | 139 return notification; |
| 137 } | 140 } |
| 138 | 141 |
| 142 NotificationResources |
| 143 TypeConverter<NotificationResources, NotificationResourcesPtr>::Convert( |
| 144 const NotificationResourcesPtr& notification_resources) { |
| 145 NotificationResources resources; |
| 146 resources.notification_icon = notification_resources->icon.To<SkBitmap>(); |
| 147 resources.badge = notification_resources->badge.To<SkBitmap>(); |
| 148 |
| 149 resources.action_icons.resize(notification_resources->action_icons.size()); |
| 150 for (size_t i = 0; i < notification_resources->action_icons.size(); ++i) { |
| 151 resources.action_icons[i] = |
| 152 notification_resources->action_icons[i].To<SkBitmap>(); |
| 153 } |
| 154 |
| 155 return resources; |
| 156 } |
| 157 |
| 139 } // namespace mojo | 158 } // namespace mojo |
| OLD | NEW |