我和this post的人有类似的问题;我正在尝试扩展chrome嵌入式框架二进制文件中包含的cefsimple.exe应用程序以包含V8处理程序。我实施了OnContextCreated()
方法,并确保在RenderProcessHandler
类中扩展SimpleHandler
。我正在尝试实现一个名为test_string
的简单窗口绑定变量;这是我的代码的样子;
void SimpleHandler::OnContextCreated(
CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
CefRefPtr<CefV8Context> context)
{
CefRefPtr<CefV8Value> object = context->GetGlobal();
object->SetValue("test_string", CefV8Value::CreateString("this is a test"), V8_PROPERTY_ATTRIBUTE_NONE);
}
但是程序永远不会到达我在方法中添加的任何断点,并且在我在应用程序中加载的任何网页上都没有定义变量。我看到另一个线程中的一个解决方案是启用settings.single_process
标志,我已经完成了,但我的代码仍然没有到达断点。
要清楚,我正在使用window.test_string
访问页面上的变量。
确保将CefApp发送到CefExecuteProcess。
CefRefPtr<SimpleApp> app(new SimpleApp);
// 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.
int exit_code = CefExecuteProcess(main_args, app, sandbox_info);
if (exit_code >= 0) {
// The sub-process has completed so return here.
return exit_code;
}
找到这个解决方案here
你读过General Usage
指南吗?以下一些要点
https://bitbucket.org/chromiumembedded/cef/wiki/GeneralUsage#markdown-header-cefapp https://bitbucket.org/chromiumembedded/cef/wiki/GeneralUsage#markdown-header-processes
不支持single_process
模式,所以我从未使用过它。一般来说,我会避免它。多进程体系结构意味着您需要将调试器附加到进程。在这种情况下,Chromium
指南与CEF
相关。
https://www.chromium.org/developers/how-tos/debugging-on-windows#TOC-Attaching-to-the-renderer
你需要确保你的应用程序源自CefRenderProcessHandler而不是SimpleHandler!
class SimpleApp : public CefApp
, public CefRenderProcessHandler
{
virtual void OnContextCreated(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
CefRefPtr<CefV8Context> context) OVERRIDE;
valdemar-rudolfovich说你需要在CefExecuteProcess中传递SimpleApp的实例