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 "config.h" | 5 #include "config.h" |
6 #include "modules/mediasession/HTMLMediaElementMediaSession.h" | 6 #include "modules/mediasession/HTMLMediaElementMediaSession.h" |
7 | 7 |
| 8 #include "Source/core/dom/ExceptionCode.h" |
| 9 |
8 namespace blink { | 10 namespace blink { |
9 | 11 |
10 MediaSession* HTMLMediaElementMediaSession::session(HTMLMediaElement& mediaEleme
nt) | 12 MediaSession* HTMLMediaElementMediaSession::session(HTMLMediaElement& mediaEleme
nt) |
11 { | 13 { |
12 if (HTMLMediaElementMediaSession* supplement = fromIfExists(mediaElement)) | 14 if (HTMLMediaElementMediaSession* supplement = fromIfExists(mediaElement)) |
13 return supplement->m_session.get(); | 15 return supplement->m_session.get(); |
14 return nullptr; | 16 return nullptr; |
15 } | 17 } |
16 | 18 |
17 void HTMLMediaElementMediaSession::setSession(HTMLMediaElement& mediaElement, Me
diaSession* session) | 19 void HTMLMediaElementMediaSession::setSession(HTMLMediaElement& mediaElement, Me
diaSession* session, ExceptionState& exceptionState) |
18 { | 20 { |
| 21 if (mediaElement.networkState() != HTMLMediaElement::NETWORK_EMPTY |
| 22 && mediaElement.networkState() != HTMLMediaElement::NETWORK_NO_SOURCE) { |
| 23 exceptionState.throwDOMException(InvalidStateError, "A media session mus
t be set when before a resource is selected"); |
| 24 return; |
| 25 } |
| 26 |
19 from(mediaElement).m_session = session; | 27 from(mediaElement).m_session = session; |
20 } | 28 } |
21 | 29 |
22 const char* HTMLMediaElementMediaSession::supplementName() | 30 const char* HTMLMediaElementMediaSession::supplementName() |
23 { | 31 { |
24 return "HTMLMediaElementMediaSession"; | 32 return "HTMLMediaElementMediaSession"; |
25 } | 33 } |
26 | 34 |
27 HTMLMediaElementMediaSession& HTMLMediaElementMediaSession::from(HTMLMediaElemen
t& element) | 35 HTMLMediaElementMediaSession& HTMLMediaElementMediaSession::from(HTMLMediaElemen
t& element) |
28 { | 36 { |
(...skipping 11 matching lines...) Expand all Loading... |
40 } | 48 } |
41 | 49 |
42 DEFINE_TRACE(HTMLMediaElementMediaSession) | 50 DEFINE_TRACE(HTMLMediaElementMediaSession) |
43 { | 51 { |
44 visitor->trace(m_session); | 52 visitor->trace(m_session); |
45 WillBeHeapSupplement<HTMLMediaElement>::trace(visitor); | 53 WillBeHeapSupplement<HTMLMediaElement>::trace(visitor); |
46 } | 54 } |
47 | 55 |
48 } | 56 } |
49 | 57 |
OLD | NEW |