Skip to content

Commit

Permalink
Revert "Use safeWebMessageHandler code for autofill integration"
Browse files Browse the repository at this point in the history
This reverts commit 676e4c1.
  • Loading branch information
cmonfortep committed Oct 9, 2024
1 parent 7d1ae8d commit ce5b52b
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 130 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class DuckDuckGoWebView : WebView, NestedScrollingChild3 {
private var nestedScrollHelper: NestedScrollingChildHelper = NestedScrollingChildHelper(this)
private val helper = CoordinatorLayoutHelper()

var isDestroyed: Boolean = false
private var isDestroyed: Boolean = false
var isSafeWebViewEnabled: Boolean = false

constructor(context: Context) : this(context, null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ import com.duckduckgo.app.browser.api.WebViewCapabilityChecker.WebViewCapability
import com.duckduckgo.browser.api.WebViewVersionProvider
import com.duckduckgo.common.utils.DispatcherProvider
import com.duckduckgo.common.utils.extensions.compareSemanticVersion
import com.duckduckgo.di.scopes.AppScope
import com.duckduckgo.di.scopes.FragmentScope
import com.squareup.anvil.annotations.ContributesBinding
import javax.inject.Inject
import kotlinx.coroutines.withContext

@ContributesBinding(AppScope::class)
@ContributesBinding(FragmentScope::class)
class RealWebViewCapabilityChecker @Inject constructor(
private val dispatchers: DispatcherProvider,
private val webViewVersionProvider: WebViewVersionProvider,
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ package com.duckduckgo.autofill.impl

import android.annotation.SuppressLint
import android.webkit.WebView
import com.duckduckgo.app.browser.api.SafeWebMessageHandler
import androidx.webkit.WebViewCompat
import com.duckduckgo.autofill.api.AutofillFeature
import com.duckduckgo.autofill.api.BrowserAutofill
import com.duckduckgo.autofill.api.Callback
Expand Down Expand Up @@ -90,7 +90,7 @@ class InlineBrowserAutofill @Inject constructor(
}
}

private suspend fun WebView.addWebMessageListener(
private fun WebView.addWebMessageListener(
messageListener: AutofillWebMessageListener,
autofillCallback: Callback,
tabId: String,
Expand All @@ -106,24 +106,22 @@ class InlineBrowserAutofill @Inject constructor(
}

interface AutofillWebMessageAttacher {
suspend fun addListener(
fun addListener(
webView: WebView,
listener: AutofillWebMessageListener,
)
}

@SuppressLint("RequiresFeature")
@ContributesBinding(FragmentScope::class)
class AutofillWebMessageAttacherImpl @Inject constructor(
private val safeWebMessageHandler: SafeWebMessageHandler,
) : AutofillWebMessageAttacher {
class AutofillWebMessageAttacherImpl @Inject constructor() : AutofillWebMessageAttacher {

@SuppressLint("AddWebMessageListenerUsage")
// suppress AddWebMessageListenerUsage, we don't have access to DuckDuckGoWebView here.
override suspend fun addListener(
override fun addListener(
webView: WebView,
listener: AutofillWebMessageListener,
) {
safeWebMessageHandler.addWebMessageListener(webView, listener.key, listener.origins, listener)
WebViewCompat.addWebMessageListener(webView, listener.key, listener.origins, listener)
}
}
2 changes: 0 additions & 2 deletions browser-api/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ dependencies {

// LiveData
implementation AndroidX.lifecycle.liveDataKtx

implementation AndroidX.webkit
}
android {
namespace 'com.duckduckgo.browser.api'
Expand Down

This file was deleted.

0 comments on commit ce5b52b

Please sign in to comment.