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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 86 | 86 |
| 87 const size_t maxActions = Notification::maxActions(); | 87 const size_t maxActions = Notification::maxActions(); |
| 88 for (const NotificationAction& action : options.actions()) { | 88 for (const NotificationAction& action : options.actions()) { |
| 89 if (actions.size() >= maxActions) | 89 if (actions.size() >= maxActions) |
| 90 break; | 90 break; |
| 91 | 91 |
| 92 WebNotificationAction webAction; | 92 WebNotificationAction webAction; |
| 93 webAction.action = action.action(); | 93 webAction.action = action.action(); |
| 94 webAction.title = action.title(); | 94 webAction.title = action.title(); |
| 95 | 95 |
| 96 if (action.type() == "button") | |
| 97 webAction.type = WebNotificationAction::Button; | |
| 98 else if (action.type() == "text") | |
| 99 webAction.type = WebNotificationAction::Text; | |
| 100 else | |
| 101 NOTREACHED() << "Unknown action type: " << action.type(); | |
| 102 | |
| 103 if (action.hasPlaceholder() && webAction.type == WebNotificationAction:: Button) { | |
| 104 exceptionState.throwTypeError("Notifications of type \"button\" cann ot specify a placeholder."); | |
|
Peter Beverloo
2016/04/06 17:22:00
test?
See NotificationDataTest.cpp
Nina
2016/04/07 10:59:09
Ah, this was only tested on the layout test. Added
| |
| 105 return WebNotificationData(); | |
| 106 } | |
| 107 | |
| 108 webAction.placeholder = action.placeholder(); | |
| 109 | |
| 96 if (action.hasIcon() && !action.icon().isEmpty()) | 110 if (action.hasIcon() && !action.icon().isEmpty()) |
| 97 webAction.icon = completeURL(executionContext, action.icon()); | 111 webAction.icon = completeURL(executionContext, action.icon()); |
| 98 | 112 |
| 99 actions.append(webAction); | 113 actions.append(webAction); |
| 100 } | 114 } |
| 101 | 115 |
| 102 webData.actions = actions; | 116 webData.actions = actions; |
| 103 | 117 |
| 104 return webData; | 118 return webData; |
| 105 } | 119 } |
| 106 | 120 |
| 107 } // namespace blink | 121 } // namespace blink |
| OLD | NEW |