[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] r15416: Modify FF3 sessionstore to block writes according to prefs. (torbutton/trunk/src/components)
Author: mikeperry
Date: 2008-06-22 06:38:48 -0400 (Sun, 22 Jun 2008)
New Revision: 15416
Added:
torbutton/trunk/src/components/nsSessionStore3.diff
Modified:
torbutton/trunk/src/components/nsSessionStore3.js
Log:
Modify FF3 sessionstore to block writes according to prefs.
Add diff against original sessionstore.
Added: torbutton/trunk/src/components/nsSessionStore3.diff
===================================================================
--- torbutton/trunk/src/components/nsSessionStore3.diff (rev 0)
+++ torbutton/trunk/src/components/nsSessionStore3.diff 2008-06-22 10:38:48 UTC (rev 15416)
@@ -0,0 +1,98 @@
+--- nsSessionStore3.js 2008-05-29 13:21:21.000000000 -0700
++++ nsSessionStore3.js 2008-06-22 03:35:48.000000000 -0700
+@@ -99,9 +99,21 @@
+ "Subframes", "Plugins", "Javascript", "MetaRedirects", "Images"
+ ];
+
+-// module for JSON conversion (needed for the nsISessionStore API)
+-Cu.import("resource://gre/modules/JSON.jsm");
+-Cu.import("resource://gre/modules/XPCOMUtils.jsm");
++var is_FF3 = false;
++var appInfo = Components.classes["@mozilla.org/xre/app-info;1"]
++ .getService(Components.interfaces.nsIXULAppInfo);
++var versionChecker = Components.classes["@mozilla.org/xpcom/version-comparator;1"]
++ .getService(Components.interfaces.nsIVersionComparator);
++
++if(versionChecker.compare(appInfo.version, "3.0a1") >= 0) {
++ is_FF3 = true;
++ // module for JSON conversion (needed for the nsISessionStore API)
++ Cu.import("resource://gre/modules/JSON.jsm");
++ Cu.import("resource://gre/modules/XPCOMUtils.jsm");
++} else {
++ is_FF3 = false;
++ var XPCOMUtils = { generateQI: function() { return null; } };
++}
+
+ function debug(aMsg) {
+ aMsg = ("SessionStore: " + aMsg).replace(/\S{80}/g, "$&\n");
+@@ -857,9 +869,23 @@
+ var tabbrowser = aWindow.getBrowser();
+ var tabs = tabbrowser.mTabs;
+ var tabsData = this._windows[aWindow.__SSi].tabs = [];
+-
+- for (var i = 0; i < tabs.length; i++)
+- tabsData.push(this._collectTabData(tabs[i]));
++ var prefs = Components.classes["@mozilla.org/preferences-service;1"]
++ .getService(Components.interfaces.nsIPrefBranch);
++ var bypass_tor = prefs.getBoolPref("extensions.torbutton.notor_sessionstore");
++ var bypass_nontor = prefs.getBoolPref("extensions.torbutton.nonontor_sessionstore");
++
++ for (var i = 0; i < tabs.length; i++) {
++ if(typeof(tabs[i].linkedBrowser.__tb_tor_fetched) != "undefined") {
++ if(bypass_tor && tabs[i].linkedBrowser.__tb_tor_fetched) {
++ continue;
++ }
++ if(bypass_nontor && !tabs[i].linkedBrowser.__tb_tor_fetched) {
++ continue;
++ }
++ }
++ var tabData = this._collectTabData(tabs[i]);
++ if(tabData) tabsData.push(tabData);
++ }
+
+ this._windows[aWindow.__SSi].selected = tabbrowser.mTabBox.selectedIndex + 1;
+ },
+@@ -892,6 +918,7 @@
+ if (history && browser.parentNode.__SS_data &&
+ browser.parentNode.__SS_data.entries[history.index] && !aFullData) {
+ tabData = browser.parentNode.__SS_data;
++ if(!tabData) return null;
+ tabData.index = history.index + 1;
+ }
+ else if (history && history.count > 0) {
+@@ -1104,7 +1131,7 @@
+ for (var i = 0; i < browsers.length; i++) {
+ try {
+ var tabData = this._windows[aWindow.__SSi].tabs[i];
+- if (tabData.entries.length == 0 ||
++ if (!tabData || tabData.entries.length == 0 ||
+ browsers[i].parentNode.__SS_data && browsers[i].parentNode.__SS_data._tab)
+ continue; // ignore incompletely initialized tabs
+ this._updateTextAndScrollDataForTab(aWindow, browsers[i], tabData);
+@@ -2156,5 +2183,24 @@
+ }
+ };
+
+-function NSGetModule(aComMgr, aFileSpec)
+- XPCOMUtils.generateModule([SessionStoreService]);
++const NoModule = {
++ getClassObject: function(aCompMgr, aCID, aIID) {
++ Components.returnCode = Cr.NS_ERROR_NOT_REGISTERED;
++ return null;
++ },
++ registerSelf: function(aCompMgr, aFileSpec, aLocation, aType) { return; },
++ unregisterSelf: function(aCompMgr, aLocation, aType) { return; },
++ canUnload: function(aCompMgr) { return true; }
++};
++
++
++function NSGetModule(aComMgr, aFileSpec) {
++ var prefs = Components.classes["@mozilla.org/preferences-service;1"]
++ .getService(Components.interfaces.nsIPrefBranch);
++ if(is_FF3 && (prefs.getBoolPref("extensions.torbutton.notor_sessionstore")
++ || prefs.getBoolPref("extensions.torbutton.nonontor_sessionstore"))) {
++ return XPCOMUtils.generateModule([SessionStoreService]);
++ } else {
++ return NoModule;
++ }
++}
Modified: torbutton/trunk/src/components/nsSessionStore3.js
===================================================================
--- torbutton/trunk/src/components/nsSessionStore3.js 2008-06-22 09:46:39 UTC (rev 15415)
+++ torbutton/trunk/src/components/nsSessionStore3.js 2008-06-22 10:38:48 UTC (rev 15416)
@@ -99,10 +99,22 @@
"Subframes", "Plugins", "Javascript", "MetaRedirects", "Images"
];
-// module for JSON conversion (needed for the nsISessionStore API)
-Cu.import("resource://gre/modules/JSON.jsm");
-Cu.import("resource://gre/modules/XPCOMUtils.jsm");
+var is_FF3 = false;
+var appInfo = Components.classes["@mozilla.org/xre/app-info;1"]
+ .getService(Components.interfaces.nsIXULAppInfo);
+var versionChecker = Components.classes["@mozilla.org/xpcom/version-comparator;1"]
+ .getService(Components.interfaces.nsIVersionComparator);
+if(versionChecker.compare(appInfo.version, "3.0a1") >= 0) {
+ is_FF3 = true;
+ // module for JSON conversion (needed for the nsISessionStore API)
+ Cu.import("resource://gre/modules/JSON.jsm");
+ Cu.import("resource://gre/modules/XPCOMUtils.jsm");
+} else {
+ is_FF3 = false;
+ var XPCOMUtils = { generateQI: function() { return null; } };
+}
+
function debug(aMsg) {
aMsg = ("SessionStore: " + aMsg).replace(/\S{80}/g, "$&\n");
Cc["@mozilla.org/consoleservice;1"].getService(Ci.nsIConsoleService)
@@ -857,10 +869,24 @@
var tabbrowser = aWindow.getBrowser();
var tabs = tabbrowser.mTabs;
var tabsData = this._windows[aWindow.__SSi].tabs = [];
+ var prefs = Components.classes["@mozilla.org/preferences-service;1"]
+ .getService(Components.interfaces.nsIPrefBranch);
+ var bypass_tor = prefs.getBoolPref("extensions.torbutton.notor_sessionstore");
+ var bypass_nontor = prefs.getBoolPref("extensions.torbutton.nonontor_sessionstore");
+
+ for (var i = 0; i < tabs.length; i++) {
+ if(typeof(tabs[i].linkedBrowser.__tb_tor_fetched) != "undefined") {
+ if(bypass_tor && tabs[i].linkedBrowser.__tb_tor_fetched) {
+ continue;
+ }
+ if(bypass_nontor && !tabs[i].linkedBrowser.__tb_tor_fetched) {
+ continue;
+ }
+ }
+ var tabData = this._collectTabData(tabs[i]);
+ if(tabData) tabsData.push(tabData);
+ }
- for (var i = 0; i < tabs.length; i++)
- tabsData.push(this._collectTabData(tabs[i]));
-
this._windows[aWindow.__SSi].selected = tabbrowser.mTabBox.selectedIndex + 1;
},
@@ -892,6 +918,7 @@
if (history && browser.parentNode.__SS_data &&
browser.parentNode.__SS_data.entries[history.index] && !aFullData) {
tabData = browser.parentNode.__SS_data;
+ if(!tabData) return null;
tabData.index = history.index + 1;
}
else if (history && history.count > 0) {
@@ -1104,7 +1131,7 @@
for (var i = 0; i < browsers.length; i++) {
try {
var tabData = this._windows[aWindow.__SSi].tabs[i];
- if (tabData.entries.length == 0 ||
+ if (!tabData || tabData.entries.length == 0 ||
browsers[i].parentNode.__SS_data && browsers[i].parentNode.__SS_data._tab)
continue; // ignore incompletely initialized tabs
this._updateTextAndScrollDataForTab(aWindow, browsers[i], tabData);
@@ -2156,5 +2183,24 @@
}
};
-function NSGetModule(aComMgr, aFileSpec)
- XPCOMUtils.generateModule([SessionStoreService]);
+const NoModule = {
+ getClassObject: function(aCompMgr, aCID, aIID) {
+ Components.returnCode = Cr.NS_ERROR_NOT_REGISTERED;
+ return null;
+ },
+ registerSelf: function(aCompMgr, aFileSpec, aLocation, aType) { return; },
+ unregisterSelf: function(aCompMgr, aLocation, aType) { return; },
+ canUnload: function(aCompMgr) { return true; }
+};
+
+
+function NSGetModule(aComMgr, aFileSpec) {
+ var prefs = Components.classes["@mozilla.org/preferences-service;1"]
+ .getService(Components.interfaces.nsIPrefBranch);
+ if(is_FF3 && (prefs.getBoolPref("extensions.torbutton.notor_sessionstore")
+ || prefs.getBoolPref("extensions.torbutton.nonontor_sessionstore"))) {
+ return XPCOMUtils.generateModule([SessionStoreService]);
+ } else {
+ return NoModule;
+ }
+}