将Chromium Embeded(Javascript)中的信息发送到包含C ++的应用程序 [英] Sending information from Chromium Embeded (Javascript) to a containing C++ application

查看:242
本文介绍了将Chromium Embeded(Javascript)中的信息发送到包含C ++的应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

检查Chromium嵌入式框架示例后,我有一个问题。我需要与我的窗口的嵌入部分的本机交互。但是,在CEF示例中,我看到的是c ++发送消息到浏览器,而不是相反。我想知道是否有任何方式从JavaScript发送消息从c ++,像在一个函数的方式。



我在找什么是这样的。我在我的网页上有一个按钮,当点击。我想把窗口最小化。

解决方案

最简单的方法:
1.在主进程中(UI进程) - 你可以创建自己的自定义方案处理程序(它可以绑定到http协议,以及不同的处理程序按域)。
2.从JS端,可以使用XMLHttpRequest来调用方案处理程序。其它方式:
使用V8绑定,但在这种情况下,您将需要使自己的IPC在渲染器和主进程。或者使用内置的IPC,但请注意,它只是以异步方式发送消息。


After checking out the Chromium Embedded Framework example I have a question. I need native interaction with the embedded part of my window. However, in the CEF example, all I saw was the c++ sending messages to the browser, not the other way around. I was wondering if there is any way to send a message from JavaScript from c++, like in the way of a function.

What I am looking for is something like this. I have a button in my webpage that when clicked. I would like to minimize the window. Is there any way to call some c++ from JavaScript in CEF?

解决方案

Easiest way: 1. In main process (UI process) - you can create own custom scheme handler (it can be bounded to http protocol too, and distinct handlers by domain). 2. From JS side, you can use XMLHttpRequest to call you scheme handler. It is standard mechanism to IPC between JS<>Main process.

Other way: Use V8 bindings, but in this case you will need make own IPC between renderer and main process. Or use built-in IPC, but note that it is sends messages only in async way.

这篇关于将Chromium Embeded(Javascript)中的信息发送到包含C ++的应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆