I was reminded that there is one more way to get to private browsing – typing about:privatebrowsing in the URL bar. This gives us a chance to talk about another thing you can do in chrome.manifest – override.
Override allows us to completely replace a built in URL in Firefox with another URL. I use this in my Rebrand extension to override certain images and other things. We can also use it to override built in URLs like about:config and about:privatebrowsing. There is a catch though.
When a URL begins with about, that’s not the true URL; all about URLs map to a corresponding chrome URL. The easiest way to see this mapping is by looking at AboutRedirector.cpp or nsAboutRedirector.cpp. These files contain the mappings of just about every about command to a corresponding chrome URL. For about:privatebrowsing, that’s chrome://browser/content/aboutPrivateBrowsing.xhtml
So to override the about:privatebrowsing, we just need to give it a suitable replacement. Put this line in your chrome.manifest:
override chrome://browser/content/aboutPrivateBrowsing.xhtml data:text/html,Disabled
You’ll see the word “Disabled” when you type about:privatebrowsing.
Alternatively, you could create your own custom HTML file and place it in your content directory and point to that:
override chrome://browser/content/aboutPrivateBrowsing.xhtml chrome://myextension/content/myfile.html
This method can be used to override just about any of the about pages. For instance, to override about:config, do this:
override chrome://global/content/config.xul data:text/html,Disabled
Using override is a powerful way to prevent access to things you don’t want your users messing around with.