diff --git a/autofill/autofill-internal/src/main/java/com/duckduckgo/autofill/internal/AutofillInternalSettingsActivity.kt b/autofill/autofill-internal/src/main/java/com/duckduckgo/autofill/internal/AutofillInternalSettingsActivity.kt index cc202930933f..e3712e6dd51e 100644 --- a/autofill/autofill-internal/src/main/java/com/duckduckgo/autofill/internal/AutofillInternalSettingsActivity.kt +++ b/autofill/autofill-internal/src/main/java/com/duckduckgo/autofill/internal/AutofillInternalSettingsActivity.kt @@ -21,6 +21,7 @@ import android.app.Activity import android.content.Context import android.content.Intent import android.os.Bundle +import android.webkit.CookieManager import android.widget.Toast import androidx.activity.result.contract.ActivityResultContracts import androidx.core.content.IntentCompat @@ -317,6 +318,10 @@ class AutofillInternalSettingsActivity : DuckDuckGoActivity() { importCsvLauncher.launch(intent) } + binding.importPasswordsGoogleLogoutButton.setClickListener { + clearGoogleCookies() + } + binding.importPasswordsResetImportedFlagButton.setClickListener { lifecycleScope.launch(dispatchers.io()) { autofillStore.hasDismissedMainAppSettingsPromo = false @@ -651,6 +656,21 @@ class AutofillInternalSettingsActivity : DuckDuckGoActivity() { return LoginCredentials(username = username, password = password, domain = domain) } + private fun clearGoogleCookies() { + val cookieManager = CookieManager.getInstance() + val domain = ".google.com" + + cookieManager.getCookie(domain)?.let { cookies -> + cookies.split(";").forEach { cookie -> + val cookieName = cookie.substringBefore("=").trim() + cookieManager.setCookie(domain, "$cookieName=; Max-Age=0; Path=/") + } + } + cookieManager.flush() + + Toast.makeText(this, R.string.autofillDevSettingsGoogleLogoutSuccess, Toast.LENGTH_SHORT).show() + } + companion object { fun intent(context: Context): Intent { return Intent(context, AutofillInternalSettingsActivity::class.java) diff --git a/autofill/autofill-internal/src/main/res/layout/activity_autofill_internal_settings.xml b/autofill/autofill-internal/src/main/res/layout/activity_autofill_internal_settings.xml index 2b2705f41e0c..0227d624b062 100644 --- a/autofill/autofill-internal/src/main/res/layout/activity_autofill_internal_settings.xml +++ b/autofill/autofill-internal/src/main/res/layout/activity_autofill_internal_settings.xml @@ -124,6 +124,13 @@ android:layout_height="wrap_content" app:primaryText="@string/autofillDevSettingsImportPasswordsImportPasswordsCsvTitle" /> + + Launch Google Passwords (normal tab) Launch Google Passwords (import flow) Import CSV + Google Account Logout + Tap to clear all Google cookies + Google cookies cleared %1$d passwords imported from Google Clear Previous Google Imports interactions Tap to forget whether we\'ve previously imported, what we chose when previously prompted etc…