Disclosure Statement: This site contains affiliate links, which means that I may receive a commission if you make a purchase using these links. As an eBay Partner, I earn from qualifying purchases.

Get the useragent

Post Reply
3vr
Posts: 9
Joined: Mon Feb 26, 2024 7:56 pm

Get the useragent

Post 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
User avatar
salvadordf
Posts: 4057
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Get the useragent

Post by salvadordf »

Hi,

Try calling GetDefaultCEFUserAgent in uCEFMiscFunctions.
3vr
Posts: 9
Joined: Mon Feb 26, 2024 7:56 pm

Re: Get the useragent

Post by 3vr »

Yes I did it. But the string is different.
I put a comparison above.
User avatar
salvadordf
Posts: 4057
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Get the useragent

Post 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.
User avatar
salvadordf
Posts: 4057
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Get the useragent

Post 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
Post Reply