How to get default user agent?

Having problems with building or using CEF's C/C++ APIs? This forum is here to help. Please do not post bug reports or feature requests here.

How to get default user agent?

Postby Streamlet » Wed Aug 28, 2019 1:51 am

I found a pull request not accepted because lack of feedback:
https://bitbucket.org/chromiumembedded/ ... t-the-user

I am coming to increase the number of feedback here.


The default ua string is likely to be:
Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.142 Safari/537.36

Usually we want to append our app info on the end, not modify it from blank. We are not easy to rebuild the default ua string for these reasons:
1. The platfrom info "Windows NT 10.0; WOW64" depends on platforms
2. We can not get webkit version "537.36" through cef_version.h

Would you please consider the idea to add such an api again?
Streamlet
Mentor
 
Posts: 61
Joined: Tue Aug 27, 2019 6:47 am

Re: How to get default user agent?

Postby magreenblatt » Wed Aug 28, 2019 9:53 am

You can get the Chrome version from cef_version.h. Use CefSettings.product_version to build a string that contains the Chrome version plus your product-specific string. That value will then be inserted into the default User-Agent string.
magreenblatt
Site Admin
 
Posts: 12408
Joined: Fri May 29, 2009 6:57 pm

Re: How to get default user agent?

Postby Streamlet » Wed Aug 28, 2019 9:08 pm

magreenblatt wrote:You can get the Chrome version from cef_version.h. Use CefSettings.product_version to build a string that contains the Chrome version plus your product-specific string. That value will then be inserted into the default User-Agent string.


that works well! thank you.
Streamlet
Mentor
 
Posts: 61
Joined: Tue Aug 27, 2019 6:47 am


Return to Support Forum

Who is online

Users browsing this forum: No registered users and 39 guests