Unverified Commit 4b13cad9 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 9a5d1216
......@@ -586,6 +586,22 @@ class GeckoEngine(
override var forceUserScalableContent: Boolean
get() = runtime.settings.forceUserScalableEnabled
set(value) { runtime.settings.forceUserScalableEnabled = 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
......@@ -603,6 +619,8 @@ class GeckoEngine(
this.forceUserScalableContent = it.forceUserScalableContent
this.clearColor = it.clearColor
this.loginAutofillEnabled = it.loginAutofillEnabled
this.torSecurityLevel = it.torSecurityLevel
this.spoofEnglish = it.spoofEnglish
}
}
......
......@@ -80,6 +80,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 {
......
......@@ -599,6 +599,22 @@ class GeckoEngine(
override var forceUserScalableContent: Boolean
get() = runtime.settings.forceUserScalableEnabled
set(value) { runtime.settings.forceUserScalableEnabled = 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
......@@ -616,6 +632,8 @@ class GeckoEngine(
this.forceUserScalableContent = it.forceUserScalableContent
this.clearColor = it.clearColor
this.loginAutofillEnabled = it.loginAutofillEnabled
this.torSecurityLevel = it.torSecurityLevel
this.spoofEnglish = it.spoofEnglish
}
}
......
......@@ -80,6 +80,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 {
......
......@@ -51,7 +51,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)
......
......@@ -179,6 +179,13 @@ abstract class Settings {
* Setting to control the clear color while drawing.
*/
open var clearColor: Int? by UnsupportedSetting()
/**
* Setting to control the current security level
*/
open var torSecurityLevel: Int by UnsupportedSetting()
open var spoofEnglish: Boolean by UnsupportedSetting()
}
/**
......@@ -214,7 +221,9 @@ data class DefaultSettings(
override var fontSizeFactor: Float? = null,
override var forceUserScalableContent: Boolean = false,
override var loginAutofillEnabled: Boolean = false,
override var clearColor: Int? = null
override var clearColor: Int? = null,
override var torSecurityLevel: Int = 4,
override var spoofEnglish: Boolean = false
) : Settings()
class UnsupportedSetting<T> {
......
......@@ -46,7 +46,8 @@ data class Request(
val body: Body? = null,
val redirect: Redirect = Redirect.FOLLOW,
val cookiePolicy: CookiePolicy = CookiePolicy.INCLUDE,
val useCaches: Boolean = true
val useCaches: Boolean = true,
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