Question

I would like to open a URL in private mode from a Thunderbird extension. Right now, the following code works in "standard" non-private mode:

try {
  var eps = Components.classes["@mozilla.org/uriloader/external-protocol-service;1"].
  getService(Components.interfaces.nsIExternalProtocolService);
  var ios = Components.classes["@mozilla.org/network/io-service;1"].
  getService(Components.interfaces.nsIIOService);
  eps.loadURI(ios.newURI("http://www.example.com", null, null));
} catch (err) {}

Any idea how to achieve the same result in private mode? I'm interested to make it work with launching Chrome as the default browser. (Once again, Chrome is correctly launched with the code above).

Was it helpful?

Solution

You cannot really launch Firefox with a new url in a private window AFAIK. -private-window <url> will open a new private window, but still put the new tab in a regular one.

Chrome can be launched with chrome --incognito <url>, however you would need to launch it yourself via nsIProcess and therefore would first have to figure out where the chrome binary is.

If you can guarantee that the default handler is Chrome, then you might use nsIExternalProtocolService.getProtocolHandlerInfo(), use preferredApplicationHandler and QueryInterface that to nsILocalHandlerApp to find the .executable. Otherwise, you'll have to deal with the OS and/or known paths yourself.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top