Skip to content
Snippets Groups Projects
Verified Commit de446ffa authored by Pier Angelo Vendrame's avatar Pier Angelo Vendrame :jack_o_lantern:
Browse files

fixup! Bug 40925: Implemented the Security Level component

Improve the patch to skip DDG redirection for 115.
parent 24ab2f48
No related branches found
No related tags found
1 merge request!694Bug 41796: Rebased on top of FIREFOX_ESR_115_BASE
......@@ -2,6 +2,12 @@
/* global AppConstants, Services, openPreferences, XPCOMUtils */
ChromeUtils.defineModuleGetter(
this,
"SecurityLevelPrefs",
"resource://gre/modules/SecurityLevel.jsm"
);
XPCOMUtils.defineLazyGetter(this, "SecurityLevelStrings", () => {
let strings = {
// Generic terms
......@@ -61,45 +67,6 @@ XPCOMUtils.defineLazyGetter(this, "SecurityLevelStrings", () => {
return strings;
});
/*
Security Level Prefs
Getters and Setters for relevant torbutton prefs
*/
var SecurityLevelPrefs = {
SecurityLevels: Object.freeze({
safest: 1,
safer: 2,
standard: 4,
}),
security_slider_pref: "browser.security_level.security_slider",
security_custom_pref: "browser.security_level.security_custom",
get securityLevel() {
// Set the default return value to 0, which won't match anything in
// SecurityLevels.
const val = Services.prefs.getIntPref(this.security_slider_pref, 0);
return Object.entries(this.SecurityLevels).find(
entry => entry[1] === val
)?.[0];
},
set securityLevel(level) {
const val = this.SecurityLevels[level];
if (val !== undefined) {
Services.prefs.setIntPref(this.security_slider_pref, val);
}
},
get securityCustom() {
return Services.prefs.getBoolPref(this.security_custom_pref);
},
set securityCustom(val) {
Services.prefs.setBoolPref(this.security_custom_pref, val);
},
}; /* Security Level Prefs */
/*
Security Level Button Code
......
......@@ -14,6 +14,12 @@ ChromeUtils.defineESModuleGetters(lazy, {
SearchUtils: "resource://gre/modules/SearchUtils.sys.mjs",
});
ChromeUtils.defineModuleGetter(
lazy,
"SecurityLevelPrefs",
"resource://gre/modules/SecurityLevel.jsm"
);
const BinaryInputStream = Components.Constructor(
"@mozilla.org/binaryinputstream;1",
"nsIBinaryInputStream",
......@@ -27,12 +33,6 @@ XPCOMUtils.defineLazyGetter(lazy, "logConsole", () => {
});
});
XPCOMUtils.defineLazyScriptGetter(
this,
"SecurityLevelPrefs",
"chrome://browser/content/securitylevel/securityLevel.js"
);
const USER_DEFINED = "searchTerms";
// Supported OpenSearch parameters
......@@ -444,8 +444,8 @@ export class EngineURL {
engine &&
(engine._extensionID === "ddg@search.mozilla.org" ||
engine._extensionID === "ddg-onion@search.mozilla.org") &&
this.type === SearchUtils.URL_TYPE.SEARCH &&
SecurityLevelPrefs?.securityLevel === "safest"
this.type === lazy.SearchUtils.URL_TYPE.SEARCH &&
lazy.SecurityLevelPrefs?.securityLevel === "safest"
) {
urlTemplate += "html";
}
......
"use strict";
var EXPORTED_SYMBOLS = ["SecurityLevel"];
var EXPORTED_SYMBOLS = ["SecurityLevel", "SecurityLevelPrefs"];
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
const { XPCOMUtils } = ChromeUtils.import(
"resource://gre/modules/XPCOMUtils.jsm"
);
const { ConsoleAPI } = ChromeUtils.import("resource://gre/modules/Console.jsm");
const lazy = {};
XPCOMUtils.defineLazyModuleGetters(lazy, {
ExtensionParent: "resource://gre/modules/ExtensionParent.jsm",
});
ChromeUtils.defineModuleGetter(
lazy,
"ExtensionParent",
"resource://gre/modules/ExtensionParent.jsm"
);
const logger = new ConsoleAPI({
maxLogLevel: "info",
......@@ -443,3 +442,42 @@ class SecurityLevel {
}
}
}
/*
Security Level Prefs
Getters and Setters for relevant torbutton prefs
*/
const SecurityLevelPrefs = {
SecurityLevels: Object.freeze({
safest: 1,
safer: 2,
standard: 4,
}),
security_slider_pref: "browser.security_level.security_slider",
security_custom_pref: "browser.security_level.security_custom",
get securityLevel() {
// Set the default return value to 0, which won't match anything in
// SecurityLevels.
const val = Services.prefs.getIntPref(this.security_slider_pref, 0);
return Object.entries(this.SecurityLevels).find(
entry => entry[1] === val
)?.[0];
},
set securityLevel(level) {
const val = this.SecurityLevels[level];
if (val !== undefined) {
Services.prefs.setIntPref(this.security_slider_pref, val);
}
},
get securityCustom() {
return Services.prefs.getBoolPref(this.security_custom_pref);
},
set securityCustom(val) {
Services.prefs.setBoolPref(this.security_custom_pref, val);
},
}; /* Security Level Prefs */
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment