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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "base/time/time.h" |
10 #include "third_party/WebKit/public/platform/URLConversion.h" | 11 #include "third_party/WebKit/public/platform/URLConversion.h" |
11 #include "third_party/WebKit/public/platform/WebString.h" | 12 #include "third_party/WebKit/public/platform/WebString.h" |
12 #include "third_party/WebKit/public/platform/WebURL.h" | 13 #include "third_party/WebKit/public/platform/WebURL.h" |
13 #include "third_party/WebKit/public/platform/WebVector.h" | 14 #include "third_party/WebKit/public/platform/WebVector.h" |
14 #include "third_party/WebKit/public/platform/modules/notifications/WebNotificati
onAction.h" | 15 #include "third_party/WebKit/public/platform/modules/notifications/WebNotificati
onAction.h" |
15 | 16 |
16 using blink::WebNotificationData; | 17 using blink::WebNotificationData; |
17 | 18 |
18 namespace content { | 19 namespace content { |
19 | 20 |
(...skipping 15 matching lines...) Expand all Loading... |
35 platform_data.direction = PlatformNotificationData::DIRECTION_AUTO; | 36 platform_data.direction = PlatformNotificationData::DIRECTION_AUTO; |
36 break; | 37 break; |
37 } | 38 } |
38 | 39 |
39 platform_data.lang = base::UTF16ToUTF8(base::StringPiece16(web_data.lang)); | 40 platform_data.lang = base::UTF16ToUTF8(base::StringPiece16(web_data.lang)); |
40 platform_data.body = web_data.body; | 41 platform_data.body = web_data.body; |
41 platform_data.tag = base::UTF16ToUTF8(base::StringPiece16(web_data.tag)); | 42 platform_data.tag = base::UTF16ToUTF8(base::StringPiece16(web_data.tag)); |
42 platform_data.icon = blink::WebStringToGURL(web_data.icon.string()); | 43 platform_data.icon = blink::WebStringToGURL(web_data.icon.string()); |
43 platform_data.vibration_pattern.assign(web_data.vibrate.begin(), | 44 platform_data.vibration_pattern.assign(web_data.vibrate.begin(), |
44 web_data.vibrate.end()); | 45 web_data.vibrate.end()); |
| 46 platform_data.timestamp = base::Time::FromJsTime(web_data.timestamp); |
45 platform_data.silent = web_data.silent; | 47 platform_data.silent = web_data.silent; |
46 platform_data.require_interaction = web_data.requireInteraction; | 48 platform_data.require_interaction = web_data.requireInteraction; |
47 platform_data.data.assign(web_data.data.begin(), web_data.data.end()); | 49 platform_data.data.assign(web_data.data.begin(), web_data.data.end()); |
48 platform_data.actions.resize(web_data.actions.size()); | 50 platform_data.actions.resize(web_data.actions.size()); |
49 for (size_t i = 0; i < web_data.actions.size(); ++i) { | 51 for (size_t i = 0; i < web_data.actions.size(); ++i) { |
50 platform_data.actions[i].action = | 52 platform_data.actions[i].action = |
51 base::UTF16ToUTF8(base::StringPiece16(web_data.actions[i].action)); | 53 base::UTF16ToUTF8(base::StringPiece16(web_data.actions[i].action)); |
52 platform_data.actions[i].title = web_data.actions[i].title; | 54 platform_data.actions[i].title = web_data.actions[i].title; |
53 } | 55 } |
54 | 56 |
(...skipping 15 matching lines...) Expand all Loading... |
70 case PlatformNotificationData::DIRECTION_AUTO: | 72 case PlatformNotificationData::DIRECTION_AUTO: |
71 web_data.direction = WebNotificationData::DirectionAuto; | 73 web_data.direction = WebNotificationData::DirectionAuto; |
72 break; | 74 break; |
73 } | 75 } |
74 | 76 |
75 web_data.lang = blink::WebString::fromUTF8(platform_data.lang); | 77 web_data.lang = blink::WebString::fromUTF8(platform_data.lang); |
76 web_data.body = platform_data.body; | 78 web_data.body = platform_data.body; |
77 web_data.tag = blink::WebString::fromUTF8(platform_data.tag); | 79 web_data.tag = blink::WebString::fromUTF8(platform_data.tag); |
78 web_data.icon = blink::WebURL(platform_data.icon); | 80 web_data.icon = blink::WebURL(platform_data.icon); |
79 web_data.vibrate = platform_data.vibration_pattern; | 81 web_data.vibrate = platform_data.vibration_pattern; |
| 82 web_data.timestamp = platform_data.timestamp.ToJsTime(); |
80 web_data.silent = platform_data.silent; | 83 web_data.silent = platform_data.silent; |
81 web_data.requireInteraction = platform_data.require_interaction; | 84 web_data.requireInteraction = platform_data.require_interaction; |
82 web_data.data = platform_data.data; | 85 web_data.data = platform_data.data; |
83 blink::WebVector<blink::WebNotificationAction> resized( | 86 blink::WebVector<blink::WebNotificationAction> resized( |
84 platform_data.actions.size()); | 87 platform_data.actions.size()); |
85 web_data.actions.swap(resized); | 88 web_data.actions.swap(resized); |
86 for (size_t i = 0; i < platform_data.actions.size(); ++i) { | 89 for (size_t i = 0; i < platform_data.actions.size(); ++i) { |
87 web_data.actions[i].action = | 90 web_data.actions[i].action = |
88 blink::WebString::fromUTF8(platform_data.actions[i].action); | 91 blink::WebString::fromUTF8(platform_data.actions[i].action); |
89 web_data.actions[i].title = platform_data.actions[i].title; | 92 web_data.actions[i].title = platform_data.actions[i].title; |
90 } | 93 } |
91 | 94 |
92 return web_data; | 95 return web_data; |
93 } | 96 } |
94 | 97 |
95 } // namespace content | 98 } // namespace content |
OLD | NEW |