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" | |
15 #include "platform/weborigin/KURL.h" | 14 #include "platform/weborigin/KURL.h" |
16 | 15 |
17 namespace blink { | 16 namespace blink { |
18 namespace { | 17 namespace { |
19 | 18 |
20 WebNotificationData::Direction toDirectionEnumValue(const String& direction) | 19 WebNotificationData::Direction toDirectionEnumValue(const String& direction) |
21 { | 20 { |
22 if (direction == "ltr") | 21 if (direction == "ltr") |
23 return WebNotificationData::DirectionLeftToRight; | 22 return WebNotificationData::DirectionLeftToRight; |
24 if (direction == "rtl") | 23 if (direction == "rtl") |
(...skipping 15 matching lines...) Expand all Loading... | |
40 WebNotificationData webData; | 39 WebNotificationData webData; |
41 | 40 |
42 webData.title = title; | 41 webData.title = title; |
43 webData.direction = toDirectionEnumValue(options.dir()); | 42 webData.direction = toDirectionEnumValue(options.dir()); |
44 webData.lang = options.lang(); | 43 webData.lang = options.lang(); |
45 webData.body = options.body(); | 44 webData.body = options.body(); |
46 webData.tag = options.tag(); | 45 webData.tag = options.tag(); |
47 | 46 |
48 KURL iconUrl; | 47 KURL iconUrl; |
49 | 48 |
50 // TODO(peter): Apply the appropriate CORS checks on the |iconUrl|. | |
51 if (options.hasIcon() && !options.icon().isEmpty()) { | 49 if (options.hasIcon() && !options.icon().isEmpty()) { |
52 iconUrl = executionContext->completeURL(options.icon()); | 50 iconUrl = executionContext->completeURL(options.icon()); |
53 if (!iconUrl.isValid()) | 51 if (!iconUrl.isValid()) |
54 iconUrl = KURL(); | 52 iconUrl = KURL(); |
55 } | 53 } |
56 | 54 |
57 webData.icon = iconUrl; | 55 webData.icon = iconUrl; |
58 webData.vibrate = NavigatorVibration::sanitizeVibrationPattern(options.vibra te()); | 56 webData.vibrate = NavigatorVibration::sanitizeVibrationPattern(options.vibra te()); |
59 webData.silent = options.silent(); | 57 webData.silent = options.silent(); |
60 webData.requireInteraction = options.requireInteraction(); | 58 webData.requireInteraction = options.requireInteraction(); |
(...skipping 13 matching lines...) Expand all Loading... | |
74 | 72 |
75 const size_t maxActions = Notification::maxActions(); | 73 const size_t maxActions = Notification::maxActions(); |
76 for (const NotificationAction& action : options.actions()) { | 74 for (const NotificationAction& action : options.actions()) { |
77 if (actions.size() >= maxActions) | 75 if (actions.size() >= maxActions) |
78 break; | 76 break; |
79 | 77 |
80 WebNotificationAction webAction; | 78 WebNotificationAction webAction; |
81 webAction.action = action.action(); | 79 webAction.action = action.action(); |
82 webAction.title = action.title(); | 80 webAction.title = action.title(); |
83 | 81 |
82 KURL iconUrl; | |
83 if (action.hasIcon() && !action.icon().isEmpty()) { | |
84 iconUrl = executionContext->completeURL(action.icon()); | |
85 if (!iconUrl.isValid()) | |
86 iconUrl = KURL(); | |
87 } | |
88 webAction.icon = iconUrl; | |
Peter Beverloo
2016/01/27 17:14:23
PTAL at third_party/WebKit/Source/modules/notifica
Michael van Ouwerkerk
2016/02/01 14:39:23
Done.
| |
89 | |
84 actions.append(webAction); | 90 actions.append(webAction); |
85 } | 91 } |
86 | 92 |
87 webData.actions = actions; | 93 webData.actions = actions; |
88 | 94 |
89 return webData; | 95 return webData; |
90 } | 96 } |
91 | 97 |
92 } // namespace blink | 98 } // namespace blink |
OLD | NEW |