Chromium Code Reviews| Index: Source/modules/notifications/Notification.cpp |
| diff --git a/Source/modules/notifications/Notification.cpp b/Source/modules/notifications/Notification.cpp |
| index cb95b15625b0b8f6661ed312321f923e6d905d7f..6789009b7ef1b8bdffc2b2a58da4cd6403d26e0c 100644 |
| --- a/Source/modules/notifications/Notification.cpp |
| +++ b/Source/modules/notifications/Notification.cpp |
| @@ -45,6 +45,7 @@ |
| #include "core/frame/UseCounter.h" |
| #include "modules/notifications/NotificationOptions.h" |
| #include "modules/notifications/NotificationPermissionClient.h" |
| +#include "modules/notifications/PageNotificationEvent.h" |
| #include "platform/RuntimeEnabledFeatures.h" |
| #include "platform/UserGestureIndicator.h" |
| #include "public/platform/Platform.h" |
| @@ -247,9 +248,23 @@ void Notification::dispatchShowEvent() |
| void Notification::dispatchClickEvent() |
| { |
| + dispatchClickEvent(-1); |
| +} |
| + |
| +void Notification::dispatchClickEvent(int actionIndex) |
| +{ |
| UserGestureIndicator gestureIndicator(DefinitelyProcessingNewUserGesture); |
| ScopedWindowFocusAllowedIndicator windowFocusAllowed(executionContext()); |
| - dispatchEvent(Event::create(EventTypeNames::click)); |
| + if (!RuntimeEnabledFeatures::notificationExperimentalEnabled()) { |
| + // TODO(johnme): Remove this branch once actions ship. |
|
Peter Beverloo
2015/08/07 07:25:25
no need for this TODO (the code is no less obvious
|
| + dispatchEvent(Event::create(EventTypeNames::click)); |
| + return; |
| + } |
| + |
| + PageNotificationEventInit eventInit; |
| + if (0 <= actionIndex && actionIndex < static_cast<int>(m_actions.size())) |
|
Peter Beverloo
2015/08/07 07:25:25
if (actionIndex >= 0 && actionIndex < static_cast<
|
| + eventInit.setAction(m_actions[actionIndex].action()); |
| + dispatchEvent(PageNotificationEvent::create(EventTypeNames::click, eventInit)); |
| } |
| void Notification::dispatchErrorEvent() |