| Index: third_party/WebKit/Source/modules/mediasession/MediaSession.cpp
|
| diff --git a/third_party/WebKit/Source/modules/mediasession/MediaSession.cpp b/third_party/WebKit/Source/modules/mediasession/MediaSession.cpp
|
| index 9396d06843e9e67f71baaef9ee3d97071b653a36..0afbb0d8c1483b93121fc7f133fb10a5b3177c1b 100644
|
| --- a/third_party/WebKit/Source/modules/mediasession/MediaSession.cpp
|
| +++ b/third_party/WebKit/Source/modules/mediasession/MediaSession.cpp
|
| @@ -8,6 +8,7 @@
|
| #include "core/dom/Document.h"
|
| #include "core/dom/ExecutionContext.h"
|
| #include "core/frame/LocalFrame.h"
|
| +#include "modules/EventTargetModules.h"
|
| #include "modules/mediasession/MediaMetadata.h"
|
| #include "modules/mediasession/MediaMetadataSanitizer.h"
|
| #include "public/platform/InterfaceProvider.h"
|
| @@ -15,25 +16,33 @@
|
|
|
| namespace blink {
|
|
|
| -MediaSession::MediaSession() = default;
|
| +MediaSession::MediaSession(ScriptState* scriptState)
|
| + : m_scriptState(scriptState) {}
|
|
|
| -MediaSession* MediaSession::create() {
|
| - return new MediaSession();
|
| +MediaSession* MediaSession::create(ScriptState* scriptState) {
|
| + return new MediaSession(scriptState);
|
| }
|
|
|
| -void MediaSession::setMetadata(ScriptState* scriptState,
|
| - MediaMetadata* metadata) {
|
| - if (getService(scriptState)) {
|
| - getService(scriptState)
|
| - ->SetMetadata(
|
| - MediaMetadataSanitizer::sanitizeAndConvertToMojo(metadata));
|
| +void MediaSession::setMetadata(MediaMetadata* metadata) {
|
| + if (mojom::blink::MediaSessionService* service =
|
| + getService(m_scriptState.get())) {
|
| + service->SetMetadata(
|
| + MediaMetadataSanitizer::sanitizeAndConvertToMojo(metadata));
|
| }
|
| }
|
|
|
| -MediaMetadata* MediaSession::metadata(ScriptState*) const {
|
| +MediaMetadata* MediaSession::metadata() const {
|
| return m_metadata;
|
| }
|
|
|
| +const WTF::AtomicString& MediaSession::interfaceName() const {
|
| + return EventTargetNames::MediaSession;
|
| +}
|
| +
|
| +ExecutionContext* MediaSession::getExecutionContext() const {
|
| + return m_scriptState->getExecutionContext();
|
| +}
|
| +
|
| mojom::blink::MediaSessionService* MediaSession::getService(
|
| ScriptState* scriptState) {
|
| if (!m_service) {
|
| @@ -50,8 +59,27 @@ mojom::blink::MediaSessionService* MediaSession::getService(
|
| return m_service.get();
|
| }
|
|
|
| +bool MediaSession::addEventListenerInternal(
|
| + const AtomicString& eventType,
|
| + EventListener* listener,
|
| + const AddEventListenerOptionsResolved& options) {
|
| + // TODO(zqzhang): Notify MediaSessionService the handler has been set. See
|
| + // https://crbug.com/656563
|
| + return EventTarget::addEventListenerInternal(eventType, listener, options);
|
| +}
|
| +
|
| +bool MediaSession::removeEventListenerInternal(
|
| + const AtomicString& eventType,
|
| + const EventListener* listener,
|
| + const EventListenerOptions& options) {
|
| + // TODO(zqzhang): Notify MediaSessionService the handler has been unset. See
|
| + // https://crbug.com/656563
|
| + return EventTarget::removeEventListenerInternal(eventType, listener, options);
|
| +}
|
| +
|
| DEFINE_TRACE(MediaSession) {
|
| visitor->trace(m_metadata);
|
| + EventTargetWithInlineData::trace(visitor);
|
| }
|
|
|
| } // namespace blink
|
|
|