From aacc74488476ffd5fcf0e0c6eaab9aa80dd25060 Mon Sep 17 00:00:00 2001 From: Cristian Monforte Date: Thu, 13 Feb 2025 17:35:27 +0100 Subject: [PATCH] enable showing suggestions inside DDG (behind FF) (#5646) Task/Issue URL: https://app.asana.com/0/488551667048375/1209399460038441 ### Description show suggestions inside DDG app Put it behind a FF in case we uncover unexpected behaviors ### Steps to test this PR _Feature 1_ - [ ] Visiting fill.dev or other sites inside DDG - [ ] focus on login fields - [ ] you should see suggestions as in other apps ### UI changes | Before | After | | ------ | ----- | !(Upload before screenshot)|(Upload after screenshot)| --- .../autofill/impl/service/AutofillServiceFeature.kt | 4 ++++ .../autofill/impl/service/RealAutofillService.kt | 12 ++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/autofill/autofill-impl/src/main/java/com/duckduckgo/autofill/impl/service/AutofillServiceFeature.kt b/autofill/autofill-impl/src/main/java/com/duckduckgo/autofill/impl/service/AutofillServiceFeature.kt index 8a0b16ab10da..ee3465307735 100644 --- a/autofill/autofill-impl/src/main/java/com/duckduckgo/autofill/impl/service/AutofillServiceFeature.kt +++ b/autofill/autofill-impl/src/main/java/com/duckduckgo/autofill/impl/service/AutofillServiceFeature.kt @@ -38,4 +38,8 @@ interface AutofillServiceFeature { @Toggle.DefaultValue(false) @InternalAlwaysEnabled fun canMapAppToDomain(): Toggle + + @Toggle.DefaultValue(false) + @InternalAlwaysEnabled + fun canAutofillInsideDDG(): Toggle } diff --git a/autofill/autofill-impl/src/main/java/com/duckduckgo/autofill/impl/service/RealAutofillService.kt b/autofill/autofill-impl/src/main/java/com/duckduckgo/autofill/impl/service/RealAutofillService.kt index 8b1c264aedf1..3d8808ccd3ec 100644 --- a/autofill/autofill-impl/src/main/java/com/duckduckgo/autofill/impl/service/RealAutofillService.kt +++ b/autofill/autofill-impl/src/main/java/com/duckduckgo/autofill/impl/service/RealAutofillService.kt @@ -82,6 +82,7 @@ class RealAutofillService : AutofillService() { val parsedRootNodes = autofillParser.parseStructure(structure) val nodeToAutofill = parsedRootNodes.findBestFillableNode() if (nodeToAutofill == null || shouldSkipAutofillSuggestions(nodeToAutofill)) { + Timber.v("DDGAutofillService onFillRequest: no autofill suggestions") callback.onSuccess(null) return@launch } @@ -108,7 +109,13 @@ class RealAutofillService : AutofillService() { if (nodeToAutofill.packageId.equals("android", ignoreCase = true)) return true - if (nodeToAutofill.packageId in PACKAGES_TO_EXCLUDE) return true + if (autofillServiceFeature.canAutofillInsideDDG().isEnabled().not() && nodeToAutofill.packageId in DDG_PACKAGE_IDS) { + return true + } + + if (nodeToAutofill.packageId in BROWSERS_PACKAGE_IDS && nodeToAutofill.website.isNullOrBlank()) { + return true // if a browser we require a website + } return false } @@ -136,9 +143,10 @@ class RealAutofillService : AutofillService() { } companion object { - private val PACKAGES_TO_EXCLUDE = setOf( + private val DDG_PACKAGE_IDS = setOf( "com.duckduckgo.mobile.android", "com.duckduckgo.mobile.android.debug", ) + private val BROWSERS_PACKAGE_IDS = DDG_PACKAGE_IDS } }