OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "modules/notifications/NotificationData.h" | 5 #include "modules/notifications/NotificationData.h" |
6 | 6 |
7 #include "bindings/core/v8/ExceptionState.h" | 7 #include "bindings/core/v8/ExceptionState.h" |
8 #include "bindings/core/v8/SerializedScriptValue.h" | 8 #include "bindings/core/v8/SerializedScriptValue.h" |
9 #include "bindings/core/v8/SerializedScriptValueFactory.h" | 9 #include "bindings/core/v8/SerializedScriptValueFactory.h" |
10 #include "core/dom/ExecutionContext.h" | 10 #include "core/dom/ExecutionContext.h" |
11 #include "modules/notifications/Notification.h" | 11 #include "modules/notifications/Notification.h" |
12 #include "modules/notifications/NotificationOptions.h" | 12 #include "modules/notifications/NotificationOptions.h" |
13 #include "modules/vibration/NavigatorVibration.h" | 13 #include "modules/vibration/NavigatorVibration.h" |
14 #include "platform/RuntimeEnabledFeatures.h" | 14 #include "platform/RuntimeEnabledFeatures.h" |
15 #include "platform/weborigin/KURL.h" | 15 #include "platform/weborigin/KURL.h" |
| 16 #include "wtf/CurrentTime.h" |
16 | 17 |
17 namespace blink { | 18 namespace blink { |
18 namespace { | 19 namespace { |
19 | 20 |
20 WebNotificationData::Direction toDirectionEnumValue(const String& direction) | 21 WebNotificationData::Direction toDirectionEnumValue(const String& direction) |
21 { | 22 { |
22 if (direction == "ltr") | 23 if (direction == "ltr") |
23 return WebNotificationData::DirectionLeftToRight; | 24 return WebNotificationData::DirectionLeftToRight; |
24 if (direction == "rtl") | 25 if (direction == "rtl") |
25 return WebNotificationData::DirectionRightToLeft; | 26 return WebNotificationData::DirectionRightToLeft; |
(...skipping 23 matching lines...) Expand all Loading... |
49 | 50 |
50 // TODO(peter): Apply the appropriate CORS checks on the |iconUrl|. | 51 // TODO(peter): Apply the appropriate CORS checks on the |iconUrl|. |
51 if (options.hasIcon() && !options.icon().isEmpty()) { | 52 if (options.hasIcon() && !options.icon().isEmpty()) { |
52 iconUrl = executionContext->completeURL(options.icon()); | 53 iconUrl = executionContext->completeURL(options.icon()); |
53 if (!iconUrl.isValid()) | 54 if (!iconUrl.isValid()) |
54 iconUrl = KURL(); | 55 iconUrl = KURL(); |
55 } | 56 } |
56 | 57 |
57 webData.icon = iconUrl; | 58 webData.icon = iconUrl; |
58 webData.vibrate = NavigatorVibration::sanitizeVibrationPattern(options.vibra
te()); | 59 webData.vibrate = NavigatorVibration::sanitizeVibrationPattern(options.vibra
te()); |
| 60 webData.timestamp = options.hasTimestamp() ? static_cast<double>(options.tim
estamp()) : WTF::currentTimeMS(); |
59 webData.silent = options.silent(); | 61 webData.silent = options.silent(); |
60 webData.requireInteraction = options.requireInteraction(); | 62 webData.requireInteraction = options.requireInteraction(); |
61 | 63 |
62 if (options.hasData()) { | 64 if (options.hasData()) { |
63 RefPtr<SerializedScriptValue> serializedScriptValue = SerializedScriptVa
lueFactory::instance().create(options.data().isolate(), options.data(), nullptr,
exceptionState); | 65 RefPtr<SerializedScriptValue> serializedScriptValue = SerializedScriptVa
lueFactory::instance().create(options.data().isolate(), options.data(), nullptr,
exceptionState); |
64 if (exceptionState.hadException()) | 66 if (exceptionState.hadException()) |
65 return WebNotificationData(); | 67 return WebNotificationData(); |
66 | 68 |
67 Vector<char> serializedData; | 69 Vector<char> serializedData; |
68 serializedScriptValue->toWireBytes(serializedData); | 70 serializedScriptValue->toWireBytes(serializedData); |
(...skipping 14 matching lines...) Expand all Loading... |
83 | 85 |
84 actions.append(webAction); | 86 actions.append(webAction); |
85 } | 87 } |
86 | 88 |
87 webData.actions = actions; | 89 webData.actions = actions; |
88 | 90 |
89 return webData; | 91 return webData; |
90 } | 92 } |
91 | 93 |
92 } // namespace blink | 94 } // namespace blink |
OLD | NEW |