WICG / ua-client-hints

Wouldn't it be nice if `User-Agent` was a (set of) client hints?
https://wicg.github.io/ua-client-hints/
Other
582 stars 75 forks source link

Client hints for WebView-based apps #280

Open dgstpierre opened 2 years ago

dgstpierre commented 2 years ago

In the current user agent we have an indicator of 'wv' that assists with identifying web apps. As well as the web app adding it's identity. I don't see anything that accounts for this, looks like lost functionality.

miketaylr commented 2 years ago

In the current user agent we have an indicator of 'wv' that assists with identifying web apps.

Can you clarify what you mean by web apps? Do you mean native apps with a webview component?

dgstpierre commented 2 years ago

Yes that is what I mean. The user agent currently has 'wv' in it to indicate.

miketaylr commented 2 years ago

Thanks, changing the title accordingly. This seems useful to consider.

ronancremin commented 2 years ago

Note that the Chromium blog stated that "have no plans to change the User-Agent string on Android WebView or Chrome for iOS at this time, but will make public updates if and when that changes."

So, by default, apps using the default Chrome-based Android webview ("Android System WebView") will presumably continue to behave as before—perhaps @miketaylr can confirm.

miketaylr commented 2 years ago

Correct, this is not an announcement that anything is changing from what is previously announced. To be clear, I'm saying it may be useful to consider a specific type of client hint to a webview.

ronancremin commented 2 years ago

Understood, thanks.

dgstpierre commented 1 year ago

I wanted to check in on this with the user agent reduction coming for mobile devices in a few months. Will the user agent reduction remove wv? Or will it still be there to fall back on if user agent hints doesn't add a way to support it? Thanks

Sora2455 commented 1 year ago

Why couldn't the browser just be listed as "Chrome WV" instead of "Chrome"?

miketaylr commented 1 year ago

I wanted to check in on this with the user agent reduction coming for mobile devices in a few months. Will the user agent reduction remove wv? Or will it still be there to fall back on if user agent hints doesn't add a way to support it? Thanks

The upcoming changes won't affect webview. Right now webview doesn't support client hints, which I consider a blocker for any UA reduction effort. But that will soon change (see https://groups.google.com/a/chromium.org/g/blink-dev/c/N_Y40YIHMtI). If and when we have a plan for webview reduction, we'll be sure to make it public and give devs plenty of time to prep for it/provide feedback, etc.

miketaylr commented 10 months ago

See also https://github.com/WICG/ua-client-hints/issues/219#issuecomment-1749217579

In particular we would like to see User-Agent Client Hints to indicate:

If the traffic is coming from a WebView The source application that the browser session is coming from

The first would be covered by a hint that expressed "hey i'm a webview", and the second would be basically X-Requested-With, right? That was recently removed AFAIU: https://chromestatus.com/feature/5160086884843520

jross1012 commented 10 months ago

That's right, it would be great to see this supported with Client Hints.

miketaylr commented 10 months ago

Note to self, this seems relevant: https://android-developers.googleblog.com/2023/02/improving-user-privacy-by-requiring-opt-in-to-send-x-requested-wih-header-from-webview.html

Tanych commented 10 months ago

the sec-ch-ua client hints already support to identify the traffic coming from WebView

for android it would be like:

Shivaansh-Agarwal commented 3 months ago

The sec-ch-ua is available but it doesn't seem to be a reliable approach as some browsers still don't support it. https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Sec-CH-UA#browser_compatibility

bvattikonda commented 1 month ago

Any update on this issue? Sec-CH-UA supports identifying traffic that is coming from webview. But, the issue of using client hints to identify source application remains unresolved.

Tanych commented 1 month ago

the app can override the user agent metadata to give their own client hints, e.g. they can add their own brand version: https://developer.android.com/reference/androidx/webkit/WebSettingsCompat#setUserAgentMetadata(android.webkit.WebSettings,androidx.webkit.UserAgentMetadata)