Alexey Kruchenok
Alexey Kruchenok

Reputation: 175

Displaying extension page in browser tab

I'm trying to write extension that have some advanced control (much more than selecting from list or check/unchenck).

I wish to create separate page to do all required actions, idealy it would be separate tab.

The question is:

Is it possible to create XUL window and insert them into browser tab?

For now i got just one idea - store html page into /content folder, and use them. But i don't like that user will see some wierd url chrome://blalbla/content/control.html etc.

Upvotes: 0

Views: 172

Answers (1)

Neil
Neil

Reputation: 55392

That works with XUL pages too. But if you want to hide the chrome: URL from the user, you can create a component that redirects about:myext to the chrome: URL. A partial snippet follows:

myAbout.prototype = {
  QueryInterface: XPCOMUtils.generateQI([Components.interfaces.nsIAboutModule]),

  getURIFlags: function(aURI) {
    return Components.interfaces.nsIAboutModule.ALLOW_SCRIPT;
  },

  newChannel: function(aURI) {
    var channel = ioSvc.newChannel("chrome://myext/content/myext.xul", null, null);
    channel.originalURI = aURI;
    return channel;
  }
};

You then have to register your component using the contract ID @mozilla.org/network/protocol/about;1?what=myext and this will redirect about:myext to your XUL page.

Upvotes: 2

Related Questions