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

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: 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
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 59ec313479d5ee3100f21ca36dafafa2cc016bcf..ca61da61a790214102539ca6c915c2397ece8aa9 100644
--- a/third_party/WebKit/Source/core/html/HTMLMediaElement.cpp
+++ b/third_party/WebKit/Source/core/html/HTMLMediaElement.cpp
@@ -293,6 +293,13 @@ enum AutoplaySource {
NumberOfAutoplaySources = 2,
};
+// These values are used for histograms. Do not reorder.
+enum AutoplayUnmuteActionStatus {
+ AutoplayUnmuteActionFailure = 0,
+ AutoplayUnmuteActionSuccess = 1,
+ AutoplayUnmuteActionMax = 2,
+};
+
} // anonymous namespace
class HTMLMediaElement::AutoplayHelperClientImpl :
@@ -2292,9 +2299,6 @@ void HTMLMediaElement::setMuted(bool muted)
{
MEDIA_LOG << "setMuted(" << (void*)this << ", " << boolString(muted) << ")";
- if (UserGestureIndicator::processingUserGesture())
- unlockUserGesture();
-
if (m_muted == muted)
return;
@@ -2310,6 +2314,14 @@ void HTMLMediaElement::setMuted(bool muted)
scheduleEvent(EventTypeNames::volumechange);
+ bool wasLocked = isGestureNeededForPlayback();
whywhat 2016/06/28 10:20:59 nit: I think you either want: bool wasLocked = m_
+ if (UserGestureIndicator::processingUserGesture())
+ unlockUserGesture();
+
+ // Record when unmuting a video that was autoplayed because it was muted.
+ if (wasLocked && !muted && isHTMLVideoElement() && RuntimeEnabledFeatures::autoplayMutedVideosEnabled())
whywhat 2016/06/28 10:20:59 this condition seems to be very hard to read and m
+ recordAutoplayUnmuteStatus(isGestureNeededForPlayback() ? AutoplayUnmuteStatus::Failure : AutoplayUnmuteStatus::Success);
+
// Pause the element when unmuting if it's still locked.
if (!muted && isGestureNeededForPlayback())
whywhat 2016/06/28 10:20:59 // this implicitly relies on m_muted set to false
pause();
@@ -3890,6 +3902,13 @@ void HTMLMediaElement::recordAutoplaySourceMetric(int source)
}
}
+void HTMLMediaElement::recordAutoplayUnmuteStatus(AutoplayUnmuteStatus status)
+{
+ DEFINE_STATIC_LOCAL(EnumerationHistogram, autoplayUnmuteHistogram, ("Media.Video.Autoplay.Muted.UnmuteAction", AutoplayUnmuteActionMax));
+
+ autoplayUnmuteHistogram.count(status == AutoplayUnmuteStatus::Success ? AutoplayUnmuteActionSuccess : AutoplayUnmuteActionFailure);
+}
+
void HTMLMediaElement::onVisibilityChangedForAutoplay(bool isVisible)
{
if (!isVisible)

Powered by Google App Engine
This is Rietveld 408576698