这篇文章的前提你的libcef能够正常启动,能打开一个基本的网页,但是不清楚一些接口怎样在render进程调用和调试的人来说的。
第一步,实现“CefRenderProcessHandler”接口,关键代码:
class ClientApp : public CefApp,
public CefRenderProcessHandler{
public:
ClientApp();
// CefApp methods:
virtual CefRefPtr<CefRenderProcessHandler> GetRenderProcessHandler()
OVERRIDE { return this; }
virtual void OnWebKitInitialized()OVERRIDE;
}
第二步,初始化libcef的时候创建render进程:
CefMainArgs mainArgs;
CefSettings settings;
CefRefPtr<CefApp> app;
settings.multi_threaded_message_loop = true;
settings.log_severity = LOGSEVERITY_DISABLE;
CefString(&settings.locale).FromWString(L"zh-CN");
void* sandbox_info = NULL;
CefRefPtr<ClientApp> CefApp(new ClientApp);
int exit_code = CefExecuteProcess(mainArgs, CefApp, sandbox_info);
bool lbRet = CefInitialize(mainArgs, sett