1
0
Fork 0

Closes #7156: Update app links feature usage to include app links interceptor (#7275)

master
Roger Yang 2019-12-20 08:27:19 -05:00 committed by GitHub
parent cb1cd1e4c7
commit dd1433733a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 43 additions and 13 deletions

View File

@ -19,16 +19,26 @@ import org.mozilla.fenix.ext.isOnline
class AppRequestInterceptor(private val context: Context) : RequestInterceptor {
override fun onLoadRequest(
session: EngineSession,
uri: String
engineSession: EngineSession,
uri: String,
hasUserGesture: Boolean,
isSameDomain: Boolean
): RequestInterceptor.InterceptionResponse? {
adjustTrackingProtection(context, session)
adjustTrackingProtection(context, engineSession)
var result: RequestInterceptor.InterceptionResponse? = null
// WebChannel-driven authentication does not require a separate redirect interceptor.
return if (context.isInExperiment(Experiments.asFeatureWebChannelsDisabled)) {
context.components.services.accountsAuthFeature.interceptor.onLoadRequest(session, uri)
} else {
null
if (context.isInExperiment(Experiments.asFeatureWebChannelsDisabled)) {
result = context.components.services.accountsAuthFeature.interceptor.onLoadRequest(
engineSession, uri, hasUserGesture, isSameDomain)
}
if (result == null) {
result = context.components.services.appLinksInterceptor.onLoadRequest(
engineSession, uri, hasUserGesture, isSameDomain)
}
return result
}
private fun adjustTrackingProtection(context: Context, session: EngineSession) {

View File

@ -78,6 +78,7 @@ import org.mozilla.fenix.downloads.DownloadNotificationBottomSheetDialog
import org.mozilla.fenix.downloads.DownloadService
import org.mozilla.fenix.ext.components
import org.mozilla.fenix.ext.enterToImmersiveMode
import org.mozilla.fenix.ext.getPreferenceKey
import org.mozilla.fenix.ext.getRootView
import org.mozilla.fenix.ext.hideToolbar
import org.mozilla.fenix.ext.metrics
@ -304,8 +305,10 @@ abstract class BaseBrowserFragment : Fragment(), UserInteractionHandler, Session
context,
sessionManager = sessionManager,
sessionId = customTabSessionId,
interceptLinkClicks = true,
fragmentManager = parentFragmentManager
fragmentManager = parentFragmentManager,
launchInApp = { context.settings().preferences.getBoolean(
context.getPreferenceKey(R.string.pref_key_open_links_in_external_app), false)
}
),
owner = this,
view = view
@ -403,9 +406,8 @@ abstract class BaseBrowserFragment : Fragment(), UserInteractionHandler, Session
url: String,
triggeredByRedirect: Boolean,
triggeredByWebContent: Boolean
): Boolean {
) {
browserToolbarView.expand()
return false
}
}, owner = viewLifecycleOwner)

View File

@ -10,12 +10,16 @@ import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import mozilla.components.feature.accounts.FirefoxAccountsAuthFeature
import mozilla.components.feature.app.links.AppLinksInterceptor
import mozilla.components.service.fxa.manager.FxaAccountManager
import mozilla.components.support.ktx.android.content.hasCamera
import org.mozilla.fenix.Experiments
import org.mozilla.fenix.NavGraphDirections
import org.mozilla.fenix.R
import org.mozilla.fenix.components.metrics.Event
import org.mozilla.fenix.ext.components
import org.mozilla.fenix.ext.getPreferenceKey
import org.mozilla.fenix.ext.settings
import org.mozilla.fenix.isInExperiment
import org.mozilla.fenix.settings.SupportUtils
import org.mozilla.fenix.test.Mockable
@ -28,6 +32,7 @@ class Services(
private val context: Context,
private val accountManager: FxaAccountManager
) {
val fxaRedirectUrl = FxaServer.redirectUrl(context)
val accountsAuthFeature by lazy {
@ -42,6 +47,17 @@ class Services(
}
}
val appLinksInterceptor by lazy {
AppLinksInterceptor(
context,
interceptLinkClicks = true,
launchInApp = {
context.settings().preferences.getBoolean(
context.getPreferenceKey(R.string.pref_key_open_links_in_external_app), false)
}
)
}
/**
* Launches the sign in and pairing custom tab from any screen in the app.
* @param context the current Context

View File

@ -233,7 +233,7 @@ class DefaultBrowserToolbarController(
sessionManager.selectedSession?.let {
val redirect = getRedirect.invoke(it.url)
redirect.appIntent?.flags = Intent.FLAG_ACTIVITY_NEW_TASK
appLinksUseCases.openAppLink.invoke(redirect)
appLinksUseCases.openAppLink.invoke(redirect.appIntent)
}
}
ToolbarMenu.Item.Bookmark -> {

View File

@ -43,6 +43,7 @@ class Settings private constructor(
const val autoBounceMaximumCount = 2
const val trackingProtectionOnboardingMaximumCount = 2
const val FENIX_PREFERENCES = "fenix_preferences"
private const val BLOCKED_INT = 0
private const val ASK_TO_ALLOW_INT = 1
private const val CFR_COUNT_CONDITION_FOCUS_INSTALLED = 1

View File

@ -119,6 +119,7 @@
<!-- Privacy Settings -->
<string name="pref_key_open_links_in_a_private_tab" translatable="false">pref_key_open_links_in_a_private_tab</string>
<string name="pref_key_open_links_in_external_app" translatable="false">pref_key_open_links_in_external_app</string>
<!-- Quick Action Sheet -->
<string name="pref_key_bounce_quick_action" translatable="false">pref_key_bounce_quick_action</string>

View File

@ -35,7 +35,7 @@ object Versions {
const val androidx_work = "2.2.0"
const val google_material = "1.1.0-beta01"
const val mozilla_android_components = "26.0.0-SNAPSHOT"
const val mozilla_android_components = "27.0.0-SNAPSHOT"
// Note that android-components also depends on application-services,
// and in fact is our main source of appservices-related functionality.
// The version number below tracks the application-services version