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

Side by Side 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 27 matching lines...) Expand all
38 #include "bindings/core/v8/ScriptWrappable.h" 38 #include "bindings/core/v8/ScriptWrappable.h"
39 #include "bindings/core/v8/SerializedScriptValueFactory.h" 39 #include "bindings/core/v8/SerializedScriptValueFactory.h"
40 #include "core/dom/Document.h" 40 #include "core/dom/Document.h"
41 #include "core/dom/ExecutionContext.h" 41 #include "core/dom/ExecutionContext.h"
42 #include "core/dom/ExecutionContextTask.h" 42 #include "core/dom/ExecutionContextTask.h"
43 #include "core/dom/ScopedWindowFocusAllowedIndicator.h" 43 #include "core/dom/ScopedWindowFocusAllowedIndicator.h"
44 #include "core/events/Event.h" 44 #include "core/events/Event.h"
45 #include "core/frame/UseCounter.h" 45 #include "core/frame/UseCounter.h"
46 #include "modules/notifications/NotificationOptions.h" 46 #include "modules/notifications/NotificationOptions.h"
47 #include "modules/notifications/NotificationPermissionClient.h" 47 #include "modules/notifications/NotificationPermissionClient.h"
48 #include "modules/notifications/PageNotificationEvent.h"
48 #include "platform/RuntimeEnabledFeatures.h" 49 #include "platform/RuntimeEnabledFeatures.h"
49 #include "platform/UserGestureIndicator.h" 50 #include "platform/UserGestureIndicator.h"
50 #include "public/platform/Platform.h" 51 #include "public/platform/Platform.h"
51 #include "public/platform/WebSecurityOrigin.h" 52 #include "public/platform/WebSecurityOrigin.h"
52 #include "public/platform/WebString.h" 53 #include "public/platform/WebString.h"
53 #include "public/platform/modules/notifications/WebNotificationData.h" 54 #include "public/platform/modules/notifications/WebNotificationData.h"
54 #include "public/platform/modules/notifications/WebNotificationManager.h" 55 #include "public/platform/modules/notifications/WebNotificationManager.h"
55 56
56 namespace blink { 57 namespace blink {
57 namespace { 58 namespace {
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 } 241 }
241 } 242 }
242 243
243 void Notification::dispatchShowEvent() 244 void Notification::dispatchShowEvent()
244 { 245 {
245 dispatchEvent(Event::create(EventTypeNames::show)); 246 dispatchEvent(Event::create(EventTypeNames::show));
246 } 247 }
247 248
248 void Notification::dispatchClickEvent() 249 void Notification::dispatchClickEvent()
249 { 250 {
251 dispatchClickEvent(-1);
252 }
253
254 void Notification::dispatchClickEvent(int actionIndex)
255 {
250 UserGestureIndicator gestureIndicator(DefinitelyProcessingNewUserGesture); 256 UserGestureIndicator gestureIndicator(DefinitelyProcessingNewUserGesture);
251 ScopedWindowFocusAllowedIndicator windowFocusAllowed(executionContext()); 257 ScopedWindowFocusAllowedIndicator windowFocusAllowed(executionContext());
252 dispatchEvent(Event::create(EventTypeNames::click)); 258 if (!RuntimeEnabledFeatures::notificationExperimentalEnabled()) {
259 // 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
260 dispatchEvent(Event::create(EventTypeNames::click));
261 return;
262 }
263
264 PageNotificationEventInit eventInit;
265 if (0 <= actionIndex && actionIndex < static_cast<int>(m_actions.size()))
Peter Beverloo 2015/08/07 07:25:25 if (actionIndex >= 0 && actionIndex < static_cast<
266 eventInit.setAction(m_actions[actionIndex].action());
267 dispatchEvent(PageNotificationEvent::create(EventTypeNames::click, eventInit ));
253 } 268 }
254 269
255 void Notification::dispatchErrorEvent() 270 void Notification::dispatchErrorEvent()
256 { 271 {
257 dispatchEvent(Event::create(EventTypeNames::error)); 272 dispatchEvent(Event::create(EventTypeNames::error));
258 } 273 }
259 274
260 void Notification::dispatchCloseEvent() 275 void Notification::dispatchCloseEvent()
261 { 276 {
262 // The notification will be showing when the user initiated the close, or it will be 277 // The notification will be showing when the user initiated the close, or it will be
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 } 396 }
382 397
383 DEFINE_TRACE(Notification) 398 DEFINE_TRACE(Notification)
384 { 399 {
385 visitor->trace(m_actions); 400 visitor->trace(m_actions);
386 RefCountedGarbageCollectedEventTargetWithInlineData<Notification>::trace(vis itor); 401 RefCountedGarbageCollectedEventTargetWithInlineData<Notification>::trace(vis itor);
387 ActiveDOMObject::trace(visitor); 402 ActiveDOMObject::trace(visitor);
388 } 403 }
389 404
390 } // namespace blink 405 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698