We have created an initial POC and thus sharing the approach what we took,
Extension:
Available approaches to build an Extension,
Add-on SDK
Restartless
XUL Overlay
XUL is deprecated and Add-On SDK is the suggested approach from Firefox. Thus, we decided to use the Add-on SDK to build the extension.
Interception of the SAFE: schema can be handled by the extension. Once the schema is intercepted, the data must be retrieved from the network and passed back.
For intercepting the SCHEMA, we had to implement a Custom Protocol Handler, through this we could be able to stream the contents back to the caller.
In the custom handler, we created a Channel using nsIPipe (To handle the I/O stream between the caller and the network).
We did emulate to this by writing a byte array through the channel stream, whenever a SAFE: schema is intercepted from the address bar of the browser and also from the DOM.
Plugin:
Available approaches for building plugins for interacting with native code,
NPAPI
XPCOM
JS-Ctypes
emscripten
NPAPI seems to not be available Cross Browser since Chrome currently does not support it. Moreover it also has restrictions with network operations and file system access. XPCOM is being used by Firefox, but again there is an uncertainty hanging around it, that Firefox might not support custom made XPCOM binaries some time soon.
Emscripten seemed to be promising. But porting can become more complicated, considering all the dependencies with MAIDSafe.
Thus we decided to try out our initial POC with JS-Ctypes.
Created a layer with JS-ctypes which provides a bridge between Javascript and the native code. Using the ctypes API from the extension, the native code is invoked. JS-ctypes supports only C, thus, we are accessing the C++ functions through a C wrapper. To have a completely isolated non-blocking operation, we also used ChromeWorker (Similar to WebWorker).
We have tested the MAIDSafe port sample with the extension so far :) scope is currently limited to MaidSafe-RUDP from the MaidSafe-Port layer
Github Repository:
https://github.com/shankar2105/CustomProtocolHandlerSample_Firefox