Skip to content
This repository has been archived by the owner on Feb 20, 2023. It is now read-only.

Commit

Permalink
Closes #394 - Trusted Web Activities (#5391)
Browse files Browse the repository at this point in the history
  • Loading branch information
NotWoods authored and sblatz committed Oct 9, 2019
1 parent f008d29 commit 6ec0d46
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 5 deletions.
19 changes: 16 additions & 3 deletions app/src/debug/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,22 @@
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

<!-- Allows changing locales -->
<uses-permission android:name="android.permission.CHANGE_CONFIGURATION" />
<uses-permission android:name="android.permission.CHANGE_CONFIGURATION"
tools:ignore="ProtectedPermissions" />

<application
tools:replace="android:name"
android:name="org.mozilla.fenix.DebugFenixApplication"/>
</manifest>
android:name="org.mozilla.fenix.DebugFenixApplication">

<service android:name=".customtabs.CustomTabsService">
<!-- Trusted Web Activities are currently only supported in nightly. -->
<intent-filter tools:node="removeAll" />
<intent-filter>
<action android:name="android.support.customtabs.action.CustomTabsService" />
<category android:name="androidx.browser.trusted.category.TrustedWebActivities" />
</intent-filter>
</service>

</application>

</manifest>
18 changes: 18 additions & 0 deletions app/src/fenixNightly/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="org.mozilla.fenix">

<application>

<service android:name=".customtabs.CustomTabsService">
<!-- Trusted Web Activities are currently only supported in nightly. -->
<intent-filter tools:node="removeAll" />
<intent-filter>
<action android:name="android.support.customtabs.action.CustomTabsService" />
<category android:name="androidx.browser.trusted.category.TrustedWebActivities" />
</intent-filter>
</service>

</application>

</manifest>
9 changes: 8 additions & 1 deletion app/src/main/java/org/mozilla/fenix/components/Components.kt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,14 @@ class Components(private val context: Context) {
)
}
val intentProcessors by lazy {
IntentProcessors(context, core.sessionManager, useCases.sessionUseCases, useCases.searchUseCases)
IntentProcessors(
context,
core.sessionManager,
useCases.sessionUseCases,
useCases.searchUseCases,
core.client,
core.customTabsStore
)
}
val analytics by lazy { Analytics(context) }
val publicSuffixList by lazy { PublicSuffixList(context) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,16 @@ 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
import mozilla.components.feature.pwa.ManifestStorage
import mozilla.components.feature.pwa.intent.WebAppIntentProcessor
import mozilla.components.feature.pwa.intent.TrustedWebActivityIntentProcessor
import mozilla.components.feature.search.SearchUseCases
import mozilla.components.feature.session.SessionUseCases
import org.mozilla.fenix.BuildConfig
import org.mozilla.fenix.test.Mockable

/**
Expand All @@ -22,7 +26,9 @@ class IntentProcessors(
private val context: Context,
private val sessionManager: SessionManager,
private val sessionUseCases: SessionUseCases,
private val searchUseCases: SearchUseCases
private val searchUseCases: SearchUseCases,
private val httpClient: Client,
private val customTabsStore: CustomTabsServiceStore
) {
/**
* Provides intent processing functionality for ACTION_VIEW and ACTION_SEND intents.
Expand All @@ -40,6 +46,14 @@ class IntentProcessors(

val externalAppIntentProcessors by lazy {
listOf(
TrustedWebActivityIntentProcessor(
sessionManager = sessionManager,
loadUrlUseCase = sessionUseCases.loadUrl,
httpClient = httpClient,
packageManager = context.packageManager,
apiKey = BuildConfig.DIGITAL_ASSET_LINKS_TOKEN,
store = customTabsStore
),
WebAppIntentProcessor(sessionManager, sessionUseCases.loadUrl, ManifestStorage(context)),
CustomTabIntentProcessor(sessionManager, sessionUseCases.loadUrl, context.resources)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@ 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
}

0 comments on commit 6ec0d46

Please sign in to comment.