cygprofile: increase timeouts to allow showing web contents
[chromium-blink-merge.git] / content / child / notifications / notification_data_conversions.cc
blob9f05f0d0b61f3719bd8fb0cd3769c95477c6bbf0
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
3 // found in the LICENSE file.
5 #include "content/child/notifications/notification_data_conversions.h"
7 #include "base/strings/utf_string_conversions.h"
8 #include "third_party/WebKit/public/platform/WebString.h"
9 #include "third_party/WebKit/public/platform/WebURL.h"
10 #include "third_party/WebKit/public/platform/WebVector.h"
11 #include "third_party/WebKit/public/platform/modules/notifications/WebNotificationAction.h"
13 using blink::WebNotificationData;
15 namespace content {
17 PlatformNotificationData ToPlatformNotificationData(
18 const WebNotificationData& web_data) {
19 PlatformNotificationData platform_data;
20 platform_data.title = web_data.title;
22 switch (web_data.direction) {
23 case WebNotificationData::DirectionLeftToRight:
24 platform_data.direction =
25 PlatformNotificationData::DIRECTION_LEFT_TO_RIGHT;
26 break;
27 case WebNotificationData::DirectionRightToLeft:
28 platform_data.direction =
29 PlatformNotificationData::DIRECTION_RIGHT_TO_LEFT;
30 break;
31 case WebNotificationData::DirectionAuto:
32 platform_data.direction =
33 PlatformNotificationData::DIRECTION_AUTO;
34 break;
37 platform_data.lang = base::UTF16ToUTF8(base::StringPiece16(web_data.lang));
38 platform_data.body = web_data.body;
39 platform_data.tag = base::UTF16ToUTF8(base::StringPiece16(web_data.tag));
40 platform_data.icon = GURL(web_data.icon.string());
41 platform_data.vibration_pattern.assign(web_data.vibrate.begin(),
42 web_data.vibrate.end());
43 platform_data.silent = web_data.silent;
44 platform_data.require_interaction = web_data.requireInteraction;
45 platform_data.data.assign(web_data.data.begin(), web_data.data.end());
46 platform_data.actions.resize(web_data.actions.size());
47 for (size_t i = 0; i < web_data.actions.size(); ++i) {
48 platform_data.actions[i].action =
49 base::UTF16ToUTF8(base::StringPiece16(web_data.actions[i].action));
50 platform_data.actions[i].title = web_data.actions[i].title;
53 return platform_data;
56 WebNotificationData ToWebNotificationData(
57 const PlatformNotificationData& platform_data) {
58 WebNotificationData web_data;
59 web_data.title = platform_data.title;
61 switch (platform_data.direction) {
62 case PlatformNotificationData::DIRECTION_LEFT_TO_RIGHT:
63 web_data.direction = WebNotificationData::DirectionLeftToRight;
64 break;
65 case PlatformNotificationData::DIRECTION_RIGHT_TO_LEFT:
66 web_data.direction = WebNotificationData::DirectionRightToLeft;
67 break;
68 case PlatformNotificationData::DIRECTION_AUTO:
69 web_data.direction = WebNotificationData::DirectionAuto;
70 break;
73 web_data.lang = blink::WebString::fromUTF8(platform_data.lang);
74 web_data.body = platform_data.body;
75 web_data.tag = blink::WebString::fromUTF8(platform_data.tag);
76 web_data.icon = blink::WebURL(platform_data.icon);
77 web_data.vibrate = platform_data.vibration_pattern;
78 web_data.silent = platform_data.silent;
79 web_data.requireInteraction = platform_data.require_interaction;
80 web_data.data = platform_data.data;
81 blink::WebVector<blink::WebNotificationAction> resized(
82 platform_data.actions.size());
83 web_data.actions.swap(resized);
84 for (size_t i = 0; i < platform_data.actions.size(); ++i) {
85 web_data.actions[i].action =
86 blink::WebString::fromUTF8(platform_data.actions[i].action);
87 web_data.actions[i].title = platform_data.actions[i].title;
90 return web_data;
93 } // namespace content