Identifying the browser process in CEF3

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.

Identifying the browser process in CEF3

Postby tashimaya » Mon Oct 20, 2014 10:25 am

In CEF3, what is a recommended way to identify the browser process and distinguish it from the sub-processes like renderer, plugin?

Should I check against the "type" command line-value?

Many thanks
tashimaya
Techie
 
Posts: 36
Joined: Fri Oct 10, 2014 7:18 am

Re: Identifying the browser process in CEF3

Postby magreenblatt » Mon Oct 20, 2014 10:38 am

tashimaya wrote:Should I check against the "type" command line-value?

Yes, it will be empty for the browser process.
magreenblatt
Site Admin
 
Posts: 12382
Joined: Fri May 29, 2009 6:57 pm

Re: Identifying the browser process in CEF3

Postby tashimaya » Tue Oct 21, 2014 3:29 am

Thanks for your reply. But is this the only way? You could always start the host application like:

myCefHostApp.exe --type=custom-flag-value --other-flag=abc ...

This function would fail to detect the browser process.

Code: Select all
bool IsBrowserProcess(args)
{
   return args.contains("--type") ? false : true;
}


I just wonder if there is a more reliable way.
tashimaya
Techie
 
Posts: 36
Joined: Fri Oct 10, 2014 7:18 am

Re: Identifying the browser process in CEF3

Postby Mayhew » Tue Oct 28, 2014 6:34 pm

At some point in your apps main() method you must do something like

// Execute the secondary process, if any.
int exit_code = CefExecuteProcess(cef_args, cef_app.get(), NULL);
if (exit_code >= 0) {
return exit_code;
}

if you set a global variable after that if block, then you could access that to determine that this is the browser process. Secondary processes will not execute any code after that if check.
Mayhew
Expert
 
Posts: 303
Joined: Mon Apr 18, 2011 8:02 pm


Return to Support Forum

Who is online

Users browsing this forum: Google [Bot] and 34 guests