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

Unified Diff: Source/modules/notifications/Notification.cpp

Issue 1280913002: Deliver action clicks to page notifications (blink) (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@click_test
Patch Set: Created 5 years, 4 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 side-by-side diff with in-line comments
Download patch
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()

Powered by Google App Engine
This is Rietveld 408576698