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

Unified 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, 2 months 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/modules/mediasession/HTMLMediaElementMediaSession.cpp
diff --git a/third_party/WebKit/Source/modules/mediasession/HTMLMediaElementMediaSession.cpp b/third_party/WebKit/Source/modules/mediasession/HTMLMediaElementMediaSession.cpp
index ddcde17601ffe90911027ed7909630e6e3bda4cf..1266a558028d2efc5e5db2801701401186e58676 100644
--- a/third_party/WebKit/Source/modules/mediasession/HTMLMediaElementMediaSession.cpp
+++ b/third_party/WebKit/Source/modules/mediasession/HTMLMediaElementMediaSession.cpp
@@ -5,6 +5,8 @@
#include "config.h"
#include "modules/mediasession/HTMLMediaElementMediaSession.h"
+#include "core/dom/ExceptionCode.h"
+
namespace blink {
MediaSession* HTMLMediaElementMediaSession::session(HTMLMediaElement& mediaElement)
@@ -14,8 +16,14 @@ MediaSession* HTMLMediaElementMediaSession::session(HTMLMediaElement& mediaEleme
return nullptr;
}
-void HTMLMediaElementMediaSession::setSession(HTMLMediaElement& mediaElement, MediaSession* session)
+void HTMLMediaElementMediaSession::setSession(HTMLMediaElement& mediaElement, MediaSession* session, ExceptionState& exceptionState)
{
+ HTMLMediaElement::NetworkState networkState = mediaElement.networkState();
+ if (networkState == HTMLMediaElement::NETWORK_IDLE || networkState == HTMLMediaElement::NETWORK_LOADING) {
+ exceptionState.throwDOMException(InvalidStateError, "networkState must be NETWORK_EMPTY or NETWORK_NO_SOURCE.");
+ return;
+ }
+
from(mediaElement).m_session = session;
}

Powered by Google App Engine
This is Rietveld 408576698