Tue, 06 Jan 2015 21:39:09 +0100
Conditionally force memory storage according to privacy.thirdparty.isolate;
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 | |
michael@0 | 5 | Components.utils.import("resource://gre/modules/XPCOMUtils.jsm"); |
michael@0 | 6 | |
michael@0 | 7 | const nsISupports = Components.interfaces.nsISupports; |
michael@0 | 8 | |
michael@0 | 9 | const nsICommandLine = Components.interfaces.nsICommandLine; |
michael@0 | 10 | const nsICommandLineHandler = Components.interfaces.nsICommandLineHandler; |
michael@0 | 11 | const nsISupportsString = Components.interfaces.nsISupportsString; |
michael@0 | 12 | const nsIWindowWatcher = Components.interfaces.nsIWindowWatcher; |
michael@0 | 13 | |
michael@0 | 14 | function RecordingCmdLineHandler() {} |
michael@0 | 15 | RecordingCmdLineHandler.prototype = |
michael@0 | 16 | { |
michael@0 | 17 | classID: Components.ID('{86FB70EC-90FF-45AD-A1C1-F77D3C1184E9}'), |
michael@0 | 18 | |
michael@0 | 19 | /* nsISupports */ |
michael@0 | 20 | QueryInterface: XPCOMUtils.generateQI([nsICommandLineHandler]), |
michael@0 | 21 | |
michael@0 | 22 | /* nsICommandLineHandler */ |
michael@0 | 23 | handle : function handler_handle(cmdLine) { |
michael@0 | 24 | var args = { }; |
michael@0 | 25 | args.wrappedJSObject = args; |
michael@0 | 26 | try { |
michael@0 | 27 | var uristr = cmdLine.handleFlagWithParam("recording", false); |
michael@0 | 28 | if (uristr == null) |
michael@0 | 29 | return; |
michael@0 | 30 | try { |
michael@0 | 31 | args.uri = cmdLine.resolveURI(uristr).spec; |
michael@0 | 32 | } |
michael@0 | 33 | catch (e) { |
michael@0 | 34 | return; |
michael@0 | 35 | } |
michael@0 | 36 | } |
michael@0 | 37 | catch (e) { |
michael@0 | 38 | cmdLine.handleFlag("recording", true); |
michael@0 | 39 | } |
michael@0 | 40 | |
michael@0 | 41 | /** |
michael@0 | 42 | * Manipulate preferences by adding to the *default* branch. Adding |
michael@0 | 43 | * to the default branch means the changes we make won't get written |
michael@0 | 44 | * back to user preferences. |
michael@0 | 45 | * |
michael@0 | 46 | * We want to do this here rather than in reftest.js because it's |
michael@0 | 47 | * important to set the recording pref before the platform Init gets |
michael@0 | 48 | * called. |
michael@0 | 49 | */ |
michael@0 | 50 | var prefs = Components.classes["@mozilla.org/preferences-service;1"]. |
michael@0 | 51 | getService(Components.interfaces.nsIPrefService); |
michael@0 | 52 | var branch = prefs.getDefaultBranch(""); |
michael@0 | 53 | |
michael@0 | 54 | try { |
michael@0 | 55 | var outputstr = cmdLine.handleFlagWithParam("recording-output", false); |
michael@0 | 56 | if (outputstr != null) { |
michael@0 | 57 | branch.setCharPref("gfx.2d.recordingfile", outputstr); |
michael@0 | 58 | } |
michael@0 | 59 | } catch (e) { } |
michael@0 | 60 | |
michael@0 | 61 | branch.setBoolPref("gfx.2d.recording", true); |
michael@0 | 62 | |
michael@0 | 63 | var wwatch = Components.classes["@mozilla.org/embedcomp/window-watcher;1"] |
michael@0 | 64 | .getService(nsIWindowWatcher); |
michael@0 | 65 | wwatch.openWindow(null, "chrome://recording/content/recording.xul", "_blank", |
michael@0 | 66 | "chrome,dialog=no,all", args); |
michael@0 | 67 | cmdLine.preventDefault = true; |
michael@0 | 68 | }, |
michael@0 | 69 | |
michael@0 | 70 | helpInfo : " -recording <file> Record drawing for a given URL.\n" + |
michael@0 | 71 | " -recording-output <file> Specify destination file for a drawing recording.\n" |
michael@0 | 72 | }; |
michael@0 | 73 | |
michael@0 | 74 | this.NSGetFactory = XPCOMUtils.generateNSGetFactory([RecordingCmdLineHandler]); |