Verified Commit a52d3674 authored by Matthew Finkel's avatar Matthew Finkel Committed by Pier Angelo Vendrame
Browse files

Add support for new GeckoView interfaces

Bug 40006: Expose Security Level interface

Bug 40019: Expose spoofEnglish pref

Bug 34439: Isolate Icon loader on Android

Bug 41394: Expose privacy.prioritizeonions.enabled to Android.
parent e1ea75a0
Loading
Loading
Loading
Loading
+26 −0
Original line number Diff line number Diff line
@@ -780,6 +780,29 @@ class GeckoEngine(
                    Engine.HttpsOnlyMode.ENABLED -> GeckoRuntimeSettings.HTTPS_ONLY
                }
            }

        override var torSecurityLevel: Int
            get() = runtime.settings.torSecurityLevel
            set(value) {
                value.let {
                    runtime.settings.torSecurityLevel = it
                }
            }
        override var spoofEnglish: Boolean
            get() = runtime.settings.spoofEnglish
            set(value) {
                value.let {
                    runtime.settings.spoofEnglish = it
                    localeUpdater.updateValue()
                }
            }
        override var prioritizeOnions: Boolean
            get() = runtime.settings.prioritizeOnions
            set(value) {
                value.let {
                    runtime.settings.prioritizeOnions = it
                }
            }
    }.apply {
        defaultSettings?.let {
            this.javascriptEnabled = it.javascriptEnabled
@@ -802,6 +825,9 @@ class GeckoEngine(
            this.cookieBannerHandlingMode = it.cookieBannerHandlingMode
            this.cookieBannerHandlingModePrivateBrowsing = it.cookieBannerHandlingModePrivateBrowsing
            this.cookieBannerHandlingDetectOnlyMode = it.cookieBannerHandlingDetectOnlyMode
            this.torSecurityLevel = it.torSecurityLevel
            this.spoofEnglish = it.spoofEnglish
            this.prioritizeOnions = it.prioritizeOnions
        }
    }

+1 −0
Original line number Diff line number Diff line
@@ -87,6 +87,7 @@ private fun Request.toWebRequest(): WebRequest = WebRequest.Builder(url)
    .addHeadersFrom(this)
    .addBodyFrom(this)
    .cacheMode(if (useCaches) CACHE_MODE_DEFAULT else CACHE_MODE_RELOAD)
    .origin(origin)
    // Turn off bleeding-edge network features to avoid breaking core browser functionality.
    .beConservative(true)
    .build()
+1 −0
Original line number Diff line number Diff line
@@ -58,6 +58,7 @@ open class HttpIconLoader(
            redirect = Request.Redirect.FOLLOW,
            useCaches = true,
            private = request.isPrivate,
            origin = request.url
        )

        return try {
+12 −0
Original line number Diff line number Diff line
@@ -205,6 +205,15 @@ abstract class Settings {
     * Setting the HTTPS-Only mode for upgrading connections to HTTPS.
     */
    open var httpsOnlyMode: Engine.HttpsOnlyMode by UnsupportedSetting()

    /**
     * Setting to control the current security level
     */
    open var torSecurityLevel: Int by UnsupportedSetting()

    open var spoofEnglish: Boolean by UnsupportedSetting()

    open var prioritizeOnions: Boolean by UnsupportedSetting()
}

/**
@@ -247,6 +256,9 @@ data class DefaultSettings(
    override var cookieBannerHandlingModePrivateBrowsing: CookieBannerHandlingMode =
        CookieBannerHandlingMode.DISABLED,
    override var cookieBannerHandlingDetectOnlyMode: Boolean = false,
    override var torSecurityLevel: Int = 4,
    override var spoofEnglish: Boolean = false,
    override var prioritizeOnions: Boolean = false,
) : Settings()

class UnsupportedSetting<T> {
+1 −0
Original line number Diff line number Diff line
@@ -49,6 +49,7 @@ data class Request(
    val cookiePolicy: CookiePolicy = CookiePolicy.INCLUDE,
    val useCaches: Boolean = true,
    val private: Boolean = false,
    val origin: String? = null,
) {
    /**
     * A [Body] to be send with the [Request].