WebPlatformForEmbedded / libwpe

General-purpose library specifically developed for the WPE-flavored port of WebKit.
BSD 2-Clause "Simplified" License
49 stars 36 forks source link

Add User Agent API #100

Open donny-dont opened 2 years ago

donny-dont commented 2 years ago

Allow a libwpe application to set user agent information. The libwpe API maps to values exposed by the User-Agent Client Hints API.

donny-dont commented 2 years ago

So this is a proposal for a new libWPE API. As mentioned it follows along with what is currently in https://wicg.github.io/ua-client-hints which is in draft status so it is subject to change. Chrome does seem to be shipping it if you open up https://user-agent-client-hints.glitch.me/javascript.html in it.

Please feel free to criticize this PR fully. I think it follows along with how the libWPE APIs look but I'm not an expert at how this should look.

Note I don't think this will land as is so I'm just marking it as a WIP and hopefully we can get the discussion around it going.

mcatanzaro commented 2 years ago

This is really tricky. WPE WebKit already has an API for setting the user agent header that would have to be respected if used, but it's not nearly as sophisticated as what you have here. But on the other hand, providing accurate user agent information is rarely desirable: the goal here is to lie enough to make the web work, not expose enough platform details to encourage websites to discriminate.

I don't think WebKit intends to implement client hints, so not sure that the full complexity is really useful.

One way to think about this: what's the advantage of putting this into libwpe rather than just implementing it in UserAgentPlaystation and UserAgentGLib? Are there really device-specific details here that cannot be handled without custom code?