Bug 1513535 - Support the ability to separate feature toggle and list update in URL classifier. r=gcp
Add preferences "browser.safebrowsing.features.[feature name].update". Normally these preferences won't be set so the SafeBrowsing uses features's enable/disable preferences to decide if it should update the list or not. If an update preference is present, then it has higher priority then the enable/disable one. This provides a way for the SafeBrowsing consumer to be able to separate feature toggle and upodate. Differential Revision: https://phabricator.services.mozilla.com/D17233
This commit is contained in:
@@ -38,24 +38,36 @@ const FEATURES = [
|
||||
enabled() {
|
||||
return Services.prefs.getBoolPref("browser.safebrowsing.phishing.enabled");
|
||||
},
|
||||
update() {
|
||||
return Services.prefs.getBoolPref("browser.safebrowsing.features.phishing.update", this.enabled());
|
||||
},
|
||||
},
|
||||
{ name: "malware",
|
||||
list: ["urlclassifier.malwareTable"],
|
||||
enabled() {
|
||||
return Services.prefs.getBoolPref("browser.safebrowsing.malware.enabled");
|
||||
},
|
||||
update() {
|
||||
return Services.prefs.getBoolPref("browser.safebrowsing.features.malware.update", this.enabled());
|
||||
},
|
||||
},
|
||||
{ name: "blockedURIs",
|
||||
list: ["urlclassifier.blockedTable"],
|
||||
enabled() {
|
||||
return Services.prefs.getBoolPref("browser.safebrowsing.blockedURIs.enabled");
|
||||
},
|
||||
update() {
|
||||
return Services.prefs.getBoolPref("browser.safebrowsing.features.blockedURIs.update", this.enabled());
|
||||
},
|
||||
},
|
||||
{ name: "passwords",
|
||||
list: ["urlclassifier.passwordAllowTable"],
|
||||
enabled() {
|
||||
return Services.prefs.getBoolPref("browser.safebrowsing.passwords.enabled");
|
||||
},
|
||||
update() {
|
||||
return Services.prefs.getBoolPref("browser.safebrowsing.features.passwords.update", this.enabled());
|
||||
},
|
||||
},
|
||||
{ name: "downloads",
|
||||
list: ["urlclassifier.downloadBlockTable",
|
||||
@@ -64,6 +76,9 @@ const FEATURES = [
|
||||
return Services.prefs.getBoolPref("browser.safebrowsing.downloads.enabled") &&
|
||||
Services.prefs.getBoolPref("browser.safebrowsing.malware.enabled");
|
||||
},
|
||||
update() {
|
||||
return Services.prefs.getBoolPref("browser.safebrowsing.features.downloads.update", this.enabled());
|
||||
},
|
||||
},
|
||||
{ name: "trackingAnnotation",
|
||||
list: ["urlclassifier.trackingAnnotationTable",
|
||||
@@ -71,8 +86,11 @@ const FEATURES = [
|
||||
enabled() {
|
||||
return Services.prefs.getBoolPref("privacy.trackingprotection.annotate_channels");
|
||||
},
|
||||
update() {
|
||||
return Services.prefs.getBoolPref("browser.safebrowsing.features.trackingAnnotation.update", this.enabled());
|
||||
},
|
||||
},
|
||||
{ name: "tracking",
|
||||
{ name: "trackingProtection",
|
||||
list: ["urlclassifier.trackingTable",
|
||||
"urlclassifier.trackingWhitelistTable"],
|
||||
enabled() {
|
||||
@@ -80,6 +98,9 @@ const FEATURES = [
|
||||
Services.prefs.getBoolPref("privacy.trackingprotection.enabled") ||
|
||||
Services.prefs.getBoolPref("privacy.trackingprotection.pbmode.enabled");
|
||||
},
|
||||
update() {
|
||||
return Services.prefs.getBoolPref("browser.safebrowsing.features.trackingProtection.update", this.enabled());
|
||||
},
|
||||
},
|
||||
{ name: "flashBlock",
|
||||
list: ["urlclassifier.flashAllowTable",
|
||||
@@ -91,6 +112,9 @@ const FEATURES = [
|
||||
enabled() {
|
||||
return Services.prefs.getBoolPref("plugins.flashBlock.enabled");
|
||||
},
|
||||
update() {
|
||||
return Services.prefs.getBoolPref("browser.safebrowsing.features.flashBlock.update", this.enabled());
|
||||
},
|
||||
},
|
||||
{ name: "fingerprinting",
|
||||
list: ["urlclassifier.features.fingerprinting.blacklistTables",
|
||||
@@ -98,6 +122,9 @@ const FEATURES = [
|
||||
enabled() {
|
||||
return Services.prefs.getBoolPref("privacy.trackingprotection.fingerprinting.enabled", false);
|
||||
},
|
||||
update() {
|
||||
return Services.prefs.getBoolPref("browser.safebrowsing.features.fingerprinting.update", this.enabled());
|
||||
},
|
||||
},
|
||||
{ name: "cryptomining",
|
||||
list: ["urlclassifier.features.cryptomining.blacklistTables",
|
||||
@@ -105,6 +132,9 @@ const FEATURES = [
|
||||
enabled() {
|
||||
return Services.prefs.getBoolPref("privacy.trackingprotection.cryptomining.enabled", false);
|
||||
},
|
||||
update() {
|
||||
return Services.prefs.getBoolPref("browser.safebrowsing.features.cryptomining.update", this.enabled());
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
@@ -245,9 +275,13 @@ var SafeBrowsing = {
|
||||
|
||||
this.features = [];
|
||||
for (let i = 0; i < FEATURES.length; ++i) {
|
||||
this.features[i] = { name: FEATURES[i].name,
|
||||
list: [],
|
||||
enabled: FEATURES[i].enabled() };
|
||||
this.features[i] = {
|
||||
name: FEATURES[i].name,
|
||||
list: [],
|
||||
enabled: FEATURES[i].enabled(),
|
||||
update: FEATURES[i].update(),
|
||||
};
|
||||
|
||||
FEATURES[i].list.forEach(pref => {
|
||||
this.features[i].list.push(...getLists(pref));
|
||||
});
|
||||
@@ -351,6 +385,7 @@ var SafeBrowsing = {
|
||||
this.features.forEach(feature => {
|
||||
log("feature " + feature.name + ":");
|
||||
log(" enabled:" + feature.enabled);
|
||||
log(" update:" + feature.update);
|
||||
log(" tables:" + feature.list);
|
||||
});
|
||||
}
|
||||
@@ -361,7 +396,7 @@ var SafeBrowsing = {
|
||||
listManager.disableAllUpdates();
|
||||
|
||||
this.features.forEach(feature => {
|
||||
if (feature.enabled) {
|
||||
if (feature.update) {
|
||||
feature.list.forEach(table => {
|
||||
listManager.enableUpdate(table);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user