Skip to content

Commit 393c5ac

Browse files
Client hint feature gate (#6621)
Task/Issue URL: https://app.asana.com/1/137249556945/project/414730916066338/task/1211100004323098?focus=true ### Description ### Steps to test this PR _Feature 1_ - [ ] - [ ] ### UI changes | Before | After | | ------ | ----- | !(Upload before screenshot)|(Upload after screenshot)| Co-authored-by: Craig Russell <[email protected]>
1 parent 946531f commit 393c5ac

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

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

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,12 @@ class RealClientBrandHintProvider @Inject constructor(
5050
private var currentBranding: ClientBrandsHints = DDG
5151

5252
override fun setDefault(settings: WebSettings) {
53-
if (WebViewFeature.isFeatureSupported(WebViewFeature.USER_AGENT_METADATA)) {
54-
if (clientBrandHintFeature.self().isEnabled()) {
55-
logcat(VERBOSE) { "ClientBrandHintProvider: branding enabled, initialising metadata with DuckDuckGo branding" }
56-
setUserAgentMetadata(settings, DEFAULT_ENABLED_BRANDING)
57-
} else {
58-
logcat(VERBOSE) { "ClientBrandHintProvider: branding disabled, initialising metadata with Google Chrome branding" }
59-
setUserAgentMetadata(settings, DEFAULT_DISABLED_BRANDING)
60-
}
53+
if (clientBrandHintFeature.self().isEnabled()) {
54+
logcat(VERBOSE) { "ClientBrandHintProvider: branding enabled, initialising metadata with DuckDuckGo branding" }
55+
setUserAgentMetadata(settings, DEFAULT_ENABLED_BRANDING)
56+
} else {
57+
logcat(VERBOSE) { "ClientBrandHintProvider: branding disabled, initialising metadata with Google Chrome branding" }
58+
setUserAgentMetadata(settings, DEFAULT_DISABLED_BRANDING)
6159
}
6260
}
6361

@@ -136,6 +134,12 @@ class RealClientBrandHintProvider @Inject constructor(
136134
settings: WebSettings,
137135
branding: ClientBrandsHints,
138136
) {
137+
// Check if WebView supports user agent metadata
138+
if (!WebViewFeature.isFeatureSupported(WebViewFeature.USER_AGENT_METADATA)) {
139+
logcat(VERBOSE) { "ClientBrandHintProvider: USER_AGENT_METADATA not supported by WebView, skipping" }
140+
return
141+
}
142+
139143
currentBranding = branding
140144
val metadata = WebSettingsCompat.getUserAgentMetadata(settings)
141145
val finalBrandList = metadata.brandVersionList.map {

0 commit comments

Comments
 (0)