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

Unified Diff: Source/core/html/HTMLMediaElement.cpp

Issue 428263004: Revert of Delete mediaPlaybackRequiresUserGesture (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 5 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
« no previous file with comments | « Source/core/html/HTMLMediaElement.h ('k') | Source/web/WebSettingsImpl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/html/HTMLMediaElement.cpp
diff --git a/Source/core/html/HTMLMediaElement.cpp b/Source/core/html/HTMLMediaElement.cpp
index 2e7f9801e54e65cc38afbcd0fde33499f681174c..8166f64bb4cca55ec6ce34ea7310da7de9c3f548 100644
--- a/Source/core/html/HTMLMediaElement.cpp
+++ b/Source/core/html/HTMLMediaElement.cpp
@@ -39,6 +39,7 @@
#include "core/dom/shadow/ShadowRoot.h"
#include "core/events/Event.h"
#include "core/frame/LocalFrame.h"
+#include "core/frame/Settings.h"
#include "core/frame/UseCounter.h"
#include "core/frame/csp/ContentSecurityPolicy.h"
#include "core/html/HTMLMediaSource.h"
@@ -311,6 +312,7 @@
, m_fragmentStartTime(MediaPlayer::invalidTime())
, m_fragmentEndTime(MediaPlayer::invalidTime())
, m_pendingActionFlags(0)
+ , m_userGestureRequiredForPlay(false)
, m_playing(false)
, m_shouldDelayLoadEvent(false)
, m_haveFiredLoadedData(false)
@@ -346,6 +348,9 @@
WTF_LOG(Media, "HTMLMediaElement::HTMLMediaElement");
ScriptWrappable::init(this);
+ if (document.settings() && document.settings()->mediaPlaybackRequiresUserGesture())
+ m_userGestureRequiredForPlay = true;
+
setHasCustomStyleCallbacks();
addElementToDocumentMap(this, &document);
}
@@ -692,6 +697,9 @@
{
WTF_LOG(Media, "HTMLMediaElement::load()");
+ if (UserGestureIndicator::processingUserGesture())
+ m_userGestureRequiredForPlay = false;
+
prepareForLoad();
loadInternal();
prepareToPlay();
@@ -939,7 +947,9 @@
bool attemptLoad = true;
if (url.protocolIs(mediaSourceBlobProtocol)) {
- if (!isMediaStreamURL(url.string())) {
+ if (isMediaStreamURL(url.string())) {
+ m_userGestureRequiredForPlay = false;
+ } else {
m_mediaSource = HTMLMediaSource::lookup(url.string());
if (m_mediaSource) {
@@ -1817,7 +1827,7 @@
scheduleEvent(EventTypeNames::playing);
}
- if (m_autoplaying && m_paused && autoplay() && !document().isSandboxed(SandboxAutomaticFeatures)) {
+ if (m_autoplaying && m_paused && autoplay() && !document().isSandboxed(SandboxAutomaticFeatures) && !m_userGestureRequiredForPlay) {
m_paused = false;
invalidateCachedTime();
scheduleEvent(EventTypeNames::play);
@@ -2187,6 +2197,11 @@
void HTMLMediaElement::play()
{
WTF_LOG(Media, "HTMLMediaElement::play()");
+
+ if (m_userGestureRequiredForPlay && !UserGestureIndicator::processingUserGesture())
+ return;
+ if (UserGestureIndicator::processingUserGesture())
+ m_userGestureRequiredForPlay = false;
playInternal();
}
« no previous file with comments | « Source/core/html/HTMLMediaElement.h ('k') | Source/web/WebSettingsImpl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698