Skip to content

Commit

Permalink
Add WebView compatibility check before launching GPM in dev settings (#…
Browse files Browse the repository at this point in the history
…5527)

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

### Description

### Steps to test this PR
QA optional but if you want to….

- [ ] Install `internal` build on a device/emulator with old `WebView`
- [ ] Access `Settings->Autofill Dev Settings`
- [ ] Tap on `Launch Google Passwords (import flow)`
- [ ] Verify you see a toast saying `WebView` isn’t compatible
- [ ] Repeat this on a device/emulator with a compatible, modern
`WebView` and ensure the flow can be launched


Fixes #5499

Co-authored-by: Craig Russell <[email protected]>
  • Loading branch information
CDRussell and CDRussell authored Jan 24, 2025
1 parent 56082d7 commit 629c460
Showing 1 changed file with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ import androidx.lifecycle.Lifecycle.State.STARTED
import androidx.lifecycle.lifecycleScope
import androidx.lifecycle.repeatOnLifecycle
import com.duckduckgo.anvil.annotations.InjectWith
import com.duckduckgo.app.browser.api.WebViewCapabilityChecker
import com.duckduckgo.app.browser.api.WebViewCapabilityChecker.WebViewCapability.DocumentStartJavaScript
import com.duckduckgo.app.browser.api.WebViewCapabilityChecker.WebViewCapability.WebMessageListener
import com.duckduckgo.app.tabs.BrowserNav
import com.duckduckgo.autofill.api.AutofillFeature
import com.duckduckgo.autofill.api.AutofillScreens.AutofillSettingsScreen
Expand Down Expand Up @@ -134,6 +137,9 @@ class AutofillInternalSettingsActivity : DuckDuckGoActivity() {
@Inject
lateinit var autofillImportPasswordConfigStore: AutofillImportPasswordConfigStore

@Inject
lateinit var webViewCapabilityChecker: WebViewCapabilityChecker

private var passwordImportWatcher = ConflatedJob()

// used to output duration of import
Expand Down Expand Up @@ -289,8 +295,17 @@ class AutofillInternalSettingsActivity : DuckDuckGoActivity() {
}
}
binding.importPasswordsLaunchGooglePasswordCustomFlow.setClickListener {
val intent = globalActivityStarter.startIntent(this, AutofillImportViaGooglePasswordManagerScreen)
importGooglePasswordsFlowLauncher.launch(intent)
lifecycleScope.launch {
val webViewWebMessageSupport = webViewCapabilityChecker.isSupported(WebMessageListener)
val webViewDocumentStartJavascript = webViewCapabilityChecker.isSupported(DocumentStartJavaScript)
if (webViewDocumentStartJavascript && webViewWebMessageSupport) {
val intent =
globalActivityStarter.startIntent(this@AutofillInternalSettingsActivity, AutofillImportViaGooglePasswordManagerScreen)
importGooglePasswordsFlowLauncher.launch(intent)
} else {
Toast.makeText(this@AutofillInternalSettingsActivity, "WebView version not supported", Toast.LENGTH_SHORT).show()
}
}
}

binding.importPasswordsImportCsv.setClickListener {
Expand Down

0 comments on commit 629c460

Please sign in to comment.