Chromium Code Reviews| 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) |