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 Document* document = nullptr; | |
154 if (m_scriptState->domWindow()) | |
whywhat
2016/10/28 16:38:02
I think you should use something like this:
DCH
Zhiqiang Zhang (Slow)
2016/11/01 14:55:25
Done.
| |
155 document = m_scriptState->domWindow()->document(); | |
156 UserGestureIndicator gestureIndicator( | |
157 DocumentUserGestureToken::create(document)); | |
151 dispatchEvent(Event::create(mojomActionToEventName(action))); | 158 dispatchEvent(Event::create(mojomActionToEventName(action))); |
152 } | 159 } |
153 | 160 |
154 DEFINE_TRACE(MediaSession) { | 161 DEFINE_TRACE(MediaSession) { |
155 visitor->trace(m_metadata); | 162 visitor->trace(m_metadata); |
156 EventTargetWithInlineData::trace(visitor); | 163 EventTargetWithInlineData::trace(visitor); |
157 } | 164 } |
158 | 165 |
159 } // namespace blink | 166 } // namespace blink |
OLD | NEW |