| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/child/notifications/notification_data_conversions.h" | 5 #include "content/child/notifications/notification_data_conversions.h" |
| 6 | 6 |
| 7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
| 8 #include "third_party/WebKit/public/platform/WebString.h" | 8 #include "third_party/WebKit/public/platform/WebString.h" |
| 9 #include "third_party/WebKit/public/platform/WebURL.h" | 9 #include "third_party/WebKit/public/platform/WebURL.h" |
| 10 | 10 |
| 11 using blink::WebNotificationData; | 11 using blink::WebNotificationData; |
| 12 | 12 |
| 13 namespace content { | 13 namespace content { |
| 14 | 14 |
| 15 PlatformNotificationData ToPlatformNotificationData( | 15 PlatformNotificationData ToPlatformNotificationData( |
| 16 const WebNotificationData& web_data) { | 16 const WebNotificationData& web_data) { |
| 17 PlatformNotificationData platform_data; | 17 PlatformNotificationData platform_data; |
| 18 platform_data.title = web_data.title; | 18 platform_data.title = web_data.title; |
| 19 platform_data.direction = | 19 platform_data.direction = |
| 20 web_data.direction == WebNotificationData::DirectionLeftToRight | 20 web_data.direction == WebNotificationData::DirectionLeftToRight |
| 21 ? PlatformNotificationData::NotificationDirectionLeftToRight | 21 ? PlatformNotificationData::NotificationDirectionLeftToRight |
| 22 : PlatformNotificationData::NotificationDirectionRightToLeft; | 22 : PlatformNotificationData::NotificationDirectionRightToLeft; |
| 23 platform_data.lang = base::UTF16ToUTF8(web_data.lang); | 23 platform_data.lang = base::UTF16ToUTF8(web_data.lang); |
| 24 platform_data.body = web_data.body; | 24 platform_data.body = web_data.body; |
| 25 platform_data.tag = base::UTF16ToUTF8(web_data.tag); | 25 platform_data.tag = base::UTF16ToUTF8(web_data.tag); |
| 26 platform_data.icon = GURL(web_data.icon.string()); | 26 platform_data.icon = GURL(web_data.icon.string()); |
| 27 platform_data.vibration_pattern.assign(web_data.vibrate.begin(), |
| 28 web_data.vibrate.end()); |
| 27 platform_data.silent = web_data.silent; | 29 platform_data.silent = web_data.silent; |
| 28 platform_data.data.assign(web_data.data.begin(), web_data.data.end()); | 30 platform_data.data.assign(web_data.data.begin(), web_data.data.end()); |
| 29 | 31 |
| 30 return platform_data; | 32 return platform_data; |
| 31 } | 33 } |
| 32 | 34 |
| 33 WebNotificationData ToWebNotificationData( | 35 WebNotificationData ToWebNotificationData( |
| 34 const PlatformNotificationData& platform_data) { | 36 const PlatformNotificationData& platform_data) { |
| 35 WebNotificationData web_data; | 37 WebNotificationData web_data; |
| 36 web_data.title = platform_data.title; | 38 web_data.title = platform_data.title; |
| 37 web_data.direction = | 39 web_data.direction = |
| 38 platform_data.direction == | 40 platform_data.direction == |
| 39 PlatformNotificationData::NotificationDirectionLeftToRight | 41 PlatformNotificationData::NotificationDirectionLeftToRight |
| 40 ? WebNotificationData::DirectionLeftToRight | 42 ? WebNotificationData::DirectionLeftToRight |
| 41 : WebNotificationData::DirectionRightToLeft; | 43 : WebNotificationData::DirectionRightToLeft; |
| 42 web_data.lang = blink::WebString::fromUTF8(platform_data.lang); | 44 web_data.lang = blink::WebString::fromUTF8(platform_data.lang); |
| 43 web_data.body = platform_data.body; | 45 web_data.body = platform_data.body; |
| 44 web_data.tag = blink::WebString::fromUTF8(platform_data.tag); | 46 web_data.tag = blink::WebString::fromUTF8(platform_data.tag); |
| 45 web_data.icon = blink::WebURL(platform_data.icon); | 47 web_data.icon = blink::WebURL(platform_data.icon); |
| 48 web_data.vibrate = platform_data.vibration_pattern; |
| 46 web_data.silent = platform_data.silent; | 49 web_data.silent = platform_data.silent; |
| 47 web_data.data = platform_data.data; | 50 web_data.data = platform_data.data; |
| 48 | 51 |
| 49 return web_data; | 52 return web_data; |
| 50 } | 53 } |
| 51 | 54 |
| 52 } // namespace content | 55 } // namespace content |
| OLD | NEW |