From a599bcafe96fbaf9ed1889f8b9cf77b6d37ec6d8 Mon Sep 17 00:00:00 2001 From: Anthony Tseng Date: Mon, 18 Dec 2017 15:26:54 -0800 Subject: [PATCH] 1. Audio element should also repect auotplay setting fix brave/browser-laptop#11988 fix brave/browser-laptop#11527 2. Don't check user initiated video fix brave/browser-laptop#12149 3. Default allow muted media fix brave/browser-laptop#12152 4. Default allow for local files fix brave/browser-laptop#8929 Auditors: @bridiver, @bbondy, @bsclifton --- patches/master_patch.patch | 65 ++++++++++++++++++++------------------ 1 file changed, 35 insertions(+), 30 deletions(-) diff --git a/patches/master_patch.patch b/patches/master_patch.patch index b6e08b5911..671843f5ae 100644 --- a/patches/master_patch.patch +++ b/patches/master_patch.patch @@ -1893,46 +1893,51 @@ index 19c7b569f19849f8fbb26c1faf2ac52f8fe7c566..0294416a183a13cd925adf89dd587289 if (GetWebMediaPlayer()) GetWebMediaPlayer()->SetVolume(EffectiveMediaVolume()); diff --git a/third_party/WebKit/Source/core/html/media/AutoplayPolicy.cpp b/third_party/WebKit/Source/core/html/media/AutoplayPolicy.cpp -index 9162bc3ba51153a494aa218007511054cdebbad7..e685ea161db22661d3a643cd37df8924c4439d15 100644 +index 9162bc3ba51153a494aa218007511054cdebbad7..929da1fa1cd6ed005f219f5855d65edf1662fa4a 100644 --- a/third_party/WebKit/Source/core/html/media/AutoplayPolicy.cpp +++ b/third_party/WebKit/Source/core/html/media/AutoplayPolicy.cpp -@@ -264,6 +264,11 @@ void AutoplayPolicy::UnlockUserGesture() { - } - - bool AutoplayPolicy::IsGestureNeededForPlayback() const { -+ // MUON(darkdh): check autoplay setting -+ if (!IsAutoplayAllowedPerSettings()) { -+ return true; -+ } -+ - if (!IsLockedPendingUserGesture()) +@@ -275,11 +275,20 @@ bool AutoplayPolicy::IsGestureNeededForPlaybackIfPendingUserGestureIsLocked() + if (element_->GetLoadType() == WebMediaPlayer::kLoadTypeMediaStream) return false; -@@ -280,14 +285,16 @@ bool AutoplayPolicy::IsGestureNeededForPlaybackIfPendingUserGestureIsLocked() ++ // MUON(darkdh): default allow local files ++ if (element_->GetDocument().origin() == String("null")) ++ return false; ++ ++ if ((element_->IsHTMLVideoElement() && element_->muted() && ++ RuntimeEnabledFeatures::AutoplayMutedVideosEnabled())) ++ return false; ++ + // We want to allow muted video to autoplay if: + // - the flag is enabled; // - Data Saver is not enabled; // - Preload was not disabled (low end devices); // - Autoplay is enabled in settings; -- if (element_->IsHTMLVideoElement() && element_->muted() && -- RuntimeEnabledFeatures::AutoplayMutedVideosEnabled() && -- !(element_->GetDocument().GetSettings() && -- element_->GetDocument().GetSettings()->GetDataSaverEnabled()) && -- !(element_->GetDocument().GetSettings() && -- element_->GetDocument() -- .GetSettings() -- ->GetForcePreloadNoneForMediaElements()) && -+ // if (element_->IsHTMLVideoElement() && element_->muted() && -+ // RuntimeEnabledFeatures::AutoplayMutedVideosEnabled() && -+ // !(element_->GetDocument().GetSettings() && -+ // element_->GetDocument().GetSettings()->GetDataSaverEnabled()) && -+ // !(element_->GetDocument().GetSettings() && -+ // element_->GetDocument() -+ // .GetSettings() -+ // ->GetForcePreloadNoneForMediaElements()) && -+ // MUON(darkdh): only check autoplay setting -+ if (element_->IsHTMLVideoElement() && ++ // MUON(darkdh): don't check autoplay setting for muted video + if (element_->IsHTMLVideoElement() && element_->muted() && + RuntimeEnabledFeatures::AutoplayMutedVideosEnabled() && + !(element_->GetDocument().GetSettings() && +@@ -287,11 +296,20 @@ bool AutoplayPolicy::IsGestureNeededForPlaybackIfPendingUserGestureIsLocked() + !(element_->GetDocument().GetSettings() && + element_->GetDocument() + .GetSettings() ++#if defined(MUON_CHROMIUM_BUILD) + ->GetForcePreloadNoneForMediaElements()) && IsAutoplayAllowedPerSettings()) { ++#else ++ ->GetForcePreloadNoneForMediaElements())) { ++#endif return false; } + ++ // MUON(darkdh): check autoplay setting for media element ++ if ((element_->IsHTMLVideoElement() || element_->IsAudioElement()) && ++ IsAutoplayAllowedPerSettings()) ++ return false; ++ + return true; + } + diff --git a/third_party/WebKit/Source/platform/bindings/V8PerIsolateData.cpp b/third_party/WebKit/Source/platform/bindings/V8PerIsolateData.cpp index 7ee2fa858b93e1dd42ac27f982fb61eaf597aad4..b1c96c229077859865fd5ea03cdbd7747880e216 100644 --- a/third_party/WebKit/Source/platform/bindings/V8PerIsolateData.cpp