Czarek wrote:Just make sure that you call CefV8Context::IsValid before doing any operations. Do not keep any references to context after OnContextReleased is called.
Streamlet wrote:Czarek wrote:You can use CefRenderProcessHandler::OnBrowserCreated and send IPC message to the Browser precess. In CefClient::OnProcessMessageReceived there is CefBrowser parameter.
Excuese me please,
in OnBrowserCreated, browser->GetMainFrame() returns nullptr,so I cannot do browser->GetMainFrame()->SendProcessMessage
Streamlet wrote:My purpose is send infomation about JS injection to render process before its OnContextCreated, and in OnContextCreated I will put JS variables into context.
Curently my walkaround is, send IPC message when OnRenderViewReady, the IPC message usually arrived before OnContextCreated.
But when a browser navigates to a new URL and triggers creation of new site instance, the IPC message arrived after OnContextCreated.
So I need to judge if IPC message have arrived in OnContextCreated.
If it does, then I can set JS env to context;
if not, I do this inside OnProcessMessageReceived, so I need to save context in OnContextCreated and use it in OnProcessMessageReceived, calling context->GetTaskRunner()->PostTask, context->Enter(), do with context, context->Exit()
The solution looks too complex...
Is there a simple way to send message to render process before OnContextCreated?
magreenblatt wrote:You can pass extra_info parameters to CreateBrowser which are then delivered to CefRenderProcessHandler::OnBrowserCreated. That call should occur before OnContextCreated.
Streamlet wrote:magreenblatt wrote:You can pass extra_info parameters to CreateBrowser which are then delivered to CefRenderProcessHandler::OnBrowserCreated. That call should occur before OnContextCreated.
there is no CefBrowser param through this way...
Streamlet wrote:Oh, I'm sorry. There is a browser param, but browser->GetMainFrame() returns nullptr.
so I cannot do browser->GetMainFrame()->SendProcessMessage()
Streamlet wrote:My purpose is send infomation about JS injection to render process before its OnContextCreated, and in OnContextCreated I will put JS variables into context.
magreenblatt wrote:And why do you want to do that? OnBrowserCreated is already in the renderer process. You said previously:
Streamlet wrote:When a renderer process is created for a DevTools, the extra_info doesn't contains any data?
will DevTools create a new CefBrowser object?
Users browsing this forum: No registered users and 47 guests