- Code: Select all
//CefRunMessageLoop();
while (true)
{
CefDoMessageLoopWork();
if (!CefCurrentlyOn(TID_RENDERER))
{
CefPostTask(TID_RENDERER, base::Bind(&MyFunc));
}
Sleep(1);
}
I need to access the CefV8Context.
Win10, x64
CEF x86
VS 2015
//CefRunMessageLoop();
while (true)
{
CefDoMessageLoopWork();
if (!CefCurrentlyOn(TID_RENDERER))
{
CefPostTask(TID_RENDERER, base::Bind(&MyFunc));
}
Sleep(1);
}
fddima wrote:Read wiki JavaScriptIntegration first. TID_RENDERER is thread in renderer process, not main process.
zezba9000 wrote:"MyRenderProcessHandler::OnContextCreated" never fires in "SimpleApp" example.
I add the interface "CefRenderProcessHandler" and override "OnContextCreated". Does nothing.
Czarek wrote:zezba9000 wrote:"MyRenderProcessHandler::OnContextCreated" never fires in "SimpleApp" example.
I add the interface "CefRenderProcessHandler" and override "OnContextCreated". Does nothing.
Make sure to pass handler to CefExecuteProcess and attach debugger to the subprocess.
// Provide CEF with command-line arguments.
CefMainArgs main_args(hInstance);
// CEF applications have multiple sub-processes (render, plugin, GPU, etc)
// that share the same executable. This function checks the command-line and,
// if this is a sub-process, executes the appropriate logic.
CefRefPtr<SimpleApp> app(new SimpleApp);
int exit_code = CefExecuteProcess(main_args, app, sandbox_info);
if (exit_code >= 0) {
// The sub-process has completed so return here.
return exit_code;
}
// Specify CEF global settings here.
CefSettings settings;
#if !defined(CEF_USE_SANDBOX)
settings.no_sandbox = true;
#endif
// SimpleApp implements application-level callbacks for the browser process.
// It will create the first browser instance in OnContextInitialized() after
// CEF has initialized.
// CefRefPtr<SimpleApp> app(new SimpleApp);
// Initialize CEF.
CefInitialize(main_args, settings, app, sandbox_info);
// Run the CEF message loop. This will block until CefQuitMessageLoop() is
// called.
//auto t = std::thread(Foo, app.get());
CefRunMessageLoop();
class SimpleApp : public CefApp,
public CefBrowserProcessHandler,
public CefRenderProcessHandler
{
public:
SimpleApp();
CefRefPtr<CefBrowser> browser;
CefRefPtr<SimpleHandler> handler;
// CefRefPtr<CefBrowserProcessHandler> render;
virtual void OnContextCreated(CefRefPtr<CefBrowser> browser2,
CefRefPtr<CefFrame> frame,
CefRefPtr<CefV8Context> context) override;
virtual CefRefPtr<CefRenderProcessHandler> GetRenderProcessHandler() OVERRIDE
{
return this;
}
CefRefPtr<SimpleApp> app(new SimpleApp);
int exit_code = CefExecuteProcess(main_args, app, sandbox_info);
Users browsing this forum: Google [Bot] and 69 guests