Unverified Commit 2ec2e7e7 authored by Matthew Finkel's avatar Matthew Finkel
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
parent 0ad6c6a3
Loading
Loading
Loading
Loading
+18 −0
Original line number Diff line number Diff line
@@ -634,6 +634,22 @@ class GeckoEngine(
        override var enterpriseRootsEnabled: Boolean
            get() = runtime.settings.enterpriseRootsEnabled
            set(value) { runtime.settings.enterpriseRootsEnabled = value }

        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()
                }
            }
    }.apply {
        defaultSettings?.let {
            this.javascriptEnabled = it.javascriptEnabled
@@ -652,6 +668,8 @@ class GeckoEngine(
            this.clearColor = it.clearColor
            this.loginAutofillEnabled = it.loginAutofillEnabled
            this.enterpriseRootsEnabled = it.enterpriseRootsEnabled
            this.torSecurityLevel = it.torSecurityLevel
            this.spoofEnglish = it.spoofEnglish
        }
    }

+1 −0
Original line number Diff line number Diff line
@@ -88,6 +88,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)
    .build()

private fun WebRequest.Builder.addHeadersFrom(request: Request): WebRequest.Builder {
+2 −1
Original line number Diff line number Diff line
@@ -52,7 +52,8 @@ class HttpIconLoader(
            connectTimeout = Pair(CONNECT_TIMEOUT, TimeUnit.SECONDS),
            readTimeout = Pair(READ_TIMEOUT, TimeUnit.SECONDS),
            redirect = Request.Redirect.FOLLOW,
            useCaches = true)
            useCaches = true,
            origin = request.url)

        return try {
            val response = httpClient.fetch(downloadRequest)
+10 −1
Original line number Diff line number Diff line
@@ -184,6 +184,13 @@ abstract class Settings {
     * Setting to control whether enterprise root certs are enabled.
     */
    open var enterpriseRootsEnabled: Boolean by UnsupportedSetting()

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

    open var spoofEnglish: Boolean by UnsupportedSetting()
}

/**
@@ -220,7 +227,9 @@ data class DefaultSettings(
    override var forceUserScalableContent: Boolean = false,
    override var loginAutofillEnabled: Boolean = false,
    override var clearColor: Int? = null,
    override var enterpriseRootsEnabled: Boolean = false
    override var enterpriseRootsEnabled: Boolean = false,
    override var torSecurityLevel: Int = 4,
    override var spoofEnglish: Boolean = false
) : Settings()

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