Chromium Code Reviews| 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" |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 40 WebNotificationData webData; | 40 WebNotificationData webData; |
| 41 | 41 |
| 42 webData.title = title; | 42 webData.title = title; |
| 43 webData.direction = toDirectionEnumValue(options.dir()); | 43 webData.direction = toDirectionEnumValue(options.dir()); |
| 44 webData.lang = options.lang(); | 44 webData.lang = options.lang(); |
| 45 webData.body = options.body(); | 45 webData.body = options.body(); |
| 46 webData.tag = options.tag(); | 46 webData.tag = options.tag(); |
| 47 | 47 |
| 48 KURL iconUrl; | 48 KURL iconUrl; |
| 49 | 49 |
| 50 // TODO(peter): Apply the appropriate CORS checks on the |iconUrl|. | |
| 51 if (options.hasIcon() && !options.icon().isEmpty()) { | 50 if (options.hasIcon() && !options.icon().isEmpty()) { |
| 52 iconUrl = executionContext->completeURL(options.icon()); | 51 iconUrl = executionContext->completeURL(options.icon()); |
| 53 if (!iconUrl.isValid()) | 52 if (!iconUrl.isValid()) |
| 54 iconUrl = KURL(); | 53 iconUrl = KURL(); |
| 55 } | 54 } |
| 56 | 55 |
| 57 webData.icon = iconUrl; | 56 webData.icon = iconUrl; |
| 58 webData.vibrate = NavigatorVibration::sanitizeVibrationPattern(options.vibra te()); | 57 webData.vibrate = NavigatorVibration::sanitizeVibrationPattern(options.vibra te()); |
| 59 webData.silent = options.silent(); | 58 webData.silent = options.silent(); |
| 60 webData.requireInteraction = options.requireInteraction(); | 59 webData.requireInteraction = options.requireInteraction(); |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 74 | 73 |
| 75 const size_t maxActions = Notification::maxActions(); | 74 const size_t maxActions = Notification::maxActions(); |
| 76 for (const NotificationAction& action : options.actions()) { | 75 for (const NotificationAction& action : options.actions()) { |
| 77 if (actions.size() >= maxActions) | 76 if (actions.size() >= maxActions) |
| 78 break; | 77 break; |
| 79 | 78 |
| 80 WebNotificationAction webAction; | 79 WebNotificationAction webAction; |
| 81 webAction.action = action.action(); | 80 webAction.action = action.action(); |
| 82 webAction.title = action.title(); | 81 webAction.title = action.title(); |
| 83 | 82 |
| 83 if (RuntimeEnabledFeatures::notificationExperimentalEnabled()) { | |
|
Peter Beverloo
2016/01/27 13:24:45
We don't need this check anymore, the bindings fol
Michael van Ouwerkerk
2016/01/27 14:24:32
Oh look at that. Nice.
| |
| 84 KURL iconUrl; | |
| 85 if (action.hasIcon() && !action.icon().isEmpty()) { | |
| 86 iconUrl = executionContext->completeURL(action.icon()); | |
| 87 if (!iconUrl.isValid()) | |
| 88 iconUrl = KURL(); | |
| 89 } | |
| 90 webAction.icon = iconUrl; | |
| 91 } | |
| 92 | |
| 84 actions.append(webAction); | 93 actions.append(webAction); |
| 85 } | 94 } |
| 86 | 95 |
| 87 webData.actions = actions; | 96 webData.actions = actions; |
| 88 | 97 |
| 89 return webData; | 98 return webData; |
| 90 } | 99 } |
| 91 | 100 |
| 92 } // namespace blink | 101 } // namespace blink |
| OLD | NEW |