@@ -50,14 +50,12 @@ class RealClientBrandHintProvider @Inject constructor(
50
50
private var currentBranding: ClientBrandsHints = DDG
51
51
52
52
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 )
61
59
}
62
60
}
63
61
@@ -136,6 +134,12 @@ class RealClientBrandHintProvider @Inject constructor(
136
134
settings : WebSettings ,
137
135
branding : ClientBrandsHints ,
138
136
) {
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
+
139
143
currentBranding = branding
140
144
val metadata = WebSettingsCompat .getUserAgentMetadata(settings)
141
145
val finalBrandList = metadata.brandVersionList.map {
0 commit comments