Skip to content

Commit

Permalink
Preparation for Autofill enabled by default (#3695)
Browse files Browse the repository at this point in the history
<!--
Note: This checklist is a reminder of our shared engineering
expectations.
The items in Bold are required
If your PR involves UI changes:
1. Upload screenshots or screencasts that illustrate the changes before
/ after
2. Add them under the UI changes section (feel free to add more columns
if needed)
If your PR does not involve UI changes, you can remove the **UI
changes** section

At a minimum, make sure your changes are tested in API 23 and one of the
more recent API levels available.
-->

Task/Issue URL:
https://app.asana.com/0/488551667048375/1205737758794661/f

### Description
Preparatory work to enable us to ship autofill enabled by default. 

ℹ️ **Notes on reviewing this PR** 
- All PRs in the stack have been individually reviewed/approved already.
- This PR therefore doesn't require a line-by-line review of the code
changes (though feel free!) and is more about a sense-check that things
are working as expected.

**Note on remote config integration** 
- Remote config isn't live to actually make it enabled by default yet
- But after this PR lands the app will be ready to do so when we choose
(soon)

### Steps to test this PR

Perform a general smoke test of the main Autofill features, as detailed
below.

#### Saving a login
- [x] Enable autofill from overflow->Logins (will be enabled already if
on `internal` build)
- [x] Visit https://fill.dev/form/login-simple
- [x] Enter a username and password (>= 4 characters) and submit
- [x] Verify dialog looks good, and matches the **after** picture like
the one below
- [x] Save the login

#### Filling a login
- [x] Revisit https://fill.dev/form/login-simple
- [x] Verify dialog to autofill looks good, and matches the **after**
picture like the one below

#### Password generation
- [x] Visit https://fill.dev/form/registration-username
- [x] Verify dialog to autofill looks good, and matches the **after**
picture like the one below


### UI changes
<img width=80%
src="https://github.com/duckduckgo/Android/assets/1336281/52d9e1ef-61a7-479c-9188-2d535877a2b1"
/>

<img width=80%
src=https://github.com/duckduckgo/Android/assets/1336281/2c80948b-e22f-4192-bf35-6e3d64031252
/>

<img width=80%
src=https://github.com/duckduckgo/Android/assets/1336281/b8bdde16-3c06-49b9-8046-040e6d969b3c
/>

<img width=80%
src=https://github.com/duckduckgo/Android/assets/1336281/ce14ffd7-68b9-4bcd-8c1c-4fba47cec42d
/>

<img width=80%
src=https://github.com/duckduckgo/Android/assets/1336281/5f2abb55-71c2-4037-9b96-3a7b1df2bac4
/>

<img width=80%
src=https://github.com/duckduckgo/Android/assets/1336281/1f8eaa65-2eda-4d07-a163-c704bfaf85f3
/>

---------

Co-authored-by: Marcos Holgado <marcosh@duckduckgo.com>
Co-authored-by: root <root@10.100.11.5>
  • Loading branch information
3 people authored Nov 20, 2023
1 parent 258dea9 commit b289c87
Show file tree
Hide file tree
Showing 102 changed files with 2,453 additions and 917 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3068,7 +3068,6 @@ class BrowserTabFragment :
viewModel.onPrintSelected()
}
onMenuItemClicked(menuBinding.autofillMenuItem) {
pixel.fire(AppPixelName.MENU_ACTION_AUTOFILL_PRESSED)
viewModel.onAutofillMenuSelected()
}
}
Expand Down
2 changes: 0 additions & 2 deletions app/src/main/java/com/duckduckgo/app/pixels/AppPixelName.kt
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ enum class AppPixelName(override val pixelName: String) : Pixel.PixelName {
SETTINGS_APP_LINKS_ALWAYS_SELECTED("ms_app_links_always_setting_selected"),
SETTINGS_APP_LINKS_NEVER_SELECTED("ms_app_links_never_setting_selected"),
SETTINGS_ADD_HOME_SCREEN_WIDGET_CLICKED("ms_add_home_screen_widget_clicked"),
SETTINGS_AUTOFILL_MANAGEMENT_OPENED("m_autofill_settings_opened"),
SETTINGS_DEFAULT_BROWSER_PRESSED("ms_default_browser_pressed"),
SETTINGS_PRIVATE_SEARCH_PRESSED("ms_private_search_setting_pressed"),
SETTINGS_WEB_TRACKING_PROTECTION_PRESSED("ms_web_tracking_protection_setting_pressed"),
Expand Down Expand Up @@ -204,7 +203,6 @@ enum class AppPixelName(override val pixelName: String) : Pixel.PixelName {
MENU_ACTION_SETTINGS_PRESSED("m_nav_s_p"),
MENU_ACTION_APP_LINKS_OPEN_PRESSED("m_nav_app_links_open_menu_item_pressed"),
MENU_ACTION_DOWNLOADS_PRESSED("m_nav_downloads_menu_item_pressed"),
MENU_ACTION_AUTOFILL_PRESSED("m_nav_autofill_menu_item_pressed"),

FIREPROOF_WEBSITE_ADDED("m_fw_a"),
FIREPROOF_WEBSITE_REMOVE("m_fw_r"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,6 @@ class SettingsViewModel @Inject constructor(

fun onAutofillSettingsClick() {
viewModelScope.launch { command.send(Command.LaunchAutofillSettings) }
pixel.fire(SETTINGS_AUTOFILL_MANAGEMENT_OPENED)
}

fun onAccessibilitySettingClicked() {
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-bg/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@
<string name="settingsWebTrackingProtectionDescription">Активирано по подразбиране</string>
<string name="settingsHeadingSettings">Настройки</string>
<string name="settingsPermissionsSetting">Разрешения</string>
<string name="settingsAutofillLoginsSetting">Автоматично попълване на данни за вход</string>
<string name="settingsAutofillLoginsSetting">Данни за вход</string>
<string name="settingsSyncSetting">Синхронизиране и архивиране</string>
<string name="settingsFireButton">Fire Button</string>

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-cs/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@
<string name="settingsWebTrackingProtectionDescription">Ve výchozím nastavení povoleno</string>
<string name="settingsHeadingSettings">Nastavení</string>
<string name="settingsPermissionsSetting">Oprávnění</string>
<string name="settingsAutofillLoginsSetting">Automatické vyplňování přihlašovacích údajů</string>
<string name="settingsAutofillLoginsSetting">Přihlášení</string>
<string name="settingsSyncSetting">Synchronizace a zálohování</string>
<string name="settingsFireButton">Fire Button</string>

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-da/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@
<string name="settingsWebTrackingProtectionDescription">Aktiveret som standard</string>
<string name="settingsHeadingSettings">Indstillinger</string>
<string name="settingsPermissionsSetting">Tilladelser</string>
<string name="settingsAutofillLoginsSetting">Automatisk udfyldning ved login</string>
<string name="settingsAutofillLoginsSetting">Logins</string>
<string name="settingsSyncSetting">Synkronisering og sikkerhedskopiering</string>
<string name="settingsFireButton">Fire Button</string>

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@
<string name="settingsWebTrackingProtectionDescription">Standardmäßig aktiviert</string>
<string name="settingsHeadingSettings">Einstellungen</string>
<string name="settingsPermissionsSetting">Berechtigungen</string>
<string name="settingsAutofillLoginsSetting">Anmeldedaten automatisch ausfüllen</string>
<string name="settingsAutofillLoginsSetting">Anmeldungen</string>
<string name="settingsSyncSetting">Synchronisieren und sichern</string>
<string name="settingsFireButton">Fire Button</string>

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-el/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@
<string name="settingsWebTrackingProtectionDescription">Ενεργοποιημένο βάσει προεπιλογής</string>
<string name="settingsHeadingSettings">Ρυθμίσεις</string>
<string name="settingsPermissionsSetting">Δικαιώματα</string>
<string name="settingsAutofillLoginsSetting">Συνδέσεις αυτόματης συμπλήρωσης</string>
<string name="settingsAutofillLoginsSetting">Συνδέσεις</string>
<string name="settingsSyncSetting">Συγχρονισμός και δημιουργία αντιγράφων ασφαλείας</string>
<string name="settingsFireButton">Κουμπί Φωτιά</string>

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-es/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@
<string name="settingsWebTrackingProtectionDescription">Habilitado de forma predeterminada</string>
<string name="settingsHeadingSettings">Ajustes</string>
<string name="settingsPermissionsSetting">Permisos</string>
<string name="settingsAutofillLoginsSetting">Autocompletar inicios de sesión</string>
<string name="settingsAutofillLoginsSetting">Inicios de sesión</string>
<string name="settingsSyncSetting">Sincronización y copia de seguridad</string>
<string name="settingsFireButton">Fire Button</string>

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-et/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@
<string name="settingsWebTrackingProtectionDescription">Vaikimisi sisse lülitatud</string>
<string name="settingsHeadingSettings">Sätted</string>
<string name="settingsPermissionsSetting">Load</string>
<string name="settingsAutofillLoginsSetting">Sisesta sisselogimisandmed automaatselt</string>
<string name="settingsAutofillLoginsSetting">Sisselogimine</string>
<string name="settingsSyncSetting">Sünkroonimine ja varundamine</string>
<string name="settingsFireButton">Fire Button</string>

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-fi/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@
<string name="settingsWebTrackingProtectionDescription">Oletusarvoisesti käytössä</string>
<string name="settingsHeadingSettings">Asetukset</string>
<string name="settingsPermissionsSetting">Käyttöoikeudet</string>
<string name="settingsAutofillLoginsSetting">Täytä kirjautumistiedot automaattisesti</string>
<string name="settingsAutofillLoginsSetting">Kirjautumistiedot</string>
<string name="settingsSyncSetting">Synkronoi ja varmuuskopioi</string>
<string name="settingsFireButton">Fire-painike</string>

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-fr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@
<string name="settingsWebTrackingProtectionDescription">Activation par défaut</string>
<string name="settingsHeadingSettings">Paramètres</string>
<string name="settingsPermissionsSetting">Autorisations</string>
<string name="settingsAutofillLoginsSetting">Saisie automatique des identifiants</string>
<string name="settingsAutofillLoginsSetting">Identifiants</string>
<string name="settingsSyncSetting">Synchronisation et sauvegarde</string>
<string name="settingsFireButton">Fire Button</string>

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-hr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@
<string name="settingsWebTrackingProtectionDescription">Omogućeno prema zadanim postavkama</string>
<string name="settingsHeadingSettings">Postavke</string>
<string name="settingsPermissionsSetting">Dozvole</string>
<string name="settingsAutofillLoginsSetting">Automatsko popunjavanje prijave</string>
<string name="settingsAutofillLoginsSetting">Prijave</string>
<string name="settingsSyncSetting">Sinkronizacija i sigurnosno kopiranje</string>
<string name="settingsFireButton">Fire Button</string>

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-hu/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@
<string name="settingsWebTrackingProtectionDescription">Alapértelmezés szerint engedélyezve</string>
<string name="settingsHeadingSettings">Beállítások</string>
<string name="settingsPermissionsSetting">Engedélyek</string>
<string name="settingsAutofillLoginsSetting">Bejelentkezési adatok automatikus kitöltése</string>
<string name="settingsAutofillLoginsSetting">Bejelentkezések</string>
<string name="settingsSyncSetting">Szinkronizálás és biztonsági mentés</string>
<string name="settingsFireButton">Tűz gomb</string>

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-it/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@
<string name="settingsWebTrackingProtectionDescription">Abilitato per impostazione predefinita</string>
<string name="settingsHeadingSettings">Impostazioni</string>
<string name="settingsPermissionsSetting">Autorizzazioni</string>
<string name="settingsAutofillLoginsSetting">Compilazione automatica dei dati di accesso</string>
<string name="settingsAutofillLoginsSetting">Accessi</string>
<string name="settingsSyncSetting">Sincronizzazione e backup</string>
<string name="settingsFireButton">Fire Button</string>

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-lt/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@
<string name="settingsWebTrackingProtectionDescription">Įjungta pagal numatytuosius nustatymus</string>
<string name="settingsHeadingSettings">Nustatymai</string>
<string name="settingsPermissionsSetting">Leidimai</string>
<string name="settingsAutofillLoginsSetting">Automatiškai užpildyti prisijungimus</string>
<string name="settingsAutofillLoginsSetting">Prisijungimai</string>
<string name="settingsSyncSetting">Sinchronizuoti ir kurti atsarginę kopiją</string>
<string name="settingsFireButton">Mygtukas „Fire“</string>

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-lv/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@
<string name="settingsWebTrackingProtectionDescription">Iespējots pēc noklusējuma</string>
<string name="settingsHeadingSettings">Iestatījumi</string>
<string name="settingsPermissionsSetting">Atļaujas</string>
<string name="settingsAutofillLoginsSetting">Automātiski aizpildīt pieteikšanās datus</string>
<string name="settingsAutofillLoginsSetting">Pieteikšanās dati</string>
<string name="settingsSyncSetting">Sinhronizācija un dublēšana</string>
<string name="settingsFireButton">Fire Button</string>

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-nb/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@
<string name="settingsWebTrackingProtectionDescription">Aktivert som standard</string>
<string name="settingsHeadingSettings">Innstillinger</string>
<string name="settingsPermissionsSetting">Tillatelser</string>
<string name="settingsAutofillLoginsSetting">Fyll inn pålogginger automatisk</string>
<string name="settingsAutofillLoginsSetting">Pålogginger</string>
<string name="settingsSyncSetting">Synkronisering og sikkerhetskopiering</string>
<string name="settingsFireButton">Fire Button</string>

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-nl/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@
<string name="settingsWebTrackingProtectionDescription">Standaard ingeschakeld</string>
<string name="settingsHeadingSettings">Instellingen</string>
<string name="settingsPermissionsSetting">Toestemmingen</string>
<string name="settingsAutofillLoginsSetting">Login met automatisch invullen</string>
<string name="settingsAutofillLoginsSetting">Aanmeldgegevens</string>
<string name="settingsSyncSetting">Synchronisatie en back-up</string>
<string name="settingsFireButton">Fire Button</string>

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-pl/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@
<string name="settingsWebTrackingProtectionDescription">Domyślnie włączone</string>
<string name="settingsHeadingSettings">Ustawienia</string>
<string name="settingsPermissionsSetting">Uprawnienia</string>
<string name="settingsAutofillLoginsSetting">Autouzupełnianie logowania</string>
<string name="settingsAutofillLoginsSetting">Dane logowania</string>
<string name="settingsSyncSetting">Synchronizacja i kopia zapasowa</string>
<string name="settingsFireButton">Przycisk zabezpieczenia</string>

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-pt/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@
<string name="settingsWebTrackingProtectionDescription">Ativado por predefinição</string>
<string name="settingsHeadingSettings">Definições</string>
<string name="settingsPermissionsSetting">Permissões</string>
<string name="settingsAutofillLoginsSetting">Preenchimento automático de inícios de sessão</string>
<string name="settingsAutofillLoginsSetting">Inícios de sessão</string>
<string name="settingsSyncSetting">Sincronização e cópia de segurança</string>
<string name="settingsFireButton">Botão de proteção</string>

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-ro/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@
<string name="settingsWebTrackingProtectionDescription">Activat în mod implicit</string>
<string name="settingsHeadingSettings">Setări</string>
<string name="settingsPermissionsSetting">Permisiuni</string>
<string name="settingsAutofillLoginsSetting">Completare automată la autentificare</string>
<string name="settingsAutofillLoginsSetting">Conectări</string>
<string name="settingsSyncSetting">Sincronizare și copiere de rezervă</string>
<string name="settingsFireButton">Butonul Foc</string>

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-ru/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@
<string name="settingsWebTrackingProtectionDescription">Включено по умолчанию</string>
<string name="settingsHeadingSettings">Настройки</string>
<string name="settingsPermissionsSetting">Разрешения</string>
<string name="settingsAutofillLoginsSetting">Автозаполнение логинов</string>
<string name="settingsAutofillLoginsSetting">Логины</string>
<string name="settingsSyncSetting">Синхронизация и резервное копирование</string>
<string name="settingsFireButton">Кнопка «Тревога»</string>

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-sk/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@
<string name="settingsWebTrackingProtectionDescription">Predvolene povolené</string>
<string name="settingsHeadingSettings">Nastavenia</string>
<string name="settingsPermissionsSetting">Oprávnenia</string>
<string name="settingsAutofillLoginsSetting">Automatické vyplňovanie prihlasovacích údajov</string>
<string name="settingsAutofillLoginsSetting">Prihlasovacie údaje</string>
<string name="settingsSyncSetting">Synchronizácia a zálohovanie</string>
<string name="settingsFireButton">Tlačidlo Fire</string>

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-sl/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@
<string name="settingsWebTrackingProtectionDescription">Privzeto omogočeno</string>
<string name="settingsHeadingSettings">Nastavitve</string>
<string name="settingsPermissionsSetting">Dovoljenja</string>
<string name="settingsAutofillLoginsSetting">Samodejno izpolnjevanje obrazcev za prijavo</string>
<string name="settingsAutofillLoginsSetting">Prijave</string>
<string name="settingsSyncSetting">Sinhronizacija in varnostno kopiranje</string>
<string name="settingsFireButton">Gumb Fire Button</string>

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-sv/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@
<string name="settingsWebTrackingProtectionDescription">Aktiverat som standard</string>
<string name="settingsHeadingSettings">Inställningar</string>
<string name="settingsPermissionsSetting">Behörigheter</string>
<string name="settingsAutofillLoginsSetting">Fyll i inloggningar automatiskt</string>
<string name="settingsAutofillLoginsSetting">Inloggningar</string>
<string name="settingsSyncSetting">Synkronisering och säkerhetskopiering</string>
<string name="settingsFireButton">Fire Button</string>

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-tr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@
<string name="settingsWebTrackingProtectionDescription">Varsayılan olarak etkinleştirildi</string>
<string name="settingsHeadingSettings">Ayarlar</string>
<string name="settingsPermissionsSetting">İzinler</string>
<string name="settingsAutofillLoginsSetting">Girişleri Otomatik Doldur</string>
<string name="settingsAutofillLoginsSetting">Giriş bilgileri</string>
<string name="settingsSyncSetting">Senkronizasyon ve Yedekleme</string>
<string name="settingsFireButton">Fire Button</string>

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@
<string name="settingsWebTrackingProtectionDescription">Enabled by default</string>
<string name="settingsHeadingSettings">Settings</string>
<string name="settingsPermissionsSetting">Permissions</string>
<string name="settingsAutofillLoginsSetting">Autofill Logins</string>
<string name="settingsAutofillLoginsSetting">Logins</string>
<string name="settingsSyncSetting">Sync &amp; Backup</string>
<string name="settingsFireButton">Fire Button</string>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -377,12 +377,11 @@ class SettingsViewModelTest {
}

@Test
fun whenAutofillSettingsClickThenEmitCommandLaunchAutofillSettingsAndPixelFired() = runTest {
fun whenAutofillSettingsClickThenEmitCommandLaunchAutofillSettings() = runTest {
testee.commands().test {
testee.onAutofillSettingsClick()

assertEquals(Command.LaunchAutofillSettings, awaitItem())
verify(mockPixel).fire(AppPixelName.SETTINGS_AUTOFILL_MANAGEMENT_OPENED)

cancelAndConsumeRemainingEvents()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,11 @@ interface AutofillFeature {
*/
@Toggle.DefaultValue(false)
fun canAccessCredentialManagement(): Toggle

/**
* @return `true` when the remote config has the global "onByDefault" autofill sub-feature flag enabled
* If the remote feature is not present defaults to `false`
*/
@Toggle.DefaultValue(false)
fun onByDefault(): Toggle
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import com.duckduckgo.autofill.api.domain.app.LoginTriggerType
import com.duckduckgo.autofill.api.email.EmailManager
import com.duckduckgo.autofill.api.passwordgeneration.AutomaticSavedLoginsMonitor
import com.duckduckgo.autofill.api.store.AutofillStore
import com.duckduckgo.autofill.impl.deduper.AutofillLoginDeduplicator
import com.duckduckgo.autofill.impl.domain.javascript.JavascriptCredentials
import com.duckduckgo.autofill.impl.email.incontext.availability.EmailProtectionInContextRecentInstallChecker
import com.duckduckgo.autofill.impl.email.incontext.store.EmailProtectionInContextDataStore
Expand All @@ -43,6 +44,7 @@ import com.duckduckgo.autofill.impl.jsbridge.request.SupportedAutofillTriggerTyp
import com.duckduckgo.autofill.impl.jsbridge.request.SupportedAutofillTriggerType.USER_INITIATED
import com.duckduckgo.autofill.impl.jsbridge.response.AutofillResponseWriter
import com.duckduckgo.autofill.impl.sharedcreds.ShareableCredentials
import com.duckduckgo.autofill.impl.systemautofill.SystemAutofillServiceSuppressor
import com.duckduckgo.autofill.impl.ui.credential.passwordgeneration.Actions
import com.duckduckgo.autofill.impl.ui.credential.passwordgeneration.Actions.DeleteAutoLogin
import com.duckduckgo.autofill.impl.ui.credential.passwordgeneration.Actions.DiscardAutoLoginId
Expand Down Expand Up @@ -108,6 +110,8 @@ class AutofillStoredBackJavascriptInterface @Inject constructor(
private val emailManager: EmailManager,
private val inContextDataStore: EmailProtectionInContextDataStore,
private val recentInstallChecker: EmailProtectionInContextRecentInstallChecker,
private val loginDeduplicator: AutofillLoginDeduplicator,
private val systemAutofillServiceSuppressor: SystemAutofillServiceSuppressor,
) : AutofillJavascriptInterface {

override var callback: Callback? = null
Expand Down Expand Up @@ -209,10 +213,13 @@ class AutofillStoredBackJavascriptInterface @Inject constructor(

val credentials = filterRequestedSubtypes(request, matches)

if (credentials.isEmpty()) {
val dedupedCredentials = loginDeduplicator.deduplicate(url, credentials)
Timber.v("Original autofill credentials list size: %d, after de-duping: %d", credentials.size, dedupedCredentials.size)

if (dedupedCredentials.isEmpty()) {
callback?.noCredentialsAvailable(url)
} else {
callback?.onCredentialsAvailableToInject(url, credentials, triggerType)
callback?.onCredentialsAvailableToInject(url, dedupedCredentials, triggerType)
}
}

Expand Down Expand Up @@ -243,6 +250,9 @@ class AutofillStoredBackJavascriptInterface @Inject constructor(

@JavascriptInterface
fun storeFormData(data: String) {
// important to call suppressor as soon as possible
systemAutofillServiceSuppressor.suppressAutofill(webView)

Timber.i("storeFormData called, credentials provided to be persisted")

storeFormDataJob += coroutineScope.launch(dispatcherProvider.io()) {
Expand Down
Loading

0 comments on commit b289c87

Please sign in to comment.