The Per-Tab Private Browsing Plan
Will Bamberg wrote about Per-window private browsing and the Add-on SDK recently, and I wanted to follow up with a quick note about Per-tab private browsing on Fennec.
The situation is almost identical to Firefox’s, except that Fennec never had global private browsing implemented which is basically the same as having global browsing off, so the transition to per-tab private browsing is essentially the same as that for per-window private browsing.
You will have to repack in order to support Firefox 20 for mobile (aka Fennec 20), and you will have to request private-browsing permission (as Will outlines in his post) in order to be aware of private tabs. If you don’t opt-in for private-browsing permission, then you will not see private tabs in the tabs module and you will not be able to add a page-mod to private tabs for example. If you do request private-browsing permission then you will need to check if the tabs that you handle are private like so:
require('sdk/private-browsing').isPrivate(tab) // returns true if the tab is private and false otherwise
The code examples that Will provides are jsut as relevent to per-tab private browsing as the are to per-window private browsing, so give his post a read!!
Also if you have private-browsing permission, then you can open a private tab like so:
require('sdk/tabs').open({
url: "https://mozilla.org",
isPrivate: true
})
If you use the above example on Fennec, a new private tab is opened, if you use the example code on Firefox then the tab will be opened in a private window, which may not be the most recent active window.
If you don’t have private-browsing permission, then using the isPrivate flag when opening a tab or window, then it will be ignored.