OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "modules/mediasession/MediaSession.h" | 5 #include "modules/mediasession/MediaSession.h" |
6 | 6 |
7 #include "bindings/core/v8/ScriptState.h" | 7 #include "bindings/core/v8/ScriptState.h" |
8 #include "core/dom/Document.h" | 8 #include "core/dom/Document.h" |
| 9 #include "core/dom/DocumentUserGestureToken.h" |
9 #include "core/dom/ExecutionContext.h" | 10 #include "core/dom/ExecutionContext.h" |
10 #include "core/events/Event.h" | 11 #include "core/events/Event.h" |
11 #include "core/frame/LocalFrame.h" | 12 #include "core/frame/LocalFrame.h" |
12 #include "modules/EventTargetModules.h" | 13 #include "modules/EventTargetModules.h" |
13 #include "modules/mediasession/MediaMetadata.h" | 14 #include "modules/mediasession/MediaMetadata.h" |
14 #include "modules/mediasession/MediaMetadataSanitizer.h" | 15 #include "modules/mediasession/MediaMetadataSanitizer.h" |
| 16 #include "platform/UserGestureIndicator.h" |
15 #include "public/platform/InterfaceProvider.h" | 17 #include "public/platform/InterfaceProvider.h" |
16 #include "wtf/Optional.h" | 18 #include "wtf/Optional.h" |
17 #include <memory> | 19 #include <memory> |
18 | 20 |
19 namespace blink { | 21 namespace blink { |
20 | 22 |
21 namespace { | 23 namespace { |
22 | 24 |
23 using ::blink::mojom::blink::MediaSessionAction; | 25 using ::blink::mojom::blink::MediaSessionAction; |
24 | 26 |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 getService(m_scriptState.get())) { | 143 getService(m_scriptState.get())) { |
142 auto mojomAction = eventNameToMojomAction(eventType); | 144 auto mojomAction = eventNameToMojomAction(eventType); |
143 DCHECK(mojomAction.has_value()); | 145 DCHECK(mojomAction.has_value()); |
144 service->DisableAction(mojomAction.value()); | 146 service->DisableAction(mojomAction.value()); |
145 } | 147 } |
146 return EventTarget::removeEventListenerInternal(eventType, listener, options); | 148 return EventTarget::removeEventListenerInternal(eventType, listener, options); |
147 } | 149 } |
148 | 150 |
149 void MediaSession::DidReceiveAction( | 151 void MediaSession::DidReceiveAction( |
150 blink::mojom::blink::MediaSessionAction action) { | 152 blink::mojom::blink::MediaSessionAction action) { |
| 153 DCHECK(getExecutionContext()->isDocument()); |
| 154 Document* document = toDocument(getExecutionContext()); |
| 155 UserGestureIndicator gestureIndicator( |
| 156 DocumentUserGestureToken::create(document)); |
151 dispatchEvent(Event::create(mojomActionToEventName(action))); | 157 dispatchEvent(Event::create(mojomActionToEventName(action))); |
152 } | 158 } |
153 | 159 |
154 DEFINE_TRACE(MediaSession) { | 160 DEFINE_TRACE(MediaSession) { |
155 visitor->trace(m_metadata); | 161 visitor->trace(m_metadata); |
156 EventTargetWithInlineData::trace(visitor); | 162 EventTargetWithInlineData::trace(visitor); |
157 } | 163 } |
158 | 164 |
159 } // namespace blink | 165 } // namespace blink |
OLD | NEW |