| 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 "config.h" | 5 #include "config.h" |
| 6 #include "modules/notifications/NotificationData.h" | 6 #include "modules/notifications/NotificationData.h" |
| 7 | 7 |
| 8 #include "bindings/core/v8/ExceptionState.h" | 8 #include "bindings/core/v8/ExceptionState.h" |
| 9 #include "bindings/core/v8/SerializedScriptValue.h" | 9 #include "bindings/core/v8/SerializedScriptValue.h" |
| 10 #include "bindings/core/v8/SerializedScriptValueFactory.h" | 10 #include "bindings/core/v8/SerializedScriptValueFactory.h" |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 Vector<char> serializedData; | 68 Vector<char> serializedData; |
| 69 serializedScriptValue->toWireBytes(serializedData); | 69 serializedScriptValue->toWireBytes(serializedData); |
| 70 | 70 |
| 71 webData.data = serializedData; | 71 webData.data = serializedData; |
| 72 } | 72 } |
| 73 | 73 |
| 74 Vector<WebNotificationAction> actions; | 74 Vector<WebNotificationAction> actions; |
| 75 | 75 |
| 76 const size_t maxActions = Notification::maxActions(); | 76 const size_t maxActions = Notification::maxActions(); |
| 77 for (const NotificationAction& action : options.actions()) { | 77 for (const NotificationAction& action : options.actions()) { |
| 78 if (action.action().isEmpty()) { | |
| 79 exceptionState.throwTypeError("NotificationAction `action` must not
be empty."); | |
| 80 return WebNotificationData(); | |
| 81 } | |
| 82 | |
| 83 if (action.title().isEmpty()) { | |
| 84 exceptionState.throwTypeError("NotificationAction `title` must not b
e empty."); | |
| 85 return WebNotificationData(); | |
| 86 } | |
| 87 | |
| 88 if (actions.size() >= maxActions) | 78 if (actions.size() >= maxActions) |
| 89 continue; | 79 break; |
| 90 | 80 |
| 91 WebNotificationAction webAction; | 81 WebNotificationAction webAction; |
| 92 webAction.action = action.action(); | 82 webAction.action = action.action(); |
| 93 webAction.title = action.title(); | 83 webAction.title = action.title(); |
| 94 | 84 |
| 95 actions.append(webAction); | 85 actions.append(webAction); |
| 96 } | 86 } |
| 97 | 87 |
| 98 webData.actions = actions; | 88 webData.actions = actions; |
| 99 | 89 |
| 100 return webData; | 90 return webData; |
| 101 } | 91 } |
| 102 | 92 |
| 103 } // namespace blink | 93 } // namespace blink |
| OLD | NEW |