Commit 1358cf0c authored by Ian Clelland's avatar Ian Clelland Committed by Commit Bot

Move Autoplay feature policy checks to Document

Bug: 888668
Change-Id: I1ba1e04b8f5853e449d8a1316f6322d5839ed1b5
Reviewed-on: https://chromium-review.googlesource.com/c/1243524Reviewed-by: default avatarMounir Lamouri <mlamouri@chromium.org>
Commit-Queue: Ian Clelland <iclelland@chromium.org>
Cr-Commit-Position: refs/heads/master@{#596503}
parent d03b4549
......@@ -109,6 +109,9 @@ bool AutoplayPolicy::IsDocumentAllowedToPlay(const Document& document) {
if (!document.GetFrame())
return false;
bool feature_policy_enabled =
document.IsFeatureEnabled(mojom::FeaturePolicyFeature::kAutoplay);
for (Frame* frame = document.GetFrame(); frame;
frame = frame->Tree().Parent()) {
if (frame->HasBeenActivated() ||
......@@ -122,10 +125,8 @@ bool AutoplayPolicy::IsDocumentAllowedToPlay(const Document& document) {
return true;
}
if (!frame->DeprecatedIsFeatureEnabled(
mojom::FeaturePolicyFeature::kAutoplay)) {
if (!feature_policy_enabled)
return false;
}
}
return false;
......@@ -439,16 +440,19 @@ void AutoplayPolicy::MaybeSetAutoplayInitiated() {
return;
autoplay_initiated_ = true;
for (Frame* frame = element_->GetDocument().GetFrame(); frame;
const Document& document = element_->GetDocument();
bool feature_policy_enabled =
document.IsFeatureEnabled(mojom::FeaturePolicyFeature::kAutoplay);
for (Frame* frame = document.GetFrame(); frame;
frame = frame->Tree().Parent()) {
if (frame->HasBeenActivated() ||
frame->HasReceivedUserGestureBeforeNavigation()) {
autoplay_initiated_ = false;
break;
}
if (!frame->DeprecatedIsFeatureEnabled(
mojom::FeaturePolicyFeature::kAutoplay))
if (!feature_policy_enabled)
break;
}
}
......
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