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() {
|
enabled() {
|
||||||
return Services.prefs.getBoolPref("browser.safebrowsing.phishing.enabled");
|
return Services.prefs.getBoolPref("browser.safebrowsing.phishing.enabled");
|
||||||
},
|
},
|
||||||
|
update() {
|
||||||
|
return Services.prefs.getBoolPref("browser.safebrowsing.features.phishing.update", this.enabled());
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{ name: "malware",
|
{ name: "malware",
|
||||||
list: ["urlclassifier.malwareTable"],
|
list: ["urlclassifier.malwareTable"],
|
||||||
enabled() {
|
enabled() {
|
||||||
return Services.prefs.getBoolPref("browser.safebrowsing.malware.enabled");
|
return Services.prefs.getBoolPref("browser.safebrowsing.malware.enabled");
|
||||||
},
|
},
|
||||||
|
update() {
|
||||||
|
return Services.prefs.getBoolPref("browser.safebrowsing.features.malware.update", this.enabled());
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{ name: "blockedURIs",
|
{ name: "blockedURIs",
|
||||||
list: ["urlclassifier.blockedTable"],
|
list: ["urlclassifier.blockedTable"],
|
||||||
enabled() {
|
enabled() {
|
||||||
return Services.prefs.getBoolPref("browser.safebrowsing.blockedURIs.enabled");
|
return Services.prefs.getBoolPref("browser.safebrowsing.blockedURIs.enabled");
|
||||||
},
|
},
|
||||||
|
update() {
|
||||||
|
return Services.prefs.getBoolPref("browser.safebrowsing.features.blockedURIs.update", this.enabled());
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{ name: "passwords",
|
{ name: "passwords",
|
||||||
list: ["urlclassifier.passwordAllowTable"],
|
list: ["urlclassifier.passwordAllowTable"],
|
||||||
enabled() {
|
enabled() {
|
||||||
return Services.prefs.getBoolPref("browser.safebrowsing.passwords.enabled");
|
return Services.prefs.getBoolPref("browser.safebrowsing.passwords.enabled");
|
||||||
},
|
},
|
||||||
|
update() {
|
||||||
|
return Services.prefs.getBoolPref("browser.safebrowsing.features.passwords.update", this.enabled());
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{ name: "downloads",
|
{ name: "downloads",
|
||||||
list: ["urlclassifier.downloadBlockTable",
|
list: ["urlclassifier.downloadBlockTable",
|
||||||
@@ -64,6 +76,9 @@ const FEATURES = [
|
|||||||
return Services.prefs.getBoolPref("browser.safebrowsing.downloads.enabled") &&
|
return Services.prefs.getBoolPref("browser.safebrowsing.downloads.enabled") &&
|
||||||
Services.prefs.getBoolPref("browser.safebrowsing.malware.enabled");
|
Services.prefs.getBoolPref("browser.safebrowsing.malware.enabled");
|
||||||
},
|
},
|
||||||
|
update() {
|
||||||
|
return Services.prefs.getBoolPref("browser.safebrowsing.features.downloads.update", this.enabled());
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{ name: "trackingAnnotation",
|
{ name: "trackingAnnotation",
|
||||||
list: ["urlclassifier.trackingAnnotationTable",
|
list: ["urlclassifier.trackingAnnotationTable",
|
||||||
@@ -71,8 +86,11 @@ const FEATURES = [
|
|||||||
enabled() {
|
enabled() {
|
||||||
return Services.prefs.getBoolPref("privacy.trackingprotection.annotate_channels");
|
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",
|
list: ["urlclassifier.trackingTable",
|
||||||
"urlclassifier.trackingWhitelistTable"],
|
"urlclassifier.trackingWhitelistTable"],
|
||||||
enabled() {
|
enabled() {
|
||||||
@@ -80,6 +98,9 @@ const FEATURES = [
|
|||||||
Services.prefs.getBoolPref("privacy.trackingprotection.enabled") ||
|
Services.prefs.getBoolPref("privacy.trackingprotection.enabled") ||
|
||||||
Services.prefs.getBoolPref("privacy.trackingprotection.pbmode.enabled");
|
Services.prefs.getBoolPref("privacy.trackingprotection.pbmode.enabled");
|
||||||
},
|
},
|
||||||
|
update() {
|
||||||
|
return Services.prefs.getBoolPref("browser.safebrowsing.features.trackingProtection.update", this.enabled());
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{ name: "flashBlock",
|
{ name: "flashBlock",
|
||||||
list: ["urlclassifier.flashAllowTable",
|
list: ["urlclassifier.flashAllowTable",
|
||||||
@@ -91,6 +112,9 @@ const FEATURES = [
|
|||||||
enabled() {
|
enabled() {
|
||||||
return Services.prefs.getBoolPref("plugins.flashBlock.enabled");
|
return Services.prefs.getBoolPref("plugins.flashBlock.enabled");
|
||||||
},
|
},
|
||||||
|
update() {
|
||||||
|
return Services.prefs.getBoolPref("browser.safebrowsing.features.flashBlock.update", this.enabled());
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{ name: "fingerprinting",
|
{ name: "fingerprinting",
|
||||||
list: ["urlclassifier.features.fingerprinting.blacklistTables",
|
list: ["urlclassifier.features.fingerprinting.blacklistTables",
|
||||||
@@ -98,6 +122,9 @@ const FEATURES = [
|
|||||||
enabled() {
|
enabled() {
|
||||||
return Services.prefs.getBoolPref("privacy.trackingprotection.fingerprinting.enabled", false);
|
return Services.prefs.getBoolPref("privacy.trackingprotection.fingerprinting.enabled", false);
|
||||||
},
|
},
|
||||||
|
update() {
|
||||||
|
return Services.prefs.getBoolPref("browser.safebrowsing.features.fingerprinting.update", this.enabled());
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{ name: "cryptomining",
|
{ name: "cryptomining",
|
||||||
list: ["urlclassifier.features.cryptomining.blacklistTables",
|
list: ["urlclassifier.features.cryptomining.blacklistTables",
|
||||||
@@ -105,6 +132,9 @@ const FEATURES = [
|
|||||||
enabled() {
|
enabled() {
|
||||||
return Services.prefs.getBoolPref("privacy.trackingprotection.cryptomining.enabled", false);
|
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 = [];
|
this.features = [];
|
||||||
for (let i = 0; i < FEATURES.length; ++i) {
|
for (let i = 0; i < FEATURES.length; ++i) {
|
||||||
this.features[i] = { name: FEATURES[i].name,
|
this.features[i] = {
|
||||||
list: [],
|
name: FEATURES[i].name,
|
||||||
enabled: FEATURES[i].enabled() };
|
list: [],
|
||||||
|
enabled: FEATURES[i].enabled(),
|
||||||
|
update: FEATURES[i].update(),
|
||||||
|
};
|
||||||
|
|
||||||
FEATURES[i].list.forEach(pref => {
|
FEATURES[i].list.forEach(pref => {
|
||||||
this.features[i].list.push(...getLists(pref));
|
this.features[i].list.push(...getLists(pref));
|
||||||
});
|
});
|
||||||
@@ -351,6 +385,7 @@ var SafeBrowsing = {
|
|||||||
this.features.forEach(feature => {
|
this.features.forEach(feature => {
|
||||||
log("feature " + feature.name + ":");
|
log("feature " + feature.name + ":");
|
||||||
log(" enabled:" + feature.enabled);
|
log(" enabled:" + feature.enabled);
|
||||||
|
log(" update:" + feature.update);
|
||||||
log(" tables:" + feature.list);
|
log(" tables:" + feature.list);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -361,7 +396,7 @@ var SafeBrowsing = {
|
|||||||
listManager.disableAllUpdates();
|
listManager.disableAllUpdates();
|
||||||
|
|
||||||
this.features.forEach(feature => {
|
this.features.forEach(feature => {
|
||||||
if (feature.enabled) {
|
if (feature.update) {
|
||||||
feature.list.forEach(table => {
|
feature.list.forEach(table => {
|
||||||
listManager.enableUpdate(table);
|
listManager.enableUpdate(table);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user