Commit a1f848a6 authored by Tiger Oakes's avatar Tiger Oakes Committed by Tiger Oakes
Browse files

Add flag for PWA support

parent 7a1ab2e2
......@@ -19,7 +19,8 @@ import mozilla.components.concept.engine.manifest.WebAppManifest
import mozilla.components.feature.pwa.ext.installableManifest
class WebAppShortcutManager(
private val storage: ManifestStorage
private val storage: ManifestStorage,
private val supportWebApps: Boolean = true
) {
/**
......@@ -28,7 +29,7 @@ class WebAppShortcutManager(
suspend fun requestPinShortcut(context: Context, session: Session) {
if (ShortcutManagerCompat.isRequestPinShortcutSupported(context)) {
val manifest = session.installableManifest()
val shortcut = if (manifest != null) {
val shortcut = if (supportWebApps && manifest != null) {
buildWebAppShortcut(context, manifest)
} else {
buildBasicShortcut(context, session)
......
......@@ -13,7 +13,8 @@ import mozilla.components.browser.session.SessionManager
*/
class WebAppUseCases(
private val applicationContext: Context,
sessionManager: SessionManager
sessionManager: SessionManager,
supportWebApps: Boolean = true
) {
fun isPinningSupported() =
......@@ -30,9 +31,13 @@ class WebAppUseCases(
*/
class AddToHomescreenUseCase internal constructor(
private val applicationContext: Context,
private val sessionManager: SessionManager
private val sessionManager: SessionManager,
supportWebApps: Boolean
) {
private val shortcutManager = WebAppShortcutManager(ManifestStorage(applicationContext))
private val shortcutManager = WebAppShortcutManager(
ManifestStorage(applicationContext),
supportWebApps
)
suspend operator fun invoke() {
val session = sessionManager.selectedSession ?: return
......@@ -40,5 +45,5 @@ class WebAppUseCases(
}
}
val addToHomescreen by lazy { AddToHomescreenUseCase(applicationContext, sessionManager) }
val addToHomescreen by lazy { AddToHomescreenUseCase(applicationContext, sessionManager, supportWebApps) }
}
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