1
0
Fork 0

Closes #394 - Trusted Web Activities (#5391)

master
Tiger Oakes 2019-10-09 09:17:49 -07:00 committed by Sawyer Blatz
parent f008d29bf3
commit 6ec0d46f6b
5 changed files with 60 additions and 5 deletions

View File

@ -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>

View File

@ -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>

View File

@ -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) }

View File

@ -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
/**
@ -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.
@ -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)
)

View File

@ -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
}