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

Commit

Permalink
1. Audio element should also repect auotplay setting
Browse files Browse the repository at this point in the history
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
  • Loading branch information
darkdh committed Dec 21, 2017
1 parent 02ef956 commit 8a54a8f
Showing 1 changed file with 17 additions and 32 deletions.
49 changes: 17 additions & 32 deletions patches/master_patch.patch
Original file line number Diff line number Diff line change
Expand Up @@ -1893,43 +1893,28 @@ 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..9c3e62b6285ec8cae7de7f0c32d904aa3f406b3e 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())
return false;

@@ -280,14 +285,16 @@ bool AutoplayPolicy::IsGestureNeededForPlaybackIfPendingUserGestureIsLocked()
@@ -280,6 +280,7 @@ bool AutoplayPolicy::IsGestureNeededForPlaybackIfPendingUserGestureIsLocked()
// - 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() &&
+#if defined(MUON_CHROMIUM_BUILD)
if (element_->IsHTMLVideoElement() && element_->muted() &&
RuntimeEnabledFeatures::AutoplayMutedVideosEnabled() &&
!(element_->GetDocument().GetSettings() &&
@@ -288,6 +289,13 @@ bool AutoplayPolicy::IsGestureNeededForPlaybackIfPendingUserGestureIsLocked()
element_->GetDocument()
.GetSettings()
->GetForcePreloadNoneForMediaElements()) &&
+#else
+ // MUON(darkdh): default allow muted media and local files
+ // only check autoplay setting for non-muted and non-local one
+ if ((element_->IsHTMLVideoElement() || element_->IsAudioElement()) &&
+ element_->muted() ||
+ element_->GetDocument().origin() == String("null") ||
+#endif
IsAutoplayAllowedPerSettings()) {
return false;
}
Expand Down

0 comments on commit 8a54a8f

Please sign in to comment.