How to detect JCEF/Browser version?

Having problems with building or using the JCEF Java binding? Ask your questions here.

How to detect JCEF/Browser version?

Postby bluechips23 » Thu Oct 15, 2015 1:01 pm

When I do
Code: Select all
navigator.userAgent
or
Code: Select all
navigator.appName
on a web page accessed through JCEF, I get similar results to the one running on Google Chrome.

Is there a way, using JavaScript on the web app, to identify that we are using JCEF instead of Google Chrome?
bluechips23
Techie
 
Posts: 12
Joined: Tue Nov 11, 2014 10:58 am

Re: How to detect JCEF/Browser version?

Postby magreenblatt » Thu Oct 15, 2015 1:36 pm

bluechips23 wrote:Is there a way, using JavaScript on the web app, to identify that we are using JCEF instead of Google Chrome?

Not by default. The app would need to explicitly choose to expose that information (custom User-Agent, custom JS API, etc).
magreenblatt
Site Admin
 
Posts: 12382
Joined: Fri May 29, 2009 6:57 pm

Re: How to detect JCEF/Browser version?

Postby bluechips23 » Thu Oct 15, 2015 4:10 pm

I ended up doing a hack:

Code: Select all
if(typeof window.cefQuery === 'function') {
    console.log("We are working within JCEF");
} else {
    console.log("We are either not in JCEF, or CefMessageRouter has no definition or handler for 'cefQuery'");
}


The caveat is that one has to define a message router with "cefQuery" for this to work.
bluechips23
Techie
 
Posts: 12
Joined: Tue Nov 11, 2014 10:58 am

Re: How to detect JCEF/Browser version?

Postby magreenblatt » Thu Oct 15, 2015 6:30 pm

Are you trying to identify generic JCEF applications or one that you control? If you control the application then you can modify the helper executable to always expose a property (for example, window.i_am_jcef). See the CEF JavaScriptIntegration wiki page for instructions on how to accomplish that using C++.
magreenblatt
Site Admin
 
Posts: 12382
Joined: Fri May 29, 2009 6:57 pm


Return to JCEF Forum

Who is online

Users browsing this forum: No registered users and 19 guests