Verified Commit 7112ccfc authored by Matthew Finkel's avatar Matthew Finkel Committed by aguestuser
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 37eba642
......@@ -687,6 +687,22 @@ 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()
}
}
}.apply {
defaultSettings?.let {
this.javascriptEnabled = it.javascriptEnabled
......@@ -706,6 +722,8 @@ class GeckoEngine(
this.loginAutofillEnabled = it.loginAutofillEnabled
this.enterpriseRootsEnabled = it.enterpriseRootsEnabled
this.httpsOnlyMode = it.httpsOnlyMode
this.torSecurityLevel = it.torSecurityLevel
this.spoofEnglish = it.spoofEnglish
}
}
......
......@@ -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)
.build()
private fun WebRequest.Builder.addHeadersFrom(request: Request): WebRequest.Builder {
......
......@@ -57,7 +57,8 @@ open class HttpIconLoader(
readTimeout = Pair(READ_TIMEOUT, TimeUnit.SECONDS),
redirect = Request.Redirect.FOLLOW,
useCaches = true,
private = request.isPrivate
private = request.isPrivate,
origin = request.url
)
return try {
......
......@@ -189,6 +189,13 @@ 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()
}
/**
......@@ -226,7 +233,9 @@ data class DefaultSettings(
override var loginAutofillEnabled: Boolean = false,
override var clearColor: Int? = null,
override var enterpriseRootsEnabled: Boolean = false,
override var httpsOnlyMode: Engine.HttpsOnlyMode = Engine.HttpsOnlyMode.DISABLED
override var httpsOnlyMode: Engine.HttpsOnlyMode = Engine.HttpsOnlyMode.DISABLED,
override var torSecurityLevel: Int = 4,
override var spoofEnglish: Boolean = false
) : Settings()
class UnsupportedSetting<T> {
......
......@@ -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].
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment