Bug 1513535 - Support the ability to separate feature toggle and list update in URL classifier. r=gcp
authorDimi Lee <dlee@mozilla.com>
Tue, 22 Jan 2019 16:13:41 +0000
changeset 513756 f86cea87bf827f87f664068b76c01a8944deb22e
parent 513755 8442c715547483c98f5ca347333458b7fc54d2d6
child 513757 540a81dcd8c234b875df11ad30e2b1033c499b98
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgcp
bugs1513535
milestone67.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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
toolkit/components/url-classifier/SafeBrowsing.jsm
--- a/toolkit/components/url-classifier/SafeBrowsing.jsm
+++ b/toolkit/components/url-classifier/SafeBrowsing.jsm
@@ -33,83 +33,113 @@ function getLists(prefName) {
 }
 
 const FEATURES = [
   { name: "phishing",
     list: ["urlclassifier.phishTable"],
     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",
            "urlclassifier.downloadAllowTable"],
     enabled() {
       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",
            "urlclassifier.trackingAnnotationWhitelistTable"],
     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() {
       return Services.prefs.getBoolPref("toolkit.telemetry.isGeckoViewMode", false) ||
              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",
            "urlclassifier.flashAllowExceptTable",
            "urlclassifier.flashTable",
            "urlclassifier.flashExceptTable",
            "urlclassifier.flashSubDocTable",
            "urlclassifier.flashSubDocExceptTable"],
     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",
            "urlclassifier.features.fingerprinting.whitelistTables"],
     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",
            "urlclassifier.features.cryptomining.whitelistTables"],
     enabled() {
       return Services.prefs.getBoolPref("privacy.trackingprotection.cryptomining.enabled", false);
     },
+    update() {
+      return Services.prefs.getBoolPref("browser.safebrowsing.features.cryptomining.update", this.enabled());
+    },
   },
 ];
 
 var SafeBrowsing = {
 
 
   init() {
     if (this.initialized) {
@@ -240,19 +270,23 @@ var SafeBrowsing = {
     if (this.initialized) {
       obsoleteLists = this.features.map(feature => {
         return feature.list;
       });
     }
 
     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));
       });
     }
 
     for (let i = 0; i < obsoleteLists.length; ++i) {
       obsoleteLists[i] = obsoleteLists[i]
         .filter(list => !this.features[i].list.includes(list));
@@ -346,27 +380,28 @@ var SafeBrowsing = {
     }, this);
   },
 
   controlUpdateChecking() {
     if (loggingEnabled) {
       this.features.forEach(feature => {
         log("feature " + feature.name + ":");
         log("  enabled:" + feature.enabled);
+        log("  update:" + feature.update);
         log("  tables:" + feature.list);
       });
     }
 
     let listManager = Cc["@mozilla.org/url-classifier/listmanager;1"].
                       getService(Ci.nsIUrlListManager);
 
     listManager.disableAllUpdates();
 
     this.features.forEach(feature => {
-      if (feature.enabled) {
+      if (feature.update) {
         feature.list.forEach(table => {
           listManager.enableUpdate(table);
         });
       }
     });
 
     listManager.maybeToggleUpdateChecking();
   },