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

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: Address comments Created 4 years, 2 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 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 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 DCHECK(m_notificationId.isEmpty()); 213 DCHECK(m_notificationId.isEmpty());
213 m_notificationId = notificationId; 214 m_notificationId = notificationId;
214 215
215 dispatchEvent(Event::create(EventTypeNames::show)); 216 dispatchEvent(Event::create(EventTypeNames::show));
216 217
217 if (m_requestedClose) 218 if (m_requestedClose)
218 close(); 219 close();
219 } 220 }
220 221
221 void Notification::didClickNotification() { 222 void Notification::didClickNotification() {
222 UserGestureIndicator gestureIndicator( 223 ExecutionContext* context = getExecutionContext();
223 UserGestureToken::create(UserGestureToken::NewGesture)); 224 UserGestureIndicator gestureIndicator(DocumentUserGestureToken::create(
224 225 context->isDocument() ? toDocument(context) : nullptr,
Peter Beverloo 2016/10/19 16:36:48 Prefer DCHECK(context->isDocument()) for this code
Nate Chapin 2016/10/21 18:11:04 Done.
Nate Chapin 2016/10/21 20:43:28 ...actually, the layout tests disagree. Switched b
226 UserGestureToken::NewGesture));
225 ScopedWindowFocusAllowedIndicator windowFocusAllowed(getExecutionContext()); 227 ScopedWindowFocusAllowedIndicator windowFocusAllowed(getExecutionContext());
226 dispatchEvent(Event::create(EventTypeNames::click)); 228 dispatchEvent(Event::create(EventTypeNames::click));
227 } 229 }
228 230
229 void Notification::didCloseNotification() { 231 void Notification::didCloseNotification() {
230 // The notification will be showing when the user initiated the close, or it 232 // The notification will be showing when the user initiated the close, or it
231 // will be closing if the developer initiated the close. 233 // will be closing if the developer initiated the close.
232 if (m_state != State::Showing && m_state != State::Closing) 234 if (m_state != State::Showing && m_state != State::Closing)
233 return; 235 return;
234 236
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 } 407 }
406 408
407 DEFINE_TRACE(Notification) { 409 DEFINE_TRACE(Notification) {
408 visitor->trace(m_prepareShowMethodRunner); 410 visitor->trace(m_prepareShowMethodRunner);
409 visitor->trace(m_loader); 411 visitor->trace(m_loader);
410 EventTargetWithInlineData::trace(visitor); 412 EventTargetWithInlineData::trace(visitor);
411 ActiveDOMObject::trace(visitor); 413 ActiveDOMObject::trace(visitor);
412 } 414 }
413 415
414 } // namespace blink 416 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698