有人可以在PPAPI上验证以下假设吗?
我们要求拦截chrome流量,将其发送到本机应用程序进行分析,并根据分析结果实时阻止它。尝试探索本机消息传递,但问题在于它只支持异步通信,并且不支持以下用例。
interceptHeader是使用[“blocking”,“requestHeaders”]规范添加到chrome.webRequest.onBeforeSendHeaders的侦听器。
interceptHeaders: function(details)
{
var verdict = false;
//send request for scanning only if it is a POST request
if (details.method == "POST")
{
//create new responseObject
var responseObject = new ResponseObject();
/use native messaging to send request for scanning
chrome.runtime.sendNativeMessage('com.my_company.my_application',
requestObject,
responseObject.Callback
);
// wait for response - how to efficiently wait unitl responseObject.Callback is processed
// so that responseObject.verdict can be used as a return value of interceptHeaders as shown below
??????????????
//update the verdict (true or false)
verdict = responseObject.verdict;
console.log ("verdict " + verdict + "for RequestId " + details.requestId);
//delete the responseObject
delete responseObject;
}
return {cancel: verdict};
}
答案 0 :(得分:1)
无法同步阻止插件。该API专门针对性能和稳定性原因而设计(支持进程之间的同步调用意味着从阻塞内部进行重入调用,这几乎可以保证崩溃或严重混淆代码)。