Skip to content

Commit bfa7a1a

Browse files
committed
Address PR comments
1 parent 3154a84 commit bfa7a1a

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

app/src/main/java/com/duckduckgo/app/browser/BrowserTabFragment.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3211,7 +3211,7 @@ class BrowserTabFragment :
32113211
it.clearSslPreferences()
32123212

32133213
it.settings.apply {
3214-
withContext(dispatchers.io()) { clientBrandHintProvider.setDefault(this@apply) }
3214+
clientBrandHintProvider.setDefault(this)
32153215
webViewClient.clientProvider = clientBrandHintProvider
32163216
userAgentString = userAgentProvider.userAgent()
32173217
javaScriptEnabled = true
@@ -3514,7 +3514,7 @@ class BrowserTabFragment :
35143514
webViewCapabilityChecker.isSupported(WebViewCapability.WebMessageListener) &&
35153515
webViewCapabilityChecker.isSupported(WebViewCapability.DocumentStartJavaScript)
35163516

3517-
private suspend fun configureWebViewForAutofill(it: DuckDuckGoWebView) {
3517+
private fun configureWebViewForAutofill(it: DuckDuckGoWebView) {
35183518
it.setSystemAutofillCallback {
35193519
systemAutofillEngagement.onSystemAutofillEvent()
35203520
}

user-agent/user-agent-api/src/main/java/com/duckduckgo/user/agent/api/ClientBrandHintProvider.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ interface ClientBrandHintProvider {
3131
* Sets the default client hint header SEC-CH-UA
3232
* @param settings [WebSettings] where the agent metadata will be set
3333
*/
34-
fun setDefault(settings: WebSettings)
34+
suspend fun setDefault(settings: WebSettings)
3535

3636
/**
3737
* Checks if the url passed as parameter will force a change of branding

user-agent/user-agent-impl/src/main/java/com/duckduckgo/user/agent/impl/ClientBrandHintProvider.kt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import androidx.webkit.UserAgentMetadata
2323
import androidx.webkit.UserAgentMetadata.BrandVersion
2424
import androidx.webkit.WebSettingsCompat
2525
import androidx.webkit.WebViewFeature
26+
import com.duckduckgo.common.utils.DispatcherProvider
2627
import com.duckduckgo.di.scopes.AppScope
2728
import com.duckduckgo.user.agent.api.ClientBrandHintProvider
2829
import com.duckduckgo.user.agent.impl.remoteconfig.BrandingChange
@@ -35,6 +36,7 @@ import com.duckduckgo.user.agent.impl.remoteconfig.ClientBrandsHints.CHROME
3536
import com.duckduckgo.user.agent.impl.remoteconfig.ClientBrandsHints.DDG
3637
import com.duckduckgo.user.agent.impl.remoteconfig.ClientBrandsHints.WEBVIEW
3738
import com.squareup.anvil.annotations.ContributesBinding
39+
import kotlinx.coroutines.withContext
3840
import logcat.LogPriority.INFO
3941
import logcat.LogPriority.VERBOSE
4042
import logcat.logcat
@@ -44,13 +46,14 @@ import javax.inject.Inject
4446
class RealClientBrandHintProvider @Inject constructor(
4547
private val clientBrandHintFeature: ClientBrandHintFeature,
4648
private val repository: ClientBrandHintFeatureSettingsRepository,
49+
private val dispatcherProvider: DispatcherProvider,
4750
) : ClientBrandHintProvider {
4851

4952
private var currentDomain: String? = null
5053
private var currentBranding: ClientBrandsHints = DDG
5154

52-
override fun setDefault(settings: WebSettings) {
53-
if (clientBrandHintFeature.self().isEnabled()) {
55+
override suspend fun setDefault(settings: WebSettings) {
56+
if (withContext(dispatcherProvider.io()) { clientBrandHintFeature.self().isEnabled() }) {
5457
logcat(VERBOSE) { "ClientBrandHintProvider: branding enabled, initialising metadata with DuckDuckGo branding" }
5558
setUserAgentMetadata(settings, DEFAULT_ENABLED_BRANDING)
5659
} else {

0 commit comments

Comments
 (0)