My question is quite simple, I tried to create a chrome extension that calls a NaCl module. My button and different files seem to be ok, and my quite simple code in C++ returns a PostMessage hello World. But, when I try it, it doesn't work. Are there specific things that I haven't done for including a NaCl module in a Chrome extension? I must say that I'm a little bit losing hope.
Here is my "background.html":
<body>
<script src="background.js"></script>
<div id="listener">
<embed name="nacl_module"
id="nacl_correction"
src="nacl_correction.nmf"
type="application/x-nacl" />
</div>
<script >
document.getElementById('listener').addEventListener('load', moduleDidLoad, true);
</script>
</body>
Here is my "background.js" :
var NaclCorrectionModule = null; // Global application object.
function moduleDidLoad() {
NaclCorrectionModule = document.getElementById('nacl_correction');
//alert( NaclCorrectionModule);
if (NaclCorrectionModule == null) {
alert('Out');
}
else {
alert (NaclCorrectionModule);
}
NaclCorrectionModule.addEventListener('message', handleMessage, false);
}
function handleMessage(message_event) {
alert(message_event.data);
}
chrome.browserAction.onClicked.addListener(moduleDidLoad);
And, at last, my "Manifest.json" :
{
"name": "Correction de Cordial sous Chrome",
"version": "1.0",
"background_page" :"background.html",
"description": "Intégration d'une extension Cordial pour la correction sous Chrome",
"permissions": [
"tabs", "http://*/*"
],
"browser_action": {
"default_icon": "corriger_big.png", // Icône de l'extension
"default_title": "Correction de Cordial" // Titre affiche sur le bouton
}
}
If anybody has any ideas, I would be thankful.
Native Client (NaCl) is a secure sandbox for running untrusted native machine code in the Chrome browser. NaCl programs have special restrictions on the generated code, which are implemented by the compiler toolchain and statically verified at runtime by the trusted NaCl loader.
After a little seeking, I've found that I forgot something. In my background.js, I didn't send any message to NaCl, so it can't work.
I only needed to add 1 line:
NaclCorrectionModule.postMessage('');
Thank you for reading my question, and I hope this can help somebody!!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With