Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ class AutofillParserImpl(
val urlBarWebsite = traversalDataList
.flatMap { it.urlBarWebsites }
.firstOrNull()
?.takeIf { settingsRepository.isAutofillWebDomainCompatMode }

// Take only the autofill views from the node that currently has focus.
// Then remove all the fields that cannot be filled with data.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,6 @@ interface SettingsDiskSource {
*/
var browserAutofillDialogReshowTime: Instant?

/**
* The current status of whether the web domain compatibility mode is enabled.
*/
var isAutofillWebDomainCompatMode: Boolean?

/**
* Clears all the settings data for the given user.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ private const val RESUME_SCREEN = "resumeScreen"
private const val FLIGHT_RECORDER_KEY = "flightRecorderData"
private const val IS_DYNAMIC_COLORS_ENABLED = "isDynamicColorsEnabled"
private const val BROWSER_AUTOFILL_DIALOG_RESHOW_TIME = "browserAutofillDialogReshowTime"
private const val AUTOFILL_WEB_DOMAIN_COMPATIBILITY = "autofillWebDomainCompatibility"

/**
* Primary implementation of [SettingsDiskSource].
Expand Down Expand Up @@ -235,12 +234,6 @@ class SettingsDiskSourceImpl(
putLong(key = BROWSER_AUTOFILL_DIALOG_RESHOW_TIME, value = value?.toEpochMilli())
}

override var isAutofillWebDomainCompatMode: Boolean?
get() = getBoolean(key = AUTOFILL_WEB_DOMAIN_COMPATIBILITY)
set(value) {
putBoolean(key = AUTOFILL_WEB_DOMAIN_COMPATIBILITY, value = value)
}

override fun clearData(userId: String) {
storeVaultTimeoutInMinutes(userId = userId, vaultTimeoutInMinutes = null)
storeVaultTimeoutAction(userId = userId, vaultTimeoutAction = null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,6 @@ interface SettingsRepository : FlightRecorderManager {
*/
var isAutofillSavePromptDisabled: Boolean

/**
* Whether or not the autofill web domain parsing is enabled.
*/
var isAutofillWebDomainCompatMode: Boolean

/**
* A list of blocked autofill URI's for the current user.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -338,12 +338,6 @@ class SettingsRepositoryImpl(
)
}

override var isAutofillWebDomainCompatMode: Boolean
get() = settingsDiskSource.isAutofillWebDomainCompatMode ?: false
set(value) {
settingsDiskSource.isAutofillWebDomainCompatMode = value
}

override var blockedAutofillUris: List<String>
get() = activeUserId
?.let { settingsDiskSource.getBlockedAutofillUris(userId = it) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@ import androidx.compose.ui.input.nestedscroll.nestedScroll
import androidx.compose.ui.platform.LocalResources
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.semantics.CustomAccessibilityAction
import androidx.compose.ui.semantics.customActions
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.unit.dp
import androidx.core.net.toUri
import androidx.hilt.lifecycle.viewmodel.compose.hiltViewModel
Expand Down Expand Up @@ -137,13 +134,6 @@ fun AutoFillScreen(
intentManager.launchUri("https://bitwarden.com/help/uri-match-detection/".toUri())
}

AutoFillEvent.NavigateToCompatibilityModeLearnMore -> {
intentManager.launchUri(
uri = "https://bitwarden.com/help/auto-fill-android/#compatibility-mode"
.toUri(),
)
}

AutoFillEvent.NavigateToAutofillHelp -> {
intentManager.launchUri(
uri = "https://bitwarden.com/help/auto-fill-android-troubleshooting/".toUri(),
Expand Down Expand Up @@ -255,20 +245,6 @@ private fun AutoFillScreenContent(
}
}

AnimatedVisibility(visible = state.isAutoFillServicesEnabled) {
Column {
WebDomainCompatibilityModeRow(
isChecked = state.isWebDomainCompatModeEnabled,
onToggle = autoFillHandlers.onWebDomainCompatModeToggled,
onLearnMoreClick = autoFillHandlers.onWebDomainModeCompatLearnMoreClick,
modifier = Modifier
.fillMaxWidth()
.standardHorizontalMargin(),
)
Spacer(modifier = Modifier.height(height = 8.dp))
}
}

if (state.showPasskeyManagementRow) {
BitwardenExternalLinkRow(
text = stringResource(id = BitwardenString.passkey_management),
Expand Down Expand Up @@ -370,76 +346,6 @@ private fun AutoFillScreenContent(
}
}

@Suppress("LongMethod")
@Composable
private fun WebDomainCompatibilityModeRow(
isChecked: Boolean,
onToggle: (isEnabled: Boolean) -> Unit,
onLearnMoreClick: () -> Unit,
modifier: Modifier = Modifier,
) {
var showConfirmationDialog by rememberSaveable { mutableStateOf(false) }
if (showConfirmationDialog) {
BitwardenTwoButtonDialog(
title = stringResource(id = BitwardenString.warning),
message = stringResource(id = BitwardenString.compatibility_mode_warning),
confirmButtonText = stringResource(id = BitwardenString.accept),
dismissButtonText = stringResource(id = BitwardenString.cancel),
onConfirmClick = {
onToggle(true)
showConfirmationDialog = false
},
onDismissClick = { showConfirmationDialog = false },
onDismissRequest = { showConfirmationDialog = false },
)
}

BitwardenSwitch(
label = stringResource(id = BitwardenString.use_compatibility_mode_for_browser_autofill),
isChecked = isChecked,
onCheckedChange = {
if (isChecked) {
onToggle(false)
} else {
showConfirmationDialog = true
}
},
cardStyle = CardStyle.Full,
modifier = modifier,
supportingContent = {
val learnMore = stringResource(id = BitwardenString.learn_more)
Text(
text = annotatedStringResource(
id = BitwardenString
.use_a_less_secure_autofill_method_compatible_with_more_browsers,
style = spanStyleOf(
textStyle = BitwardenTheme.typography.bodyMedium,
color = BitwardenTheme.colorScheme.text.secondary,
),
onAnnotationClick = {
when (it) {
"learnMore" -> onLearnMoreClick()
}
},
),
style = BitwardenTheme.typography.bodyMedium,
color = BitwardenTheme.colorScheme.text.secondary,
modifier = Modifier.semantics {
customActions = listOf(
CustomAccessibilityAction(
label = learnMore,
action = {
onLearnMoreClick()
true
},
),
)
},
)
},
)
}

@Composable
private fun AutofillCallToActionCard(
state: AutoFillState,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ class AutoFillViewModel @Inject constructor(
browserAutofillSettingsOptions = browserThirdPartyAutofillEnabledManager
.browserThirdPartyAutofillStatus
.toBrowserAutoFillSettingsOptions(),
isWebDomainCompatModeEnabled = settingsRepository.isAutofillWebDomainCompatMode,
)
},
) {
Expand Down Expand Up @@ -135,10 +134,6 @@ class AutoFillViewModel @Inject constructor(
AutoFillAction.PrivilegedAppsClick -> handlePrivilegedAppsClick()
AutoFillAction.LearnMoreClick -> handleLearnMoreClick()
AutoFillAction.HelpCardClick -> handleHelpCardClick()
is AutoFillAction.WebDomainModeCompatToggle -> handleWebDomainModeCompatToggle(action)
AutoFillAction.WebDomainModeCompatLearnMoreClick -> {
handleNavigateToCompatibilityModeLearnMore()
}
}

private fun handlePrivilegedAppsClick() {
Expand All @@ -153,15 +148,6 @@ class AutoFillViewModel @Inject constructor(
sendEvent(AutoFillEvent.NavigateToAutofillHelp)
}

private fun handleNavigateToCompatibilityModeLearnMore() {
sendEvent(AutoFillEvent.NavigateToCompatibilityModeLearnMore)
}

private fun handleWebDomainModeCompatToggle(action: AutoFillAction.WebDomainModeCompatToggle) {
settingsRepository.isAutofillWebDomainCompatMode = action.isEnabled
mutableStateFlow.update { it.copy(isWebDomainCompatModeEnabled = action.isEnabled) }
}

private fun handleInternalAction(action: AutoFillAction.Internal) {
when (action) {
is AutoFillAction.Internal.AccessibilityEnabledUpdateReceive -> {
Expand Down Expand Up @@ -319,7 +305,6 @@ data class AutoFillState(
val showBrowserAutofillActionCard: Boolean,
val activeUserId: String,
val browserAutofillSettingsOptions: ImmutableList<BrowserAutofillSettingsOption>,
val isWebDomainCompatModeEnabled: Boolean,
) : Parcelable {
/**
* Indicates which call-to-action that should be displayed.
Expand Down Expand Up @@ -433,11 +418,6 @@ sealed class AutoFillEvent {
*/
data object NavigateToLearnMore : AutoFillEvent()

/**
* Navigate to the web domain learn more site.
*/
data object NavigateToCompatibilityModeLearnMore : AutoFillEvent()

/**
* Navigate to the autofill help page.
*/
Expand Down Expand Up @@ -548,16 +528,6 @@ sealed class AutoFillAction {
*/
data object HelpCardClick : AutoFillAction()

/**
* User has clicked to learn more about compatibility mode.
*/
data object WebDomainModeCompatLearnMoreClick : AutoFillAction()

/**
* User has changed their compatibility setting.
*/
data class WebDomainModeCompatToggle(val isEnabled: Boolean) : AutoFillAction()

/**
* Internal actions.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ class AutoFillHandlers(
val onBlockAutoFillClick: () -> Unit,
val onLearnMoreClick: () -> Unit,
val onHelpCardClick: () -> Unit,
val onWebDomainCompatModeToggled: (isEnabled: Boolean) -> Unit,
val onWebDomainModeCompatLearnMoreClick: () -> Unit,
) {
@Suppress("UndocumentedPublicClass")
companion object {
Expand Down Expand Up @@ -86,12 +84,6 @@ class AutoFillHandlers(
onBlockAutoFillClick = { viewModel.trySendAction(AutoFillAction.BlockAutoFillClick) },
onLearnMoreClick = { viewModel.trySendAction(AutoFillAction.LearnMoreClick) },
onHelpCardClick = { viewModel.trySendAction(AutoFillAction.HelpCardClick) },
onWebDomainCompatModeToggled = {
viewModel.trySendAction(AutoFillAction.WebDomainModeCompatToggle(it))
},
onWebDomainModeCompatLearnMoreClick = {
viewModel.trySendAction(AutoFillAction.WebDomainModeCompatLearnMoreClick)
},
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ class AutofillParserTests {
private val settingsRepository: SettingsRepository = mockk {
every { isInlineAutofillEnabled } answers { mockIsInlineAutofillEnabled }
every { blockedAutofillUris } returns emptyList()
every { isAutofillWebDomainCompatMode } returns false
}

private var mockIsInlineAutofillEnabled = true
Expand Down Expand Up @@ -177,86 +176,13 @@ class AutofillParserTests {

@Suppress("MaxLineLength")
@Test
fun `parse should return Fillable without website in AutofillView from url bar but compatibility mode is off`() {
// Setup
val packageName = "com.microsoft.emmx"
every {
any<List<ViewNodeTraversalData>>().buildPackageNameOrNull(assistStructure)
} returns packageName
every { settingsRepository.isAutofillWebDomainCompatMode } returns false
every { assistStructure.windowNodeCount } returns 2
// Override the idPackage to be Edge's package name.
every { loginViewNode.idPackage } returns packageName
every { assistStructure.getWindowNodeAt(0) } returns loginWindowNode
val urlBarNode: AssistStructure.ViewNode = mockk {
every { autofillHints } returns emptyArray()
every { autofillId } returns null
every { childCount } returns 0
every { idEntry } returns "url_bar"
every { idPackage } returns packageName
every { webDomain } returns "m.facebook.com"
every { webScheme } returns null
}
val urlBarWindowNode: AssistStructure.WindowNode = mockk {
every { this@mockk.rootViewNode } returns urlBarNode
}
every { assistStructure.getWindowNodeAt(1) } returns urlBarWindowNode
val loginAutofillView: AutofillView.Login = AutofillView.Login.Username(
data = AutofillView.Data(
autofillId = loginAutofillId,
autofillOptions = emptyList(),
autofillType = AUTOFILL_TYPE,
isFocused = true,
textValue = null,
hasPasswordTerms = false,
website = null,
),
)
every { loginViewNode.toAutofillView(parentWebsite = any()) } returns loginAutofillView
val autofillPartition = AutofillPartition.Login(
views = listOf(loginAutofillView),
)
val expected = AutofillRequest.Fillable(
ignoreAutofillIds = emptyList(),
inlinePresentationSpecs = inlinePresentationSpecs,
maxInlineSuggestionsCount = MAX_INLINE_SUGGESTION_COUNT,
packageName = packageName,
partition = autofillPartition,
uri = "androidapp://$packageName",
)

// Test
val actual = parser.parse(
autofillAppInfo = autofillAppInfo,
fillRequest = fillRequest,
)

// Verify
assertEquals(expected, actual)
verify(exactly = 1) {
fillRequest.getInlinePresentationSpecs(
autofillAppInfo = autofillAppInfo,
isInlineAutofillEnabled = true,
)
fillRequest.getMaxInlineSuggestionsCount(
autofillAppInfo = autofillAppInfo,
isInlineAutofillEnabled = true,
)
any<List<ViewNodeTraversalData>>().buildPackageNameOrNull(assistStructure)
any<AutofillView>().buildUriOrNull(packageName)
}
}

@Suppress("MaxLineLength")
@Test
fun `parse should return Fillable with website in AutofillView from url bar but compatibility mode is on`() {
fun `parse should return Fillable with website in AutofillView from url bar for compatible browser`() {
// Setup
val website = "https://m.facebook.com"
val packageName = "com.microsoft.emmx"
every {
any<List<ViewNodeTraversalData>>().buildPackageNameOrNull(assistStructure)
} returns packageName
every { settingsRepository.isAutofillWebDomainCompatMode } returns true
every { assistStructure.windowNodeCount } returns 2
// Override the idPackage to be Edge's package name.
every { loginViewNode.idPackage } returns packageName
Expand Down
Loading
Loading