Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(859)

Side by Side Diff: third_party/WebKit/Source/modules/mediasession/HTMLMediaElementMediaSession.cpp

Issue 1420223002: Disallow assigning a MediaSession after the resource has been selected (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Pull expected file from the bots Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "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 HTMLMediaElement::NetworkState networkState = mediaElement.networkState();
22 if (networkState == HTMLMediaElement::NETWORK_IDLE || networkState == HTMLMe diaElement::NETWORK_LOADING) {
23 exceptionState.throwDOMException(InvalidStateError, "networkState must b e NETWORK_EMPTY or NETWORK_NO_SOURCE.");
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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698