Commit 49bb4c72 authored by Becca Hughes's avatar Becca Hughes Committed by Commit Bot

[Autoplay] Remove AutoplayMutedVideos feature

Remove the AutoplayMutedVideos feature which is set based on
the autoplay policy command line switch. This means it
ignores if we have overridden the autoplay policy for the
document.

Instead we should perform this check in AutoplayPolicy
which will have the final autoplay policy for the
document.

BUG=865548

Change-Id: Iddfb9d0b3fef3bfa6efc493876094eaf2f8f7799
Reviewed-on: https://chromium-review.googlesource.com/1157215Reviewed-by: default avatarJochen Eisinger <jochen@chromium.org>
Reviewed-by: default avatarMounir Lamouri <mlamouri@chromium.org>
Commit-Queue: Becca Hughes <beccahughes@chromium.org>
Cr-Commit-Position: refs/heads/master@{#580649}
parent c1710c99
......@@ -46,7 +46,6 @@ static void SetRuntimeFeatureDefaultsForPlatform() {
WebRuntimeFeatures::EnableNotificationConstructor(false);
// Android does not yet support switching of audio output devices
WebRuntimeFeatures::EnableAudioOutputDevices(false);
WebRuntimeFeatures::EnableAutoplayMutedVideos(true);
// Android does not yet support SystemMonitor.
WebRuntimeFeatures::EnableOnDeviceChange(false);
WebRuntimeFeatures::EnableMediaSession(true);
......@@ -364,11 +363,6 @@ void SetRuntimeFeaturesDefaultsAndUpdateFromArgs(
WebRuntimeFeatures::EnableWebNfc(true);
#endif
if (media::GetEffectiveAutoplayPolicy(command_line) !=
switches::autoplay::kNoUserGestureRequiredPolicy) {
WebRuntimeFeatures::EnableAutoplayMutedVideos(true);
}
WebRuntimeFeatures::EnableWebAuth(
base::FeatureList::IsEnabled(features::kWebAuth));
......
......@@ -166,7 +166,6 @@ class WebRuntimeFeatures {
BLINK_PLATFORM_EXPORT static void EnableWebXRGamepadSupport(bool);
BLINK_PLATFORM_EXPORT static void EnableXSLT(bool);
BLINK_PLATFORM_EXPORT static void ForceOverlayFullscreenVideo(bool);
BLINK_PLATFORM_EXPORT static void EnableAutoplayMutedVideos(bool);
BLINK_PLATFORM_EXPORT static void EnableTimerThrottlingForBackgroundTabs(
bool);
BLINK_PLATFORM_EXPORT static void EnableTimerThrottlingForHiddenFrames(bool);
......
......@@ -4,6 +4,7 @@
#include "third_party/blink/renderer/core/html/media/autoplay_policy.h"
#include "build/build_config.h"
#include "third_party/blink/public/mojom/feature_policy/feature_policy.mojom-blink.h"
#include "third_party/blink/public/platform/autoplay.mojom-blink.h"
#include "third_party/blink/public/platform/web_media_player.h"
......@@ -134,6 +135,13 @@ bool AutoplayPolicy::DocumentHasForceAllowFlag(const Document& document) {
mojom::blink::kAutoplayFlagForceAllow;
}
// static
bool AutoplayPolicy::DocumentShouldAutoplayMutedVideos(
const Document& document) {
return GetAutoplayPolicyForDocument(document) !=
AutoplayPolicy::Type::kNoUserGestureRequired;
}
AutoplayPolicy::AutoplayPolicy(HTMLMediaElement* element)
: locked_pending_user_gesture_(false),
locked_pending_user_gesture_if_cross_origin_experiment_enabled_(true),
......@@ -169,7 +177,7 @@ void AutoplayPolicy::DidMoveToNewDocument(Document& old_document) {
bool AutoplayPolicy::IsEligibleForAutoplayMuted() const {
return element_->IsHTMLVideoElement() && element_->muted() &&
RuntimeEnabledFeatures::AutoplayMutedVideosEnabled();
DocumentShouldAutoplayMutedVideos(element_->GetDocument());
}
void AutoplayPolicy::StartAutoplayMutedWhenVisible() {
......@@ -288,7 +296,7 @@ bool AutoplayPolicy::IsOrWillBeAutoplayingMuted() const {
bool AutoplayPolicy::IsOrWillBeAutoplayingMutedInternal(bool muted) const {
if (!element_->IsHTMLVideoElement() ||
!RuntimeEnabledFeatures::AutoplayMutedVideosEnabled()) {
!DocumentShouldAutoplayMutedVideos(element_->GetDocument())) {
return false;
}
......@@ -349,7 +357,7 @@ bool AutoplayPolicy::IsGestureNeededForPlaybackIfPendingUserGestureIsLocked()
// - Preload was not disabled (low end devices);
// - Autoplay is enabled in settings;
if (element_->IsHTMLVideoElement() && element_->muted() &&
RuntimeEnabledFeatures::AutoplayMutedVideosEnabled() &&
DocumentShouldAutoplayMutedVideos(element_->GetDocument()) &&
!(element_->GetDocument().GetSettings() &&
GetNetworkStateNotifier().SaveDataEnabled() &&
!element_->GetDocument()
......
......@@ -49,6 +49,9 @@ class AutoplayPolicy final : public GarbageCollected<AutoplayPolicy> {
// Returns true if the given |document| should force allow autoplay.
static bool DocumentHasForceAllowFlag(const Document&);
// Returns true if the given |document| should autoplay muted videos.
static bool DocumentShouldAutoplayMutedVideos(const Document&);
explicit AutoplayPolicy(HTMLMediaElement*);
void VideoWillBeDrawnToCanvas() const;
......
......@@ -168,7 +168,8 @@ void AutoplayUmaHelper::OnAutoplayInitiated(AutoplaySource source) {
// Record if it will be blocked by Data Saver or Autoplay setting.
if (element_->IsHTMLVideoElement() && element_->muted() &&
RuntimeEnabledFeatures::AutoplayMutedVideosEnabled()) {
AutoplayPolicy::DocumentShouldAutoplayMutedVideos(
element_->GetDocument())) {
bool data_saver_enabled_for_autoplay =
GetNetworkStateNotifier().SaveDataEnabled() &&
element_->GetDocument().GetSettings() &&
......
......@@ -444,10 +444,6 @@ void WebRuntimeFeatures::EnableServiceWorkerScriptFullCodeCache(bool enable) {
RuntimeEnabledFeatures::SetServiceWorkerScriptFullCodeCacheEnabled(enable);
}
void WebRuntimeFeatures::EnableAutoplayMutedVideos(bool enable) {
RuntimeEnabledFeatures::SetAutoplayMutedVideosEnabled(enable);
}
void WebRuntimeFeatures::EnableTimerThrottlingForBackgroundTabs(bool enable) {
RuntimeEnabledFeatures::SetTimerThrottlingForBackgroundTabsEnabled(enable);
}
......
......@@ -116,10 +116,6 @@
name: "AutoplayIgnoresWebAudio",
settable_from_internals: true,
},
{
name: "AutoplayMutedVideos",
settable_from_internals: true,
},
{
name: "BackgroundFetch",
status: "experimental",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment