From a6243384bc87548fd91fef5593f569c53750563b Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Tue, 29 Aug 2017 13:49:54 -0400 Subject: Miscellaneous fixes (#223) * Disable js dialogs for headless webviews * Update logging * Fix sharing theme * Add buddylist to drawer and theme update * Blacklist sharer.php from launching in overlay * Add whitelist for message related links --- .../pitchedapps/frost/web/FrostChromeClients.kt | 24 ++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) (limited to 'app/src/main/kotlin/com/pitchedapps/frost/web/FrostChromeClients.kt') diff --git a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostChromeClients.kt b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostChromeClients.kt index 386c5339..b469659b 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostChromeClients.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostChromeClients.kt @@ -19,10 +19,27 @@ import io.reactivex.subjects.Subject */ /** - * Nothing more than a client without logging + * Fully quiet client that disables any prompts relating to the UI + * (as nothing is attached) */ -class QuietChromeClient : WebChromeClient() { +class HeadlessChromeClient : WebChromeClient() { + override fun onConsoleMessage(consoleMessage: ConsoleMessage) = true + + override fun onJsAlert(view: WebView, url: String?, message: String?, result: JsResult): Boolean { + result.cancel() + return true + } + + override fun onJsConfirm(view: WebView, url: String?, message: String?, result: JsResult): Boolean { + result.cancel() + return true + } + + override fun onJsPrompt(view: WebView, url: String?, message: String?, defaultValue: String?, result: JsPromptResult): Boolean { + result.cancel() + return true + } } /** @@ -59,8 +76,7 @@ class FrostChromeClient(webCore: FrostWebViewCore) : WebChromeClient() { override fun onGeolocationPermissionsShowPrompt(origin: String, callback: GeolocationPermissions.Callback) { L.i("Requesting geolocation") - context.kauRequestPermissions(PERMISSION_ACCESS_FINE_LOCATION) { - granted, _ -> + context.kauRequestPermissions(PERMISSION_ACCESS_FINE_LOCATION) { granted, _ -> L.i("Geolocation response received; ${if (granted) "granted" else "denied"}") callback(origin, granted, true) } -- cgit v1.2.3