From e63680b41db4f8e07e331d35705ab4ab8b498501 Mon Sep 17 00:00:00 2001 From: Jonathan Almeida Date: Thu, 18 Feb 2021 13:06:20 +0400 Subject: [PATCH] Update to AC 72.0.15 and GeckoView 86.0.20210217195321 --- .../main/java/org/mozilla/focus/Components.kt | 5 ++++ .../mozilla/focus/web/GeckoWebViewProvider.kt | 25 ++++++++++++++----- build.gradle | 4 +-- 3 files changed, 26 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/org/mozilla/focus/Components.kt b/app/src/main/java/org/mozilla/focus/Components.kt index 413c7687239..76495dae1af 100644 --- a/app/src/main/java/org/mozilla/focus/Components.kt +++ b/app/src/main/java/org/mozilla/focus/Components.kt @@ -6,6 +6,7 @@ package org.mozilla.focus import android.content.Context import android.util.AttributeSet +import android.util.JsonReader import mozilla.components.browser.search.SearchEngineManager import mozilla.components.browser.search.provider.AssetsSearchEngineProvider import mozilla.components.browser.search.provider.localization.LocaleSearchLocalizationProvider @@ -77,6 +78,10 @@ private class DummyEngine : Engine { throw NotImplementedError() } + override fun createSessionStateFrom(reader: JsonReader): EngineSessionState { + throw NotImplementedError() + } + override fun createView(context: Context, attrs: AttributeSet?): EngineView { throw NotImplementedError() } diff --git a/app/src/main/java/org/mozilla/focus/web/GeckoWebViewProvider.kt b/app/src/main/java/org/mozilla/focus/web/GeckoWebViewProvider.kt index 3066d3ce3f0..80314d182a1 100644 --- a/app/src/main/java/org/mozilla/focus/web/GeckoWebViewProvider.kt +++ b/app/src/main/java/org/mozilla/focus/web/GeckoWebViewProvider.kt @@ -24,7 +24,11 @@ import kotlinx.coroutines.Job import mozilla.components.browser.errorpages.ErrorPages import mozilla.components.browser.errorpages.ErrorType import mozilla.components.browser.session.Session +import mozilla.components.concept.fetch.Headers.Names.CONTENT_DISPOSITION +import mozilla.components.concept.fetch.Headers.Names.CONTENT_LENGTH +import mozilla.components.concept.fetch.Headers.Names.CONTENT_TYPE import mozilla.components.lib.crash.handler.CrashHandlerService +import mozilla.components.support.utils.DownloadUtils import org.mozilla.focus.R import org.mozilla.focus.browser.LocalizedContent import org.mozilla.focus.ext.savedGeckoSession @@ -47,6 +51,7 @@ import org.mozilla.geckoview.GeckoSession.NavigationDelegate import org.mozilla.geckoview.GeckoSessionSettings import org.mozilla.geckoview.SessionFinder import org.mozilla.geckoview.WebRequestError +import org.mozilla.geckoview.WebResponse import kotlin.coroutines.CoroutineContext /** @@ -377,10 +382,7 @@ class GeckoWebViewProvider : IWebViewProvider { } } - override fun onExternalResponse( - session: GeckoSession, - response: GeckoSession.WebResponseInfo - ) { + override fun onExternalResponse(session: GeckoSession, response: WebResponse) { if (!AppConstants.supportsDownloadingFiles()) { return } @@ -394,10 +396,21 @@ class GeckoWebViewProvider : IWebViewProvider { return } + val contentType = response.headers[CONTENT_TYPE]?.trim() + val contentLength = response.headers[CONTENT_LENGTH]?.trim()?.toLong() ?: 0 + val contentDisposition = response.headers[CONTENT_DISPOSITION]?.trim() + val url = response.uri + val fileName = DownloadUtils.guessFileName( + contentDisposition, + destinationDirectory = null, + url = url, + mimeType = contentType + ) + val download = Download( response.uri, USER_AGENT, - response.filename, response.contentType, response.contentLength, - Environment.DIRECTORY_DOWNLOADS, response.filename + fileName, contentType, contentLength, + Environment.DIRECTORY_DOWNLOADS, fileName ) callback?.onDownloadStart(download) } diff --git a/build.gradle b/build.gradle index 980d44ba07b..f1eef9aa90f 100644 --- a/build.gradle +++ b/build.gradle @@ -6,8 +6,8 @@ buildscript { ext.espresso_version = '3.1.0-alpha4' ext.kotlin_version = '1.3.61' ext.coroutines_version = '1.3.0' - ext.gecko_release_version = '85.0.20210118153634' - ext.mozilla_components_version = '70.0.15' + ext.gecko_release_version = '86.0.20210217195321' + ext.mozilla_components_version = '72.0.15' // Pinning the last working version of the service-telemetry component until we decide // what we want to do with telemetry in the app. ext.mozilla_components_version_telemetry = '57.0.9'