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

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

Issue 2408333004: Move persistent gesture state to Document, add DocumentUserGestureToken (Closed)
Patch Set: Re-add dropped null check Created 4 years, 1 month 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 17 matching lines...) Expand all
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #include "modules/notifications/Notification.h" 31 #include "modules/notifications/Notification.h"
32 32
33 #include "bindings/core/v8/ExceptionState.h" 33 #include "bindings/core/v8/ExceptionState.h"
34 #include "bindings/core/v8/ScriptState.h" 34 #include "bindings/core/v8/ScriptState.h"
35 #include "bindings/core/v8/SerializedScriptValueFactory.h" 35 #include "bindings/core/v8/SerializedScriptValueFactory.h"
36 #include "bindings/modules/v8/V8NotificationAction.h" 36 #include "bindings/modules/v8/V8NotificationAction.h"
37 #include "core/dom/Document.h" 37 #include "core/dom/Document.h"
38 #include "core/dom/DocumentUserGestureToken.h"
38 #include "core/dom/ExecutionContext.h" 39 #include "core/dom/ExecutionContext.h"
39 #include "core/dom/ExecutionContextTask.h" 40 #include "core/dom/ExecutionContextTask.h"
40 #include "core/dom/ScopedWindowFocusAllowedIndicator.h" 41 #include "core/dom/ScopedWindowFocusAllowedIndicator.h"
41 #include "core/events/Event.h" 42 #include "core/events/Event.h"
42 #include "core/frame/UseCounter.h" 43 #include "core/frame/UseCounter.h"
43 #include "modules/notifications/NotificationAction.h" 44 #include "modules/notifications/NotificationAction.h"
44 #include "modules/notifications/NotificationData.h" 45 #include "modules/notifications/NotificationData.h"
45 #include "modules/notifications/NotificationManager.h" 46 #include "modules/notifications/NotificationManager.h"
46 #include "modules/notifications/NotificationOptions.h" 47 #include "modules/notifications/NotificationOptions.h"
47 #include "modules/notifications/NotificationResourcesLoader.h" 48 #include "modules/notifications/NotificationResourcesLoader.h"
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 202
202 notificationManager()->closePersistent(WebSecurityOrigin(origin), m_data.tag, 203 notificationManager()->closePersistent(WebSecurityOrigin(origin), m_data.tag,
203 m_notificationId); 204 m_notificationId);
204 } 205 }
205 206
206 void Notification::dispatchShowEvent() { 207 void Notification::dispatchShowEvent() {
207 dispatchEvent(Event::create(EventTypeNames::show)); 208 dispatchEvent(Event::create(EventTypeNames::show));
208 } 209 }
209 210
210 void Notification::dispatchClickEvent() { 211 void Notification::dispatchClickEvent() {
211 UserGestureIndicator gestureIndicator( 212 ExecutionContext* context = getExecutionContext();
212 UserGestureToken::create(UserGestureToken::NewGesture)); 213 UserGestureIndicator gestureIndicator(DocumentUserGestureToken::create(
214 context->isDocument() ? toDocument(context) : nullptr,
215 UserGestureToken::NewGesture));
213 ScopedWindowFocusAllowedIndicator windowFocusAllowed(getExecutionContext()); 216 ScopedWindowFocusAllowedIndicator windowFocusAllowed(getExecutionContext());
214 dispatchEvent(Event::create(EventTypeNames::click)); 217 dispatchEvent(Event::create(EventTypeNames::click));
215 } 218 }
216 219
217 void Notification::dispatchErrorEvent() { 220 void Notification::dispatchErrorEvent() {
218 dispatchEvent(Event::create(EventTypeNames::error)); 221 dispatchEvent(Event::create(EventTypeNames::error));
219 } 222 }
220 223
221 void Notification::dispatchCloseEvent() { 224 void Notification::dispatchCloseEvent() {
222 // The notification should be Showing if the user initiated the close, or it 225 // The notification should be Showing if the user initiated the close, or it
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 } 400 }
398 401
399 DEFINE_TRACE(Notification) { 402 DEFINE_TRACE(Notification) {
400 visitor->trace(m_prepareShowMethodRunner); 403 visitor->trace(m_prepareShowMethodRunner);
401 visitor->trace(m_loader); 404 visitor->trace(m_loader);
402 EventTargetWithInlineData::trace(visitor); 405 EventTargetWithInlineData::trace(visitor);
403 ActiveDOMObject::trace(visitor); 406 ActiveDOMObject::trace(visitor);
404 } 407 }
405 408
406 } // namespace blink 409 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698