| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "modules/mediasession/HTMLMediaElementMediaSession.h" | |
| 6 | |
| 7 #include "core/dom/ExceptionCode.h" | |
| 8 | |
| 9 namespace blink { | |
| 10 | |
| 11 MediaSession* HTMLMediaElementMediaSession::session(HTMLMediaElement& mediaEleme
nt) | |
| 12 { | |
| 13 if (HTMLMediaElementMediaSession* supplement = fromIfExists(mediaElement)) | |
| 14 return supplement->m_session.get(); | |
| 15 return nullptr; | |
| 16 } | |
| 17 | |
| 18 void HTMLMediaElementMediaSession::setSession(HTMLMediaElement& mediaElement, Me
diaSession* session, ExceptionState& exceptionState) | |
| 19 { | |
| 20 HTMLMediaElement::NetworkState networkState = mediaElement.getNetworkState()
; | |
| 21 if (networkState == HTMLMediaElement::kNetworkIdle || networkState == HTMLMe
diaElement::kNetworkLoading) { | |
| 22 exceptionState.throwDOMException(InvalidStateError, "networkState must b
e kNetworkEmpty or kNetworkNoSource."); | |
| 23 return; | |
| 24 } | |
| 25 | |
| 26 from(mediaElement).m_session = session; | |
| 27 } | |
| 28 | |
| 29 const char* HTMLMediaElementMediaSession::supplementName() | |
| 30 { | |
| 31 return "HTMLMediaElementMediaSession"; | |
| 32 } | |
| 33 | |
| 34 HTMLMediaElementMediaSession& HTMLMediaElementMediaSession::from(HTMLMediaElemen
t& element) | |
| 35 { | |
| 36 HTMLMediaElementMediaSession* supplement = fromIfExists(element); | |
| 37 if (!supplement) { | |
| 38 supplement = new HTMLMediaElementMediaSession(); | |
| 39 provideTo(element, supplementName(), supplement); | |
| 40 } | |
| 41 return *supplement; | |
| 42 } | |
| 43 | |
| 44 HTMLMediaElementMediaSession* HTMLMediaElementMediaSession::fromIfExists(HTMLMed
iaElement& element) | |
| 45 { | |
| 46 return static_cast<HTMLMediaElementMediaSession*>(Supplement<HTMLMediaElemen
t>::from(element, supplementName())); | |
| 47 } | |
| 48 | |
| 49 DEFINE_TRACE(HTMLMediaElementMediaSession) | |
| 50 { | |
| 51 visitor->trace(m_session); | |
| 52 Supplement<HTMLMediaElement>::trace(visitor); | |
| 53 } | |
| 54 | |
| 55 } // namespace blink | |
| OLD | NEW |