Reputation: 363
I am writing a new image format decoder for Chrome with a Native Client module.
I use this manifest to create a chrome extension :
{
"name": "paver-jbig2",
"manifest_version": 2,
"version": "0.1.0",
"minimum_chrome_version": "35",
"web_accessible_resources": [
"paver-jbig2.nmf",
"paver-jbig2_arm.nexe",
"paver-jbig2_x86_32.nexe",
"paver-jbig2_x86_64.nexe"
],
"nacl_modules": [
{
"path": "paver-jbig2.nmf",
"mime_type": "image/jbig2"
}
]
}
When I call an URL http://my.company.com/myimage.jbig2, I can see that the nacl module is called without error.
But when I call this URL inside an HTML page with ajax, or in JavaScript with image.src=“http://.../myimage.jbig2”
, the NaCl module is not called.
What’s wrong ?
Upvotes: 2
Views: 132
Reputation: 1860
As I suggested here, I believe what you are trying to do is not possible. A NaCl module can only be loaded in an embed element.
The reason it works when you type it as a URL is that a HTML page is automatically created for you with an embed element that fills the page.
Here is a potential workaround: modify your Chrome extension to use a content script. This content script can read the contents of the page and look for all img elements of type jbig2. If one is found, you can send the URL to your NaCl module (in your extension's background page), which will decompress the image and send the decompressed image back to JavaScript via an ArrayBuffer. Now you can create a Blob from this ArrayBuffer, and create a Blob URL from the Blob. This URL can now be used in place of the original URL in the src attribute of the img element.
Upvotes: 3