可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
Who tried add native function to javascript in CEF? It was not work, simple to reappear:
- download the CEF3 binary package (1750)
- open cefclient2010.sln
- open client_app.cpp which in cefclient project
- goto line 110, set a breakpoint
- F5
- input any url, any try, the breakpoint never breaked
Am I missed some steps? or some settings?
回答1:
i had the same problem you must add CefRenderProcessHandler interface in SimpleApp ,then the most important is you must implement CefApp::GetRenderProcessHandler() method
. just like this:
virtual CefRefPtr<CefRenderProcessHandler> GetRenderProcessHandler() { return this; }
by default, the base class return NULL,so OnContextCreated()
will not call.
回答2:
Perhaps it has something to do with the process model? How can you tell if the function is getting called? If by using a debugger, make sure you attached all child-processes too.
回答3:
By default sample CEF application is multi-process. Either attach CEF render process to the debugger or simply do following (force the CEF app run into single process mode):
CefSettings settings; #ifdef _DEBUG settings.single_process = true; #endif