Page 1 of 1

Get the useragent

Posted: Fri Mar 08, 2024 7:38 am
by 3vr
Dear,
How do I get the useragent version of cef?
I tried the code below, but it returns empty.

Code: Select all

GlobalCEFApp.UserAgent
GlobalCEFApp.UserAgentProduct
I later checked the existence of the function

Code: Select all

GetDefaultCEFUserAgent
But it returns a different string than what the browser detects.
Detected
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36
GetDefaultCEFUserAgent
Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.6261.69 Safari/537.36

Re: Get the useragent

Posted: Fri Mar 08, 2024 10:30 am
by salvadordf
Hi,

Try calling GetDefaultCEFUserAgent in uCEFMiscFunctions.

Re: Get the useragent

Posted: Fri Mar 08, 2024 11:30 am
by 3vr
Yes I did it. But the string is different.
I put a comparison above.

Re: Get the useragent

Posted: Fri Mar 08, 2024 4:52 pm
by salvadordf
You're right. Sorry I answered too quickly.

I just uploaded a fixed version of GetDefaultCEFUserAgent to GitHub.

I also added a context menu option called "Browser information..." to the MiniBrowser demo. It uses the "Browser.getVersion" devtools method to get the real user agent string and it also shows the returned GetDefaultCEFUserAgent value.

As you can see, the CEF binaries are not reporting Wow processes correctly but the rest of the user agent string is now correct and GetDefaultCEFUserAgent can be used from Windows, macOS and Linux now.

Use the "Browser.getVersion" devtools method if you want the real user agent string.

Re: Get the useragent

Posted: Fri Mar 08, 2024 5:07 pm
by salvadordf
I just tested the official CEF sample application for Windows 32 bits and it also shows the wrong user agent when you run it in Windows 64 bits :
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36