Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: duckduckgo/Android
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 5580d9fcb616b93f3923eb3038e0ea744d7708ab
Choose a base ref
..
head repository: duckduckgo/Android
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: cfea135dcbd87d5782e1451106e371a0ae0e00f1
Choose a head ref
Original file line number Diff line number Diff line change
@@ -106,4 +106,8 @@ interface AutofillFeature {
@InternalAlwaysEnabled
@Toggle.DefaultValue(false)
fun canImportFromGooglePasswordManager(): Toggle

@InternalAlwaysEnabled
@Toggle.DefaultValue(false)
fun partialFormSaves(): Toggle
}
Original file line number Diff line number Diff line change
@@ -311,7 +311,7 @@ class AutofillStoredBackJavascriptInterface @Inject constructor(
when (request.trigger) {
FORM_SUBMISSION -> handleRequestForFormSubmission(credentials, currentUrl)
PARTIAL_SAVE -> handleRequestForPartialSave(credentials, currentUrl)
UNKNOWN -> Timber.e("Unknown trigger type %s")
UNKNOWN -> Timber.e("Unknown trigger type %s", request.trigger)
}
}
}
@@ -322,7 +322,7 @@ class AutofillStoredBackJavascriptInterface @Inject constructor(
) {
val jsCredentials = JavascriptCredentials(requestCredentials.username, requestCredentials.password)

val (credentials, wasBackfilled) = jsCredentials
val credentials = jsCredentials
.asLoginCredentials(currentUrl)
.backfillUsernameIfRequired(currentUrl)

@@ -381,7 +381,7 @@ class AutofillStoredBackJavascriptInterface @Inject constructor(
}
}

private suspend fun backfillUsernameSupport(
private suspend fun isBackFillingUsernameSupported(
credentialsFromJs: LoginCredentials,
currentUrl: String,
): BackfillResult {
@@ -472,16 +472,11 @@ class AutofillStoredBackJavascriptInterface @Inject constructor(
)
}

private suspend fun LoginCredentials.backfillUsernameIfRequired(currentUrl: String): Pair<LoginCredentials, Boolean> {
private suspend fun LoginCredentials.backfillUsernameIfRequired(currentUrl: String): LoginCredentials {
// determine if we can and should use a partial previous submission's username
return when (val result = backfillUsernameSupport(this, currentUrl)) {
is BackfillSupported -> {
Pair(this.copy(username = result.username), true)
}

is BackfillNotSupported -> {
Pair(this, false)
}
return when (val result = isBackFillingUsernameSupported(this, currentUrl)) {
is BackfillSupported -> this.copy(username = result.username)
is BackfillNotSupported -> this
}
}

Original file line number Diff line number Diff line change
@@ -63,6 +63,7 @@ class RealAutofillRuntimeConfigProvider @Inject constructor(
showInlineKeyIcon = true,
showInContextEmailProtectionSignup = canShowInContextEmailProtectionSignup(url),
unknownUsernameCategorization = canCategorizeUnknownUsername(),
partialFormSaves = partialFormSaves(),
)
val availableInputTypes = generateAvailableInputTypes(url)

@@ -133,6 +134,10 @@ class RealAutofillRuntimeConfigProvider @Inject constructor(
return autofillFeature.canCategorizeUnknownUsername().isEnabled()
}

private fun partialFormSaves(): Boolean {
return autofillFeature.partialFormSaves().isEnabled()
}

private suspend fun canShowInContextEmailProtectionSignup(url: String?): Boolean {
if (url == null) return false
return emailProtectionInContextAvailabilityRules.permittedToShow(url)
Original file line number Diff line number Diff line change
@@ -39,6 +39,7 @@ interface RuntimeConfigurationWriter {
showInlineKeyIcon: Boolean,
showInContextEmailProtectionSignup: Boolean,
unknownUsernameCategorization: Boolean,
partialFormSaves: Boolean,
): String
}

@@ -88,6 +89,7 @@ class RealRuntimeConfigurationWriter @Inject constructor(val moshi: Moshi) : Run
showInlineKeyIcon: Boolean,
showInContextEmailProtectionSignup: Boolean,
unknownUsernameCategorization: Boolean,
partialFormSaves: Boolean,
): String {
return """
userPreferences = {
@@ -108,6 +110,7 @@ class RealRuntimeConfigurationWriter @Inject constructor(val moshi: Moshi) : Run
"inlineIcon_credentials": $showInlineKeyIcon,
"emailProtection_incontext_signup": $showInContextEmailProtectionSignup,
"unknown_username_categorization": $unknownUsernameCategorization,
"partial_form_saves": $partialFormSaves
}
}
}
Original file line number Diff line number Diff line change
@@ -84,6 +84,7 @@ class RealAutofillRuntimeConfigProviderTest {
showInlineKeyIcon = any(),
showInContextEmailProtectionSignup = any(),
unknownUsernameCategorization = any(),
partialFormSaves = any(),
),
).thenReturn("")
}
@@ -394,6 +395,7 @@ class RealAutofillRuntimeConfigProviderTest {
showInlineKeyIcon = any(),
showInContextEmailProtectionSignup = any(),
unknownUsernameCategorization = any(),
partialFormSaves = any(),
)
}

@@ -405,6 +407,7 @@ class RealAutofillRuntimeConfigProviderTest {
showInlineKeyIcon = any(),
showInContextEmailProtectionSignup = any(),
unknownUsernameCategorization = any(),
partialFormSaves = any(),
)
}

@@ -420,6 +423,7 @@ class RealAutofillRuntimeConfigProviderTest {
showInlineKeyIcon = eq(true),
showInContextEmailProtectionSignup = any(),
unknownUsernameCategorization = any(),
partialFormSaves = any(),
)
}

Original file line number Diff line number Diff line change
@@ -94,6 +94,7 @@ class RealRuntimeConfigurationWriterTest {
"inlineIcon_credentials": true,
"emailProtection_incontext_signup": true,
"unknown_username_categorization": false,
"partial_form_saves": false
}
}
}
@@ -109,6 +110,7 @@ class RealRuntimeConfigurationWriterTest {
showInlineKeyIcon = true,
showInContextEmailProtectionSignup = true,
unknownUsernameCategorization = false,
partialFormSaves = false,
),
)
}