Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(69)

Side by Side Diff: third_party/WebKit/Source/modules/notifications/NotificationData.cpp

Issue 1855443002: Implement receiving side of web notification inline replies (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comments & Tests Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 Vector<WebNotificationAction> actions; 85 Vector<WebNotificationAction> actions;
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 webAction.type = action.type();
96
97 if (action.hasPlaceholder() && action.type() == "button") {
98 exceptionState.throwTypeError("Notifications of type \"button\" cann ot specify a placeholder.");
99 return WebNotificationData();
100 }
101
102 webAction.placeholder = action.placeholder();
95 103
96 if (action.hasIcon() && !action.icon().isEmpty()) 104 if (action.hasIcon() && !action.icon().isEmpty())
97 webAction.icon = completeURL(executionContext, action.icon()); 105 webAction.icon = completeURL(executionContext, action.icon());
98 106
99 actions.append(webAction); 107 actions.append(webAction);
100 } 108 }
101 109
102 webData.actions = actions; 110 webData.actions = actions;
103 111
104 return webData; 112 return webData;
105 } 113 }
106 114
107 } // namespace blink 115 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698