2019-01-29 20:20:29 +01:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
2019-07-12 20:38:15 +02:00
|
|
|
* 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/. */
|
2019-01-29 20:20:29 +01:00
|
|
|
|
2019-01-29 21:46:11 +01:00
|
|
|
package org.mozilla.fenix.components
|
|
|
|
|
|
|
|
import android.content.Context
|
|
|
|
import mozilla.components.browser.session.SessionManager
|
2019-10-09 18:17:49 +02:00
|
|
|
import mozilla.components.concept.fetch.Client
|
2019-07-22 15:49:43 +02:00
|
|
|
import mozilla.components.feature.customtabs.CustomTabIntentProcessor
|
2019-10-09 18:17:49 +02:00
|
|
|
import mozilla.components.feature.customtabs.store.CustomTabsServiceStore
|
2019-09-04 12:21:42 +02:00
|
|
|
import mozilla.components.feature.intent.processing.TabIntentProcessor
|
2019-10-09 01:50:16 +02:00
|
|
|
import mozilla.components.feature.pwa.ManifestStorage
|
2019-10-09 18:17:49 +02:00
|
|
|
import mozilla.components.feature.pwa.intent.TrustedWebActivityIntentProcessor
|
2020-02-06 15:23:11 +01:00
|
|
|
import mozilla.components.feature.pwa.intent.WebAppIntentProcessor
|
2019-01-29 21:46:11 +01:00
|
|
|
import mozilla.components.feature.search.SearchUseCases
|
|
|
|
import mozilla.components.feature.session.SessionUseCases
|
2020-01-15 06:59:08 +01:00
|
|
|
import mozilla.components.support.migration.MigrationIntentProcessor
|
|
|
|
import mozilla.components.support.migration.state.MigrationStore
|
2019-10-09 18:17:49 +02:00
|
|
|
import org.mozilla.fenix.BuildConfig
|
2020-02-06 15:23:11 +01:00
|
|
|
import org.mozilla.fenix.customtabs.FennecWebAppIntentProcessor
|
2020-01-07 18:07:51 +01:00
|
|
|
import org.mozilla.fenix.home.intent.FennecBookmarkShortcutsIntentProcessor
|
2019-05-07 23:36:37 +02:00
|
|
|
import org.mozilla.fenix.test.Mockable
|
2019-01-29 21:46:11 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Component group for miscellaneous components.
|
|
|
|
*/
|
2019-05-07 23:36:37 +02:00
|
|
|
@Mockable
|
2019-09-18 20:23:32 +02:00
|
|
|
class IntentProcessors(
|
2019-01-29 21:46:11 +01:00
|
|
|
private val context: Context,
|
|
|
|
private val sessionManager: SessionManager,
|
|
|
|
private val sessionUseCases: SessionUseCases,
|
2019-10-09 18:17:49 +02:00
|
|
|
private val searchUseCases: SearchUseCases,
|
|
|
|
private val httpClient: Client,
|
2020-01-15 06:59:08 +01:00
|
|
|
private val customTabsStore: CustomTabsServiceStore,
|
2020-02-06 15:23:11 +01:00
|
|
|
private val migrationStore: MigrationStore,
|
|
|
|
private val manifestStorage: ManifestStorage
|
2019-01-29 21:46:11 +01:00
|
|
|
) {
|
|
|
|
/**
|
2019-08-29 21:45:11 +02:00
|
|
|
* Provides intent processing functionality for ACTION_VIEW and ACTION_SEND intents.
|
2019-01-29 21:46:11 +01:00
|
|
|
*/
|
|
|
|
val intentProcessor by lazy {
|
2019-07-22 15:49:43 +02:00
|
|
|
TabIntentProcessor(sessionManager, sessionUseCases.loadUrl, searchUseCases.newTabSearch, isPrivate = false)
|
2019-01-29 21:46:11 +01:00
|
|
|
}
|
2019-02-28 18:25:37 +01:00
|
|
|
|
2019-08-29 21:45:11 +02:00
|
|
|
/**
|
|
|
|
* Provides intent processing functionality for ACTION_VIEW and ACTION_SEND intents in private tabs.
|
|
|
|
*/
|
2019-02-28 18:25:37 +01:00
|
|
|
val privateIntentProcessor by lazy {
|
2019-07-22 15:49:43 +02:00
|
|
|
TabIntentProcessor(sessionManager, sessionUseCases.loadUrl, searchUseCases.newTabSearch, isPrivate = true)
|
|
|
|
}
|
|
|
|
|
2019-09-26 19:15:12 +02:00
|
|
|
val customTabIntentProcessor by lazy {
|
2019-12-06 19:57:54 +01:00
|
|
|
CustomTabIntentProcessor(sessionManager, sessionUseCases.loadUrl, context.resources, isPrivate = false)
|
|
|
|
}
|
|
|
|
|
|
|
|
val privateCustomTabIntentProcessor by lazy {
|
|
|
|
CustomTabIntentProcessor(sessionManager, sessionUseCases.loadUrl, context.resources, isPrivate = true)
|
2019-09-26 19:15:12 +02:00
|
|
|
}
|
|
|
|
|
2019-09-19 18:12:42 +02:00
|
|
|
val externalAppIntentProcessors by lazy {
|
|
|
|
listOf(
|
2019-10-09 18:17:49 +02:00
|
|
|
TrustedWebActivityIntentProcessor(
|
|
|
|
sessionManager = sessionManager,
|
|
|
|
loadUrlUseCase = sessionUseCases.loadUrl,
|
|
|
|
httpClient = httpClient,
|
|
|
|
packageManager = context.packageManager,
|
|
|
|
apiKey = BuildConfig.DIGITAL_ASSET_LINKS_TOKEN,
|
|
|
|
store = customTabsStore
|
|
|
|
),
|
2020-02-06 15:23:11 +01:00
|
|
|
WebAppIntentProcessor(sessionManager, sessionUseCases.loadUrl, manifestStorage),
|
|
|
|
FennecBookmarkShortcutsIntentProcessor(sessionManager, sessionUseCases.loadUrl),
|
|
|
|
FennecWebAppIntentProcessor(sessionManager, sessionUseCases.loadUrl, manifestStorage)
|
2019-09-19 18:12:42 +02:00
|
|
|
)
|
2019-02-28 18:25:37 +01:00
|
|
|
}
|
2020-01-15 06:59:08 +01:00
|
|
|
|
|
|
|
val migrationIntentProcessor by lazy {
|
|
|
|
MigrationIntentProcessor(migrationStore)
|
|
|
|
}
|
2019-01-29 21:46:11 +01:00
|
|
|
}
|