Pregunta

¿Cómo puedo hacer un protocolo conectable http pasarela para el trabajo de IE en Firefox?

Por otra parte, la forma de desarrollar una para Firefox? serían apreciados Cualquier ejemplos.

Gracias.

¿Fue útil?

Solución 2

Escribir un objeto que implementa XPCOM nsIObserver. A continuación, cree oyente para http-en-modificación-petición y http-a-examinar-respuesta.

var myObj = new MyObserver(); //implements nsIObserver
var observerService = Components.classes["@mozilla.org/observer-service;1"].getService(Components.interfaces.nsIObserverService);
observerService.addObserver(myObj "http-on-modify-request",   false);
observerService.addObserver(myObj, "http-on-examine-response", false);

Otros consejos

En Firefox, si quieres omitir un comportamiento por defecto de forma "enchufable", se podría escribir un plug-in> basado NPAPI. Digamos que la documentación es delgada sobre este tema ... pero para empezar, se podría consultar este .

Con un plugin NPAPI, que tienen acceso a todo el sistema operativo y por lo tanto son libres para exponer cualquier otro recurso a Firefox.

Escribir un objeto que implementa XPCOM nsIProtocolHandler. Por ejemplo, se puede acceder a las imágenes de las páginas web locales:

const Cu = Components.utils;
const Ci = Components.interfaces;
const Cm = Components.manager;
const Cc = Components.classes;
Cu.import("resource://gre/modules/XPCOMUtils.jsm");+
Cu.import("resource://gre/modules/FileUtils.jsm");
Cu.import("resource://gre/modules/NetUtil.jsm");
/***********************************************************
class definition
***********************************************************/
function sampleProtocol() {
     // If you only need to access your component from JavaScript, 
     //uncomment   the following line:
     this.wrappedJSObject = this;
}   
sampleProtocol.prototype = {
classDescription: "LocalFile sample protocol",
classID:          Components.ID("{XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}"),
contractID:       "@mozilla.org/network/protocol;1?name=x-localfile",
QueryInterface: XPCOMUtils.generateQI([Ci.nsIProtocolHandler]),
//interface nsIProtocolHandler
 allowPort :function(port, scheme)
 {
  if ((port == 80)&&(scheme == x-localfile)) {
   return true;
 }
 else
 {
     return false;
 }
},

newChannel: function(aURI)
{
    // Just example. Implementation must parse aURI
    var file = new FileUtils.File("D:\\temp\\getImage.jpg");
    var uri = NetUtil.ioService.newFileURI(file);
    var channel = NetUtil.ioService.newChannelFromURI(uri);
    return channel;
},
newURI(aSpec, aOriginCharset, aBaseURI)
{
    //URI looks like x-localfile://example.com/image1.jpg
    var uri = Cc["@mozilla.org/network/simple-uri;1"].createInstance(Ci.nsIURI);
    uri.spec = aSpec;
    return uri;
},
scheme: "x-localfile",
defaultPort: 80,
protocolFlags: 76
};
var components = [sampleProtocol];
if ("generateNSGetFactory" in XPCOMUtils)
var NSGetFactory = XPCOMUtils.generateNSGetFactory(components);  //   Firefox 4.0 and higher
else
var NSGetModule = XPCOMUtils.generateNSGetModule(components);    // Firefox 3.x

Ten cuidado! Este enfoque puede crear vulnerabilidad

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top