Skip to content
This repository has been archived by the owner on Nov 1, 2022. It is now read-only.

Closes #6027 Add support for video autoplay permissions #5953

Merged
merged 2 commits into from
Feb 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,13 @@ class GeckoEngine(
* See [Engine.settings]
*/
override val settings: Settings = object : Settings() {

init {
// `autoplayDefault` has been removed from GV nightly, but for now it must be set to
// `allowed` in order for site specific autoplay permissions to work.
runtime.settings.autoplayDefault = GeckoRuntimeSettings.AUTOPLAY_DEFAULT_ALLOWED
}

override var javascriptEnabled: Boolean
get() = runtime.settings.javaScriptEnabled
set(value) { runtime.settings.javaScriptEnabled = value }
Expand Down Expand Up @@ -538,16 +545,6 @@ class GeckoEngine(
get() = PreferredColorScheme.from(runtime.settings.preferredColorScheme)
set(value) { runtime.settings.preferredColorScheme = value.toGeckoValue() }

override var allowAutoplayMedia: Boolean
get() = runtime.settings.autoplayDefault == GeckoRuntimeSettings.AUTOPLAY_DEFAULT_ALLOWED
set(value) {
runtime.settings.autoplayDefault = if (value) {
GeckoRuntimeSettings.AUTOPLAY_DEFAULT_ALLOWED
} else {
GeckoRuntimeSettings.AUTOPLAY_DEFAULT_BLOCKED
}
}

override var suspendMediaWhenInactive: Boolean
get() = defaultSettings?.suspendMediaWhenInactive ?: false
set(value) { defaultSettings?.suspendMediaWhenInactive = value }
Expand Down Expand Up @@ -594,7 +591,6 @@ class GeckoEngine(
this.testingModeEnabled = it.testingModeEnabled
this.userAgentString = it.userAgentString
this.preferredColorScheme = it.preferredColorScheme
this.allowAutoplayMedia = it.allowAutoplayMedia
this.suspendMediaWhenInactive = it.suspendMediaWhenInactive
this.fontInflationEnabled = it.fontInflationEnabled
this.fontSizeFactor = it.fontSizeFactor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import org.mozilla.geckoview.GeckoSession.PermissionDelegate.MediaSource.SOURCE_
import org.mozilla.geckoview.GeckoSession.PermissionDelegate.MediaSource.SOURCE_MICROPHONE
import org.mozilla.geckoview.GeckoSession.PermissionDelegate.MediaSource.SOURCE_OTHER
import org.mozilla.geckoview.GeckoSession.PermissionDelegate.MediaSource.SOURCE_SCREEN
import org.mozilla.geckoview.GeckoSession.PermissionDelegate.PERMISSION_AUTOPLAY_AUDIBLE
import org.mozilla.geckoview.GeckoSession.PermissionDelegate.PERMISSION_AUTOPLAY_INAUDIBLE
import org.mozilla.geckoview.GeckoSession.PermissionDelegate.PERMISSION_DESKTOP_NOTIFICATION
import org.mozilla.geckoview.GeckoSession.PermissionDelegate.PERMISSION_GEOLOCATION

Expand Down Expand Up @@ -50,7 +52,9 @@ sealed class GeckoPermissionRequest constructor(
companion object {
val permissionsMap = mapOf(
PERMISSION_DESKTOP_NOTIFICATION to Permission.ContentNotification(),
PERMISSION_GEOLOCATION to Permission.ContentGeoLocation()
PERMISSION_GEOLOCATION to Permission.ContentGeoLocation(),
PERMISSION_AUTOPLAY_AUDIBLE to Permission.ContentAutoPlayAudible(),
PERMISSION_AUTOPLAY_INAUDIBLE to Permission.ContentAutoPlayInaudible()
)
}
}
Expand Down
Loading