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

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

Issue 2091253002: When autoplaying muted video, record when unmute happen and the result. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review comments and rebase Created 4 years, 6 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 | « third_party/WebKit/Source/core/html/HTMLMediaElement.h ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/html/HTMLMediaElement.cpp
diff --git a/third_party/WebKit/Source/core/html/HTMLMediaElement.cpp b/third_party/WebKit/Source/core/html/HTMLMediaElement.cpp
index bff62e7bfdb250473405fbd5bc2215a8d99b8bf2..1310d9cc440f55bc71606e7ddc4906c5ff3ae042 100644
--- a/third_party/WebKit/Source/core/html/HTMLMediaElement.cpp
+++ b/third_party/WebKit/Source/core/html/HTMLMediaElement.cpp
@@ -2290,12 +2290,14 @@ void HTMLMediaElement::setMuted(bool muted)
{
MEDIA_LOG << "setMuted(" << (void*)this << ", " << boolString(muted) << ")";
- if (UserGestureIndicator::processingUserGesture())
- unlockUserGesture();
-
if (m_muted == muted)
return;
+ bool wasAutoplayingMuted = !paused() && m_muted && isLockedPendingUserGesture();
+
+ if (UserGestureIndicator::processingUserGesture())
whywhat 2016/06/29 19:44:18 nit: you could avoid moving that if calculating wa
mlamouri (slow - plz ping) 2016/06/29 19:47:59 ACK :)
+ unlockUserGesture();
+
m_muted = muted;
m_autoplayHelper->mutedChanged();
@@ -2308,9 +2310,16 @@ void HTMLMediaElement::setMuted(bool muted)
scheduleEvent(EventTypeNames::volumechange);
- // Pause the element when unmuting if it's still locked.
- if (!muted && isGestureNeededForPlayback())
- pause();
+ // If an element autoplayed while muted, it needs to be unlocked to unmute,
+ // otherwise, it will be paused.
+ if (wasAutoplayingMuted) {
+ if (isGestureNeededForPlayback()) {
+ pause();
+ recordAutoplayUnmuteStatus(AutoplayUnmuteActionFailure);
+ } else {
+ recordAutoplayUnmuteStatus(AutoplayUnmuteActionSuccess);
+ }
+ }
}
void HTMLMediaElement::updateVolume()
@@ -3898,6 +3907,13 @@ void HTMLMediaElement::recordAutoplaySourceMetric(int source)
}
}
+void HTMLMediaElement::recordAutoplayUnmuteStatus(AutoplayUnmuteActionStatus status)
+{
+ DEFINE_STATIC_LOCAL(EnumerationHistogram, autoplayUnmuteHistogram, ("Media.Video.Autoplay.Muted.UnmuteAction", AutoplayUnmuteActionMax));
+
+ autoplayUnmuteHistogram.count(status);
+}
+
void HTMLMediaElement::onVisibilityChangedForAutoplay(bool isVisible)
{
if (!isVisible)
« no previous file with comments | « third_party/WebKit/Source/core/html/HTMLMediaElement.h ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698