CEF3: How can I pass CefBrowser object to other process?

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.

CEF3: How can I pass CefBrowser object to other process?

Postby Czarek » Thu Jan 10, 2013 11:35 am

Hi,

CefRenderProcessHandler::OnBrowserCreated(CefBrowser browser) is called on the Render process,
how can I forward this event / pass this browser object to main application process (Browser process
in that case)? I could pass an identifier, but seems there is no function like GetBrowserByIdentifier()
that would return CefBrowser for given identifier. What are mine options?

Czarek.
Last edited by Czarek on Thu Jan 10, 2013 5:36 pm, edited 1 time in total.
Maintainer of the CEF Python, PHP Desktop and CEF C API projects. My LinkedIn.
User avatar
Czarek
Virtuoso
 
Posts: 1927
Joined: Sun Nov 06, 2011 2:12 am

Re: CEF3: How can I pass CefBrowser object to ther process?

Postby magreenblatt » Thu Jan 10, 2013 1:57 pm

CefBrowser::SendProcessMessage from the render process ends up calling CefClient::OnProcessMessageReceived in the browser process. The associated CefBrowser is passed as a parameter to OnProcessMessageReceived. Does that satisfy your use case?
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: CEF3: How can I pass CefBrowser object to ther process?

Postby Czarek » Thu Jan 10, 2013 3:42 pm

magreenblatt wrote:CefBrowser::SendProcessMessage from the render process ends up calling CefClient::OnProcessMessageReceived in the browser process. The associated CefBrowser is passed as a parameter to OnProcessMessageReceived. Does that satisfy your use case?


That would work great. Thank you for the hint.

In CefRenderProcessHandler I see other methods that have more than only browser in
parameters, for example OnBeforeNavigation has CefFrame & CefRequest, is it also
possible to forward them to Browser process?
Maintainer of the CEF Python, PHP Desktop and CEF C API projects. My LinkedIn.
User avatar
Czarek
Virtuoso
 
Posts: 1927
Joined: Sun Nov 06, 2011 2:12 am

Re: CEF3: How can I pass CefBrowser object to ther process?

Postby magreenblatt » Thu Jan 10, 2013 6:06 pm

Czarek wrote:In CefRenderProcessHandler I see other methods that have more than only browser in
parameters, for example OnBeforeNavigation has CefFrame & CefRequest, is it also
possible to forward them to Browser process?

Frames can be uniquely identified using CefFrame::GetIdentifier(). For requests you would need to serialize them into a CefProcessMessage and pass them in that way.
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: CEF3: How can I pass CefBrowser object to other process?

Postby Czarek » Thu Jan 10, 2013 6:42 pm

I can loop through all frames and get it by identifier, yes, that should work. Thank you.
Maintainer of the CEF Python, PHP Desktop and CEF C API projects. My LinkedIn.
User avatar
Czarek
Virtuoso
 
Posts: 1927
Joined: Sun Nov 06, 2011 2:12 am

Re: CEF3: How can I pass CefBrowser object to other process?

Postby magreenblatt » Thu Jan 10, 2013 7:06 pm

Czarek wrote:I can loop through all frames and get it by identifier, yes, that should work. Thank you.

You don't need to loop, use CefBrowser::GetFrame.
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: CEF3: How can I pass CefBrowser object to other process?

Postby Czarek » Thu Jan 10, 2013 7:08 pm

magreenblatt wrote:
Czarek wrote:I can loop through all frames and get it by identifier, yes, that should work. Thank you.

You don't need to loop, use CefBrowser::GetFrame.


Ahh I missed that, CEF 3 api seems still new to me, there was no such method in CEF 1, thanks.
Maintainer of the CEF Python, PHP Desktop and CEF C API projects. My LinkedIn.
User avatar
Czarek
Virtuoso
 
Posts: 1927
Joined: Sun Nov 06, 2011 2:12 am


Return to Support Forum

Who is online

Users browsing this forum: No registered users and 206 guests