diff --git a/app/build.gradle b/app/build.gradle index 6609bba77..4f29b5e47 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -506,6 +506,7 @@ dependencies { implementation Deps.mozilla_feature_webnotifications implementation Deps.mozilla_feature_webcompat_reporter + implementation Deps.mozilla_service_digitalassetlinks implementation Deps.mozilla_service_experiments implementation Deps.mozilla_service_sync_logins implementation Deps.mozilla_service_firefox_accounts diff --git a/app/src/main/java/org/mozilla/fenix/components/Components.kt b/app/src/main/java/org/mozilla/fenix/components/Components.kt index 19e431e64..7d0437521 100644 --- a/app/src/main/java/org/mozilla/fenix/components/Components.kt +++ b/app/src/main/java/org/mozilla/fenix/components/Components.kt @@ -61,7 +61,7 @@ class Components(private val context: Context) { core.sessionManager, useCases.sessionUseCases, useCases.searchUseCases, - core.client, + core.relationChecker, core.customTabsStore, migrationStore, core.webAppManifestStorage diff --git a/app/src/main/java/org/mozilla/fenix/components/Core.kt b/app/src/main/java/org/mozilla/fenix/components/Core.kt index c3c517a32..3f2b0dbf3 100644 --- a/app/src/main/java/org/mozilla/fenix/components/Core.kt +++ b/app/src/main/java/org/mozilla/fenix/components/Core.kt @@ -41,8 +41,11 @@ import mozilla.components.feature.webcompat.reporter.WebCompatReporterFeature import mozilla.components.feature.webnotifications.WebNotificationFeature import mozilla.components.lib.dataprotect.SecureAbove22Preferences import mozilla.components.lib.dataprotect.generateEncryptionKey +import mozilla.components.service.digitalassetlinks.RelationChecker +import mozilla.components.service.digitalassetlinks.api.DigitalAssetLinksApi import mozilla.components.service.sync.logins.SyncableLoginsStorage import org.mozilla.fenix.AppRequestInterceptor +import org.mozilla.fenix.BuildConfig.DIGITAL_ASSET_LINKS_TOKEN import org.mozilla.fenix.Config import org.mozilla.fenix.HomeActivity import org.mozilla.fenix.R @@ -136,6 +139,13 @@ class Core(private val context: Context) { */ val customTabsStore by lazy { CustomTabsServiceStore() } + /** + * The [RelationChecker] checks Digital Asset Links relationships for Trusted Web Activities. + */ + val relationChecker: RelationChecker by lazy { + DigitalAssetLinksApi(client, DIGITAL_ASSET_LINKS_TOKEN) + } + /** * The session manager component provides access to a centralized registry of * all browser sessions (i.e. tabs). It is initialized here to persist and restore diff --git a/app/src/main/java/org/mozilla/fenix/components/IntentProcessors.kt b/app/src/main/java/org/mozilla/fenix/components/IntentProcessors.kt index 70654620d..793de49da 100644 --- a/app/src/main/java/org/mozilla/fenix/components/IntentProcessors.kt +++ b/app/src/main/java/org/mozilla/fenix/components/IntentProcessors.kt @@ -6,7 +6,6 @@ package org.mozilla.fenix.components import android.content.Context import mozilla.components.browser.session.SessionManager -import mozilla.components.concept.fetch.Client import mozilla.components.feature.customtabs.CustomTabIntentProcessor import mozilla.components.feature.customtabs.store.CustomTabsServiceStore import mozilla.components.feature.intent.processing.TabIntentProcessor @@ -15,9 +14,9 @@ import mozilla.components.feature.pwa.intent.TrustedWebActivityIntentProcessor import mozilla.components.feature.pwa.intent.WebAppIntentProcessor import mozilla.components.feature.search.SearchUseCases import mozilla.components.feature.session.SessionUseCases +import mozilla.components.service.digitalassetlinks.RelationChecker import mozilla.components.support.migration.MigrationIntentProcessor import mozilla.components.support.migration.state.MigrationStore -import org.mozilla.fenix.BuildConfig import org.mozilla.fenix.customtabs.FennecWebAppIntentProcessor import org.mozilla.fenix.home.intent.FennecBookmarkShortcutsIntentProcessor import org.mozilla.fenix.utils.Mockable @@ -31,7 +30,7 @@ class IntentProcessors( private val sessionManager: SessionManager, private val sessionUseCases: SessionUseCases, private val searchUseCases: SearchUseCases, - private val httpClient: Client, + private val relationChecker: RelationChecker, private val customTabsStore: CustomTabsServiceStore, private val migrationStore: MigrationStore, private val manifestStorage: ManifestStorage @@ -63,9 +62,8 @@ class IntentProcessors( TrustedWebActivityIntentProcessor( sessionManager = sessionManager, loadUrlUseCase = sessionUseCases.loadUrl, - httpClient = httpClient, packageManager = context.packageManager, - apiKey = BuildConfig.DIGITAL_ASSET_LINKS_TOKEN, + relationChecker = relationChecker, store = customTabsStore ), WebAppIntentProcessor(sessionManager, sessionUseCases.loadUrl, manifestStorage), diff --git a/app/src/main/java/org/mozilla/fenix/customtabs/CustomTabsService.kt b/app/src/main/java/org/mozilla/fenix/customtabs/CustomTabsService.kt index 3254d72fa..9024d2dff 100644 --- a/app/src/main/java/org/mozilla/fenix/customtabs/CustomTabsService.kt +++ b/app/src/main/java/org/mozilla/fenix/customtabs/CustomTabsService.kt @@ -6,12 +6,10 @@ package org.mozilla.fenix.customtabs import mozilla.components.concept.engine.Engine import mozilla.components.feature.customtabs.AbstractCustomTabsService -import org.mozilla.fenix.BuildConfig.DIGITAL_ASSET_LINKS_TOKEN import org.mozilla.fenix.ext.components class CustomTabsService : AbstractCustomTabsService() { - override val engine: Engine by lazy { applicationContext.components.core.engine } - override val customTabsServiceStore by lazy { applicationContext.components.core.customTabsStore } - override val httpClient by lazy { applicationContext.components.core.client } - override val apiKey: String? = DIGITAL_ASSET_LINKS_TOKEN + override val engine: Engine by lazy { components.core.engine } + override val customTabsServiceStore by lazy { components.core.customTabsStore } + override val relationChecker by lazy { components.core.relationChecker } } diff --git a/buildSrc/src/main/java/Dependencies.kt b/buildSrc/src/main/java/Dependencies.kt index 43b516876..7b3905e1e 100644 --- a/buildSrc/src/main/java/Dependencies.kt +++ b/buildSrc/src/main/java/Dependencies.kt @@ -116,6 +116,8 @@ object Deps { const val mozilla_feature_webnotifications = "org.mozilla.components:feature-webnotifications:${Versions.mozilla_android_components}" const val mozilla_feature_webcompat_reporter = "org.mozilla.components:feature-webcompat-reporter:${Versions.mozilla_android_components}" + const val mozilla_service_digitalassetlinks = + "org.mozilla.components:service-digitalassetlinks:${Versions.mozilla_android_components}" const val mozilla_service_experiments = "org.mozilla.components:service-experiments:${Versions.mozilla_android_components}" const val mozilla_service_sync_logins =