Commit 11c41cf2 authored by Alex Catarineu's avatar Alex Catarineu
Browse files

Bug 10760: bring back review changes that got lost by mistake

parent 8c5a555b
......@@ -14,11 +14,9 @@
* AboutTor:ChromeData privileged data chrome -> content
*/
var {classes: Cc, interfaces: Ci, utils: Cu} = Components;
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/Services.jsm");
let { bindPrefAndInit, show_torbrowser_manual } = Cu.import("resource://torbutton/modules/utils.js", {});
let { bindPrefAndInit, show_torbrowser_manual } = ChromeUtils.import("resource://torbutton/modules/utils.js", {});
var AboutTorListener = {
......@@ -139,9 +137,7 @@ var AboutTorListener = {
// Display the Tor Browser product name and version.
try {
const kBrandBundle = "chrome://branding/locale/brand.properties";
let brandBundle = Cc["@mozilla.org/intl/stringbundle;1"]
.getService(Ci.nsIStringBundleService)
.createBundle(kBrandBundle);
let brandBundle = Services.strings.createBundle(kBrandBundle);
let productName = brandBundle.GetStringFromName("brandFullName");
let tbbVersion = Services.prefs.getCharPref("torbrowser.version");
let elem = content.document.getElementById("torbrowser-version");
......
......@@ -357,7 +357,7 @@ let setupGuardNote = function () {
["div", {},
noteBefore, ["span", {class: "circuit-guard-name"}, name],
noteAfter, " ",
["span", {onclick: `gBrowser.selectedTab = gBrowser.addTab('https://support.torproject.org/${localeCode}/tbb/tbb-2/', {triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal()});`,
["span", {onclick: `gBrowser.selectedTab = gBrowser.addWebTab('https://support.torproject.org/${localeCode}/tbb/tbb-2/');`,
class: "circuit-link"},
learnMoreString]]);
};
......
......@@ -200,9 +200,7 @@ var torbutton_tor_check_observer = {
}
if (!foundTab) {
gBrowser.selectedTab = gBrowser.addTab("about:tor", {
triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal(),
});
gBrowser.selectedTab = gBrowser.addTrustedTab("about:tor");
}
}
}
......@@ -883,7 +881,6 @@ function torbutton_new_identity() {
// conditions leading to failures (see bug 11783 for an example).
// TODO: Remove the Torbutton menu entry again once we have done our
// security control redesign.
// document.getElementById("torbutton-new-identity").disabled = true;
document.getElementById("menu_newIdentity").disabled = true;
document.getElementById("appMenuNewIdentity").disabled = true;
......@@ -909,7 +906,6 @@ function torbutton_new_identity() {
} else {
// TODO: Remove the Torbutton menu entry again once we have done our
// security control redesign.
// document.getElementById("torbutton-new-identity").disabled = false;
document.getElementById("menu_newIdentity").disabled = false;
document.getElementById("appMenuNewIdentity").disabled = false;
}
......@@ -923,7 +919,6 @@ function torbutton_new_identity() {
// security control redesign.
torbutton_log(5, "Unexpected error on new identity: " + e);
window.alert("Torbutton: Unexpected error on new identity: " + e);
// document.getElementById("torbutton-new-identity").disabled = false;
document.getElementById("menu_newIdentity").disabled = false;
document.getElementById("appMenuNewIdentity").disabled = false;
}
......@@ -1575,7 +1570,7 @@ function torbutton_close_tabs_on_new_identity() {
let tabCount = browser.browsers.length;
torbutton_log(3, "Tab count for window: " + tabCount);
let tabsToRemove = new Array();
let tabsToRemove = [];
for (let i = 0; i < tabCount; i++) {
let tab = browser.getTabForBrowser(browser.browsers[i]);
if (!tab) {
......@@ -1586,9 +1581,7 @@ function torbutton_close_tabs_on_new_identity() {
}
if (win == window) {
browser.addTab("about:blank", {
triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal(),
});
browser.addWebTab("about:blank");
} else {
// It is a bad idea to alter the window list while iterating
// over it, so add this window to an array and close it later.
......@@ -1641,7 +1634,6 @@ function torbutton_check_protections()
if (!m_tb_control_pass || (!m_tb_control_ipc_file && !m_tb_control_port)) {
// TODO: Remove the Torbutton menu entry again once we have done our
// security control redesign.
document.getElementById("torbutton-new-identity").disabled = true;
document.getElementById("menu_newIdentity").disabled = true;
document.getElementById("appMenuNewIdentity").disabled = true;
}
......@@ -1651,12 +1643,6 @@ function torbutton_check_protections()
}
}
// Bug 1506 P2: I think cookie protections is a neat feature.
function torbutton_open_cookie_dialog() {
showDialog(window, 'chrome://torbutton/content/torcookiedialog.xul',
'Cookie Protections', 'centerscreen,chrome,dialog,modal,resizable');
}
// -------------- HISTORY & COOKIES ---------------------
// Bug 1506 P4: Used by New Identity if cookie protections are
......@@ -1680,9 +1666,7 @@ function torbutton_disable_browser_js(browser) {
if (!browser.contentWindow)
torbutton_log(3, "No content window to disable JS events.");
else
eventSuppressor = browser.contentWindow.
QueryInterface(Ci.nsIInterfaceRequestor).
getInterface(Ci.nsIDOMWindowUtils);
eventSuppressor = browser.contentWindow.windowUtils;
} catch(e) {
torbutton_log(4, "Failed to disable JS events: "+e)
}
......@@ -1805,8 +1789,8 @@ function torbutton_do_startup()
{
if(m_tb_prefs.getBoolPref("extensions.torbutton.startup")) {
// Bug 1506: Still want to do this
// torbutton_toggle_plugins(
// m_tb_prefs.getBoolPref("plugin.disable"));
torbutton_toggle_plugins(
m_tb_prefs.getBoolPref("plugin.disable"));
// Bug 1506: Should probably be moved to an XPCOM component
torbutton_do_main_window_startup();
......@@ -1894,10 +1878,9 @@ function showSecurityPreferencesPanel(chromeWindow) {
if (settingsTab === null) {
// Open up the settings panel in a new tab.
tabBrowser.addTab(SECURITY_PREFERENCES_URI, {
tabBrowser.addTrustedTab(SECURITY_PREFERENCES_URI, {
"selected": true,
"parentId": tabBrowser.selectedTab.id,
triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal(),
});
} else {
// Activate an existing settings panel tab.
......
......@@ -3,7 +3,6 @@
// code directly. I don't see any of them as essential for 1506,
// really.
// let { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm", {});
var m_tb_torlog = Cc["@torproject.org/torbutton-logger;1"]
.getService(Ci.nsISupports).wrappedJSObject;
......
......@@ -21,9 +21,9 @@ const kMODULE_CID = Components.ID("e6204253-b690-4159-bfe8-d4eedab6b3be");
ChromeUtils.import("resource://torbutton/modules/default-prefs.js", {})
.ensureDefaultPrefs();
const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
const { XPCOMUtils } = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
// XXX: Must match the definition in torcookie.js :/
function Cookie(number,name,value,isDomain,host,rawHost,HttpOnly,path,isSecure,isSession,
expires,isProtected) {
this.number = number;
......@@ -88,9 +88,7 @@ function CookieJarSelector() {
if (typeof(cookiesAsJS) == "undefined" || !cookiesAsJS)
return;
var cookieManager =
Cc["@mozilla.org/cookiemanager;1"]
.getService(Ci.nsICookieManager2);
var cookieManager = Services.cookies;
for (var i = 0; i < cookiesAsJS.length; i++) {
var cookie = cookiesAsJS[i];
......@@ -299,9 +297,7 @@ function CookieJarSelector() {
this.clearCookies();
return;
}
var cookiemanager =
Cc["@mozilla.org/cookiemanager;1"]
.getService(Ci.nsICookieManager2);
var cookiemanager = Services.cookies;
var enumerator = cookiemanager.enumerator;
var count = 0;
......@@ -329,7 +325,7 @@ function CookieJarSelector() {
}
// Emit cookie-changed event. This instructs other components to clear their identifiers
// (Specifically DOM storage and safe browsing, but possibly others)
var obsSvc = Cc["@mozilla.org/observer-service;1"].getService(nsIObserverService);
var obsSvc = Services.obs;
obsSvc.notifyObservers(this, "cookie-changed", "cleared");
} catch (e) {
this.logger.log(5, "Error deleting unprotected cookies: " + e);
......@@ -367,10 +363,6 @@ function CookieJarSelector() {
this.logger.log(2, "Cookies reloaded");
};
// Check firefox version to know filename
// var appInfo = Services.appinfo;
// var versionChecker = Services.vc;
// This JSObject is exported directly to chrome
this.wrappedJSObject = this;
......@@ -399,13 +391,9 @@ function CookieJarSelector() {
}
const nsISupports = Ci.nsISupports;
const nsIClassInfo = Ci.nsIClassInfo;
const nsIObserver = Ci.nsIObserver;
const nsITimer = Ci.nsITimer;
const nsIComponentRegistrar = Ci.nsIComponentRegistrar;
const nsIObserverService = Ci.nsIObserverService;
const nsICategoryManager = Ci.nsICategoryManager;
// Start1506: You may or may not care about this:
CookieJarSelector.prototype =
......@@ -446,7 +434,7 @@ CookieJarSelector.prototype =
}
break;
case "profile-after-change":
var obsSvc = Cc["@mozilla.org/observer-service;1"].getService(nsIObserverService);
var obsSvc = Services.obs;
obsSvc.addObserver(this, "cookie-changed");
// after profil loading, initialize a timer to call timerCallback
// at a specified interval
......@@ -464,7 +452,6 @@ CookieJarSelector.prototype =
* XPCOMUtils.generateNSGetFactory was introduced in Mozilla 2 (Firefox 4).
* XPCOMUtils.generateNSGetModule is for Mozilla 1.9.2 (Firefox 3.6).
*/
const {XPCOMUtils} = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
if (XPCOMUtils.generateNSGetFactory)
var NSGetFactory = XPCOMUtils.generateNSGetFactory([CookieJarSelector]);
else
......
......@@ -8,7 +8,8 @@
// ### Abbreviations
const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
const { XPCOMUtils } = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
// Make the logger available.
let logger = Cc["@torproject.org/torbutton-logger;1"]
......@@ -17,9 +18,6 @@ let logger = Cc["@torproject.org/torbutton-logger;1"]
let { ensureDefaultPrefs } = ChromeUtils.import("resource://torbutton/modules/default-prefs.js", {});
ensureDefaultPrefs();
// Import Services object
ChromeUtils.import("resource://gre/modules/Services.jsm");
// Import crypto object (FF 37+).
Cu.importGlobalProperties(["crypto"]);
......@@ -163,9 +161,6 @@ const kMODULE_NAME = "TorBrowser Domain Isolator";
const kMODULE_CONTRACTID = "@torproject.org/domain-isolator;1";
const kMODULE_CID = Components.ID("e33fd6d4-270f-475f-a96f-ff3140279f68");
// Import XPCOMUtils object.
const {XPCOMUtils} = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
// DomainIsolator object.
function DomainIsolator() {
this.wrappedJSObject = this;
......
......@@ -8,8 +8,8 @@
ChromeUtils.import("resource://torbutton/modules/default-prefs.js", {}).ensureDefaultPrefs();
const {XPCOMUtils} = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
const { XPCOMUtils } = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
// Module specific constants
const kMODULE_NAME = "Torbutton Drag and Drop Handler";
......
......@@ -12,9 +12,9 @@
* handle an URL (e.g., when the user clicks on a mailto: URL).
*************************************************************************/
const {XPCOMUtils} = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
const {PromptUtils} = ChromeUtils.import("resource://gre/modules/SharedPromptUtils.jsm");
const { XPCOMUtils } = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
const { PromptUtils } = ChromeUtils.import("resource://gre/modules/SharedPromptUtils.jsm");
// Module specific constants
const kMODULE_NAME = "Torbutton External App Handler";
......@@ -33,8 +33,7 @@ ExternalAppBlocker.prototype =
{
_helperAppLauncher: undefined,
QueryInterface: ChromeUtils.generateQI([Ci.nsIObserver,
Ci.nsIHelperAppWarningDialog]),
QueryInterface: ChromeUtils.generateQI([Ci.nsIObserver, Ci.nsIHelperAppWarningDialog]),
// make this an nsIClassInfo object
flags: Ci.nsIClassInfo.DOM_OBJECT,
......
......@@ -12,18 +12,14 @@
*
*************************************************************************/
const Cc = Components.classes;
const Ci = Components.interfaces;
const Cr = Components.results;
const Cu = Components.utils;
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
const { XPCOMUtils } = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "FileUtils",
"resource://gre/modules/FileUtils.jsm");
Cu.import("resource://torbutton/modules/default-prefs.js", {}).ensureDefaultPrefs();
let NoScriptControl = Cu.import("resource://torbutton/modules/noscript-control.js", {});
ChromeUtils.import("resource://torbutton/modules/default-prefs.js", {}).ensureDefaultPrefs();
let NoScriptControl = ChromeUtils.import("resource://torbutton/modules/noscript-control.js", {});
// Module specific constants
const kMODULE_NAME = "Startup";
......@@ -158,15 +154,7 @@ StartupObserver.prototype = {
Services.prefs.savePrefFile(null);
},
QueryInterface: function(iid) {
if (iid.equals(Ci.nsISupports)) {
return this;
}
if(iid.equals(Ci.nsIClassInfo)) {
return this;
}
return this;
},
QueryInterface: ChromeUtils.generateQI([Ci.nsIClassInfo]),
// method of nsIClassInfo
classDescription: "Torbutton Startup Observer",
......@@ -175,14 +163,6 @@ StartupObserver.prototype = {
// Hack to get us registered early to observe recovery
_xpcom_categories: [{category:"profile-after-change"}],
getInterfaces: function(count) {
var interfaceList = [nsIClassInfo];
count.value = interfaceList.length;
return interfaceList;
},
getHelperForLanguage: function(count) { return null; }
};
var NSGetFactory = XPCOMUtils.generateNSGetFactory([StartupObserver]);
......@@ -7,7 +7,8 @@
* Tor check service
*************************************************************************/
const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
const { XPCOMUtils } = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
// Module specific constants
const kMODULE_NAME = "Torbutton Tor Check Service";
......@@ -130,5 +131,4 @@ TBTorCheckService.prototype =
},
};
const {XPCOMUtils} = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
var NSGetFactory = XPCOMUtils.generateNSGetFactory([TBTorCheckService]);
......@@ -15,7 +15,8 @@ const kMODULE_CID = Components.ID("f36d72c9-9718-4134-b550-e109638331d7");
ChromeUtils.import("resource://torbutton/modules/default-prefs.js", {}).ensureDefaultPrefs();
const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
const { XPCOMUtils } = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
function TorbuttonLogger() {
// Register observer
......@@ -44,10 +45,7 @@ function TorbuttonLogger() {
* Everything below is boring boilerplate and can probably be ignored.
*/
const nsISupports = Ci.nsISupports;
const nsIClassInfo = Ci.nsIClassInfo;
const nsIComponentRegistrar = Ci.nsIComponentRegistrar;
const nsIObserverService = Ci.nsIObserverService;
const logString = { 1:"VERB", 2:"DBUG", 3: "INFO", 4:"NOTE", 5:"WARN" };
......@@ -162,7 +160,6 @@ TorbuttonLogger.prototype =
* XPCOMUtils.generateNSGetFactory was introduced in Mozilla 2 (Firefox 4).
* XPCOMUtils.generateNSGetModule is for Mozilla 1.9.2 (Firefox 3.6).
*/
const {XPCOMUtils} = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
if (XPCOMUtils.generateNSGetFactory)
var NSGetFactory = XPCOMUtils.generateNSGetFactory([TorbuttonLogger]);
else
......
......@@ -100,7 +100,7 @@ var initialize = () => {
try {
// LegacyExtensionContext is not there anymore. Using raw
// Services.mm.broadcastAsyncMessage mecanism to communicate with
// Services.cpmm.sendAsyncMessage mechanism to communicate with
// NoScript.
// The component that handles WebExtensions' sendMessage.
......@@ -113,7 +113,7 @@ var initialize = () => {
// TODO: Is there a better way?
let sendNoScriptSettings = settings =>
Services.mm.broadcastAsyncMessage("MessageChannel:Messages", [{
Services.cpmm.sendAsyncMessage("MessageChannel:Messages", [{
messageName: "Extension:Message",
sender: { id: noscriptID, extensionId: noscriptID },
recipient: { extensionId: noscriptID },
......
......@@ -22,7 +22,7 @@
let { Constructor: CC } = Components;
// ### Import Mozilla Services
const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
// __log__.
// Logging function
......
......@@ -2,7 +2,7 @@
// Various helpful utility functions.
// ### Import Mozilla Services
const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
// ### About firstPartyDomain literal
const k_tb_about_uri_first_party_domain = "about.ef2a7dd5-93bc-417f-a698-142c3116864f.mozilla";
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment