Skip to content
This repository was archived by the owner on Jan 4, 2019. It is now read-only.

Commit a599bca

Browse files
committed
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
1 parent 02ef956 commit a599bca

File tree

1 file changed

+35
-30
lines changed

1 file changed

+35
-30
lines changed

patches/master_patch.patch

+35-30
Original file line numberDiff line numberDiff line change
@@ -1893,46 +1893,51 @@ index 19c7b569f19849f8fbb26c1faf2ac52f8fe7c566..0294416a183a13cd925adf89dd587289
18931893
if (GetWebMediaPlayer())
18941894
GetWebMediaPlayer()->SetVolume(EffectiveMediaVolume());
18951895
diff --git a/third_party/WebKit/Source/core/html/media/AutoplayPolicy.cpp b/third_party/WebKit/Source/core/html/media/AutoplayPolicy.cpp
1896-
index 9162bc3ba51153a494aa218007511054cdebbad7..e685ea161db22661d3a643cd37df8924c4439d15 100644
1896+
index 9162bc3ba51153a494aa218007511054cdebbad7..929da1fa1cd6ed005f219f5855d65edf1662fa4a 100644
18971897
--- a/third_party/WebKit/Source/core/html/media/AutoplayPolicy.cpp
18981898
+++ b/third_party/WebKit/Source/core/html/media/AutoplayPolicy.cpp
1899-
@@ -264,6 +264,11 @@ void AutoplayPolicy::UnlockUserGesture() {
1900-
}
1901-
1902-
bool AutoplayPolicy::IsGestureNeededForPlayback() const {
1903-
+ // MUON(darkdh): check autoplay setting
1904-
+ if (!IsAutoplayAllowedPerSettings()) {
1905-
+ return true;
1906-
+ }
1907-
+
1908-
if (!IsLockedPendingUserGesture())
1899+
@@ -275,11 +275,20 @@ bool AutoplayPolicy::IsGestureNeededForPlaybackIfPendingUserGestureIsLocked()
1900+
if (element_->GetLoadType() == WebMediaPlayer::kLoadTypeMediaStream)
19091901
return false;
19101902

1911-
@@ -280,14 +285,16 @@ bool AutoplayPolicy::IsGestureNeededForPlaybackIfPendingUserGestureIsLocked()
1903+
+ // MUON(darkdh): default allow local files
1904+
+ if (element_->GetDocument().origin() == String("null"))
1905+
+ return false;
1906+
+
1907+
+ if ((element_->IsHTMLVideoElement() && element_->muted() &&
1908+
+ RuntimeEnabledFeatures::AutoplayMutedVideosEnabled()))
1909+
+ return false;
1910+
+
1911+
// We want to allow muted video to autoplay if:
1912+
// - the flag is enabled;
19121913
// - Data Saver is not enabled;
19131914
// - Preload was not disabled (low end devices);
19141915
// - Autoplay is enabled in settings;
1915-
- if (element_->IsHTMLVideoElement() && element_->muted() &&
1916-
- RuntimeEnabledFeatures::AutoplayMutedVideosEnabled() &&
1917-
- !(element_->GetDocument().GetSettings() &&
1918-
- element_->GetDocument().GetSettings()->GetDataSaverEnabled()) &&
1919-
- !(element_->GetDocument().GetSettings() &&
1920-
- element_->GetDocument()
1921-
- .GetSettings()
1922-
- ->GetForcePreloadNoneForMediaElements()) &&
1923-
+ // if (element_->IsHTMLVideoElement() && element_->muted() &&
1924-
+ // RuntimeEnabledFeatures::AutoplayMutedVideosEnabled() &&
1925-
+ // !(element_->GetDocument().GetSettings() &&
1926-
+ // element_->GetDocument().GetSettings()->GetDataSaverEnabled()) &&
1927-
+ // !(element_->GetDocument().GetSettings() &&
1928-
+ // element_->GetDocument()
1929-
+ // .GetSettings()
1930-
+ // ->GetForcePreloadNoneForMediaElements()) &&
1931-
+ // MUON(darkdh): only check autoplay setting
1932-
+ if (element_->IsHTMLVideoElement() &&
1916+
+ // MUON(darkdh): don't check autoplay setting for muted video
1917+
if (element_->IsHTMLVideoElement() && element_->muted() &&
1918+
RuntimeEnabledFeatures::AutoplayMutedVideosEnabled() &&
1919+
!(element_->GetDocument().GetSettings() &&
1920+
@@ -287,11 +296,20 @@ bool AutoplayPolicy::IsGestureNeededForPlaybackIfPendingUserGestureIsLocked()
1921+
!(element_->GetDocument().GetSettings() &&
1922+
element_->GetDocument()
1923+
.GetSettings()
1924+
+#if defined(MUON_CHROMIUM_BUILD)
1925+
->GetForcePreloadNoneForMediaElements()) &&
19331926
IsAutoplayAllowedPerSettings()) {
1927+
+#else
1928+
+ ->GetForcePreloadNoneForMediaElements())) {
1929+
+#endif
19341930
return false;
19351931
}
1932+
1933+
+ // MUON(darkdh): check autoplay setting for media element
1934+
+ if ((element_->IsHTMLVideoElement() || element_->IsAudioElement()) &&
1935+
+ IsAutoplayAllowedPerSettings())
1936+
+ return false;
1937+
+
1938+
return true;
1939+
}
1940+
19361941
diff --git a/third_party/WebKit/Source/platform/bindings/V8PerIsolateData.cpp b/third_party/WebKit/Source/platform/bindings/V8PerIsolateData.cpp
19371942
index 7ee2fa858b93e1dd42ac27f982fb61eaf597aad4..b1c96c229077859865fd5ea03cdbd7747880e216 100644
19381943
--- a/third_party/WebKit/Source/platform/bindings/V8PerIsolateData.cpp

0 commit comments

Comments
 (0)