Thu, 15 Jan 2015 15:59:08 +0100
Implement a real Private Browsing Mode condition by changing the API/ABI;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.
michael@0 | 1 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 2 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 3 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 4 | "use strict"; |
michael@0 | 5 | |
michael@0 | 6 | var self = require("sdk/self"); |
michael@0 | 7 | var { Panel } = require("sdk/panel"); |
michael@0 | 8 | var { ToggleButton } = require("sdk/ui"); |
michael@0 | 9 | |
michael@0 | 10 | function replaceMom(html) { |
michael@0 | 11 | return html.replace("World", "Mom"); |
michael@0 | 12 | } |
michael@0 | 13 | exports.replaceMom = replaceMom; |
michael@0 | 14 | |
michael@0 | 15 | exports.main = function(options, callbacks) { |
michael@0 | 16 | console.log("My ID is " + self.id); |
michael@0 | 17 | |
michael@0 | 18 | // Load the sample HTML into a string. |
michael@0 | 19 | var helloHTML = self.data.load("sample.html"); |
michael@0 | 20 | |
michael@0 | 21 | // Let's now modify it... |
michael@0 | 22 | helloHTML = replaceMom(helloHTML); |
michael@0 | 23 | |
michael@0 | 24 | // ... and then create a panel that displays it. |
michael@0 | 25 | var myPanel = Panel({ |
michael@0 | 26 | contentURL: "data:text/html," + helloHTML, |
michael@0 | 27 | onHide: handleHide |
michael@0 | 28 | }); |
michael@0 | 29 | |
michael@0 | 30 | // Create a widget that displays the image. We'll attach the panel to it. |
michael@0 | 31 | // When you click the widget, the panel will pop up. |
michael@0 | 32 | var button = ToggleButton({ |
michael@0 | 33 | id: "test-widget", |
michael@0 | 34 | label: "Mom", |
michael@0 | 35 | icon: './mom.png', |
michael@0 | 36 | onChange: handleChange |
michael@0 | 37 | }); |
michael@0 | 38 | |
michael@0 | 39 | // If you run cfx with --static-args='{"quitWhenDone":true}' this program |
michael@0 | 40 | // will automatically quit Firefox when it's done. |
michael@0 | 41 | if (options.staticArgs.quitWhenDone) |
michael@0 | 42 | callbacks.quit(); |
michael@0 | 43 | } |
michael@0 | 44 | |
michael@0 | 45 | function handleChange(state) { |
michael@0 | 46 | if (state.checked) { |
michael@0 | 47 | myPanel.show({ position: button }); |
michael@0 | 48 | } |
michael@0 | 49 | } |
michael@0 | 50 | |
michael@0 | 51 | function handleHide() { |
michael@0 | 52 | button.state('window', { checked: false }); |
michael@0 | 53 | } |