From cbd811dcfb30c0333a110eedbe52b67b20d76360 Mon Sep 17 00:00:00 2001 From: Tiger Oakes Date: Fri, 2 Aug 2019 20:28:30 -0400 Subject: [PATCH] Closes #1657 - Use Gecko for downloads (#4296) --- app/src/main/AndroidManifest.xml | 1 + .../org/mozilla/fenix/browser/BrowserFragment.kt | 5 ++++- .../org/mozilla/fenix/downloads/DownloadService.kt | 12 ++++++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 app/src/main/java/org/mozilla/fenix/downloads/DownloadService.kt diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 2976ff0c8..8e44fce5f 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -108,6 +108,7 @@ + diff --git a/app/src/main/java/org/mozilla/fenix/browser/BrowserFragment.kt b/app/src/main/java/org/mozilla/fenix/browser/BrowserFragment.kt index ef7362272..a7c3bf8a8 100644 --- a/app/src/main/java/org/mozilla/fenix/browser/BrowserFragment.kt +++ b/app/src/main/java/org/mozilla/fenix/browser/BrowserFragment.kt @@ -37,6 +37,7 @@ import mozilla.components.browser.session.SessionManager import mozilla.components.feature.app.links.AppLinksFeature import mozilla.components.feature.contextmenu.ContextMenuFeature import mozilla.components.feature.downloads.DownloadsFeature +import mozilla.components.feature.downloads.manager.FetchDownloadManager import mozilla.components.feature.intent.IntentProcessor import mozilla.components.feature.prompts.PromptFeature import mozilla.components.feature.readerview.ReaderViewFeature @@ -74,6 +75,7 @@ import org.mozilla.fenix.components.toolbar.QuickActionSheetAction import org.mozilla.fenix.components.toolbar.QuickActionSheetState import org.mozilla.fenix.components.toolbar.ToolbarIntegration import org.mozilla.fenix.customtabs.CustomTabsIntegration +import org.mozilla.fenix.downloads.DownloadService import org.mozilla.fenix.ext.components import org.mozilla.fenix.ext.enterToImmersiveMode import org.mozilla.fenix.ext.nav @@ -271,10 +273,11 @@ class BrowserFragment : Fragment(), BackHandler { downloadsFeature.set( feature = DownloadsFeature( - requireContext(), + requireContext().applicationContext, sessionManager = sessionManager, fragmentManager = childFragmentManager, sessionId = customTabSessionId, + downloadManager = FetchDownloadManager(requireContext().applicationContext, DownloadService::class), onNeedToRequestPermissions = { permissions -> requestPermissions(permissions, REQUEST_CODE_DOWNLOAD_PERMISSIONS) }), diff --git a/app/src/main/java/org/mozilla/fenix/downloads/DownloadService.kt b/app/src/main/java/org/mozilla/fenix/downloads/DownloadService.kt new file mode 100644 index 000000000..9cbb92a0f --- /dev/null +++ b/app/src/main/java/org/mozilla/fenix/downloads/DownloadService.kt @@ -0,0 +1,12 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +package org.mozilla.fenix.downloads + +import mozilla.components.feature.downloads.AbstractFetchDownloadService +import org.mozilla.fenix.ext.components + +class DownloadService : AbstractFetchDownloadService() { + override val httpClient by lazy { components.core.client } +}