| Index: third_party/WebKit/Source/core/html/AutoplayExperimentHelper.cpp
|
| diff --git a/third_party/WebKit/Source/core/html/AutoplayExperimentHelper.cpp b/third_party/WebKit/Source/core/html/AutoplayExperimentHelper.cpp
|
| index a06dc57a0eb3315f58a5bc6205000bc07364cb48..3bd4683141bb0dde7ba32b67020d73c3a69214ff 100644
|
| --- a/third_party/WebKit/Source/core/html/AutoplayExperimentHelper.cpp
|
| +++ b/third_party/WebKit/Source/core/html/AutoplayExperimentHelper.cpp
|
| @@ -53,10 +53,11 @@ void AutoplayExperimentHelper::becameReadyToPlay()
|
| {
|
| // Assuming that we're eligible to override the user gesture requirement,
|
| // either play if we meet the visibility checks, or install a listener
|
| - // to wait for them to pass.
|
| + // to wait for them to pass. We do not actually start playback; our
|
| + // caller must do that.
|
| if (isEligible()) {
|
| if (meetsVisibilityRequirements())
|
| - prepareToPlay(GesturelessPlaybackStartedByAutoplayFlagImmediately);
|
| + prepareToAutoplay(GesturelessPlaybackStartedByAutoplayFlagImmediately);
|
| else
|
| registerForPositionUpdatesIfNeeded();
|
| }
|
| @@ -70,7 +71,6 @@ void AutoplayExperimentHelper::playMethodCalled()
|
| m_playPending = true;
|
|
|
| if (!UserGestureIndicator::processingUserGesture()) {
|
| -
|
| if (isEligible()) {
|
| // Remember that userGestureRequiredForPlay is required for
|
| // us to be eligible for the experiment.
|
| @@ -78,13 +78,12 @@ void AutoplayExperimentHelper::playMethodCalled()
|
| // do so. Otherwise, install an event listener if we need one.
|
| if (meetsVisibilityRequirements()) {
|
| // Override the gesture and play.
|
| - prepareToPlay(GesturelessPlaybackStartedByPlayMethodImmediately);
|
| + prepareToAutoplay(GesturelessPlaybackStartedByPlayMethodImmediately);
|
| } else {
|
| // Wait for viewport visibility.
|
| registerForPositionUpdatesIfNeeded();
|
| }
|
| }
|
| -
|
| } else if (element().isUserGestureRequiredForPlay()) {
|
| unregisterForPositionUpdatesIfNeeded();
|
| }
|
| @@ -255,9 +254,13 @@ bool AutoplayExperimentHelper::maybeStartPlaying()
|
| }
|
|
|
| // Start playing!
|
| - prepareToPlay(element().shouldAutoplay()
|
| + prepareToAutoplay(element().shouldAutoplay()
|
| ? GesturelessPlaybackStartedByAutoplayFlagAfterScroll
|
| : GesturelessPlaybackStartedByPlayMethodAfterScroll);
|
| +
|
| + // Record that this played without a user gesture.
|
| + element().autoplayMediaEncountered();
|
| +
|
| element().playInternal();
|
|
|
| return true;
|
| @@ -313,22 +316,18 @@ void AutoplayExperimentHelper::muteIfNeeded()
|
| }
|
| }
|
|
|
| -void AutoplayExperimentHelper::prepareToPlay(AutoplayMetrics metric)
|
| +void AutoplayExperimentHelper::prepareToAutoplay(AutoplayMetrics metric)
|
| {
|
| - element().recordAutoplayMetric(metric);
|
| -
|
| // This also causes !isEligible, so that we don't allow autoplay more than
|
| // once. Be sure to do this before muteIfNeeded().
|
| - element().removeUserGestureRequirement();
|
| + element().removeUserGestureRequirement(metric);
|
| +
|
| + // Don't bother to call autoplayMediaEncountered, since whoever initiates
|
| + // playback has do it anyway, in case we don't allow autoplay.
|
|
|
| unregisterForPositionUpdatesIfNeeded();
|
| muteIfNeeded();
|
|
|
| - // Record that this autoplayed without a user gesture. This is normally
|
| - // set when we discover an autoplay attribute, but we include all cases
|
| - // where playback started without a user gesture, e.g., play().
|
| - element().setInitialPlayWithoutUserGestures(true);
|
| -
|
| // Do not actually start playback here.
|
| }
|
|
|
|
|