2

“NaCl 目前仅默认打开 Chrome Webstore 中的应用程序/扩展程序,或用于开发目的的解压扩展程序。” - 互联网

然而,我似乎无法从未打包的扩展中使用 NaCl。(我没有尝试过网上应用店。)

我有一个非常简单的测试扩展,它的 background.js 中有以下内容:

function clicked() {
    var testNaclElement = document.createElement("embed");
    testNaclElement.setAttribute("type","application/x-nacl");
    testNaclElement.setAttribute("width",0);
    testNaclElement.setAttribute("height",0);
    document.body.appendChild(testNaclElement);
    alert(testNaclElement.postMessage?true:false);
    document.body.removeChild(testNaclElement);
}

chrome.browserAction.onClicked.addListener(updateIcon);
updateIcon();

当在 chrome://flags 中启用 NaCl 时,此扩展报告 true,但在 chrome://flags(这是默认设置)中禁用 NaCl 时,它报告 false。

我希望它报告真实。

我错过了什么?

更新:

似乎发明我自己的检测代码毕竟不是一个好主意。如果我创建并安装了一个指向 url X 的解压 chrome webapp,那么 NaCl 将在该页面上运行,但此检测代码仍会报告错误,而在 chrome 中启用 NaCl 的普通网页上,同样的代码会报告 true: //标志。

但是,如果在指向 url X 的 iFrame 中创建一个使用 NaCl 的扩展程序(不是 chrome webapp),那么 NaCl 将无法在其中工作。

但是,如果我创建一个指向 url X 的 webapp 和一个在 iFrame 中使用 url X 的扩展,那么如果同时安装,两者都可以工作。

Update2: 如果我真的在扩展中包含了 nmf 和 nexe,那么它就可以工作。

更新 3: nexe 不需要包含在扩展中。

4

2 回答 2

0

a better way to detect if a NaCl module is loaded is to use progress events. see https://developers.google.com/native-client/pepper16/devguide/coding/progress-events for the enumeration of events and an example.

about the url X -- i don't think events propagate pass iframes if the iframe's URL and the container's URL domains differ -- and any enabling of NaCl in the web store or unpacked extensions corresponds to an URL (possibly with a special proto-spec; i don't know the details), so that might explain the various combinations that you're seeing. it probably also depend on how you specified the URL set in the webapp manifest.

the code's testNaclElement lack a src= attribute/value pair. it's been a while since i looked at the NaCl plugin's code, but that might also cause problems.

于 2012-02-29T18:29:57.653 回答
0

Chrome 要求 nmf 位置属于扩展程序。空 nmf 属性没有此属性。

于 2012-03-02T09:14:47.070 回答