jcef java_JS调用JCEF方法

本文档介绍了如何使用Java调用JCEF(Java Chromium Embedded Framework)来实现在渲染进程中的JavaScript与浏览器进程中的C++之间进行异步消息路由。通过创建并注册处理器实例,应用可以在C++中响应JavaScript发起的请求,并在JavaScript中执行相应的回调。文档详细阐述了持久性和非持久性查询的使用场景,并提供了示例代码说明配置和使用过程。
摘要由CSDN通过智能技术生成

/*** The below classes implement support for routing aynchronous messages between

* JavaScript running in the renderer process and C++ running in the browser

* process. An application interacts with the router by passing it data from

* standard CEF C++ callbacks (OnBeforeBrowse, OnProcessMessageRecieved,

* OnContextCreated, etc). The renderer-side router supports generic JavaScript

* callback registration and execution while the browser-side router supports

* application-specific logic via one or more application-provided Handler

* instances.

*

* The renderer-side router implementation exposes a query function and a cancel

* function via the JavaScript 'window' object:

*

* // Create and send a new query.

* var request_id = window.cefQuery({

* request: 'my_request',

* persistent: false,

* onSuccess: function(response) {},

* onFailure: function(error_code, error_message) {}

* });

*

* // Optionally cancel the query.

* window.cefQueryCancel(request_id);

*

* When |window.cefQuery| is executed the request is sent asynchronously to one

* or more C++ Handler objects registered in the browser process. Each C++

* Handler can choose to either handle or ignore the query in the

* Handler::OnQuery callback. If a Handler chooses to handle the query then it

* should execute Callback::Success when a response is available or

* Callback::Failure if an error occurs. This will result in asynchronous

* execution of the associated JavaScript callback in the renderer process. Any

* queries unhandled by C++ code in the browser process will be automatically

* canceled and the associated JavaScript onFailure callback will be executed

* with an error code of -1.

*

* Queries can be either persistent or non-persistent. If the query is

* persistent than the callbacks will remain registered until one of the

* following conditions are met:

*

* A. The query is canceled in JavaScript using the |window.cefQueryCancel|

* functi

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值