Bug 1535304 - Remove provider from about:url-classifier if no table is being used. r=gcp
authordlee <dlee@mozilla.com>
Thu, 21 Mar 2019 07:54:20 +0000
changeset 524196 c78da14598ce7727d70e51700bf7afee901aa0e7
parent 524195 7c998456e1fd5aa0271b8508a25a5becec2768e0
child 524197 25ebfc26acfccd17f5e66c5f0640ba8f1dca5f91
push id11265
push userffxbld-merge
push dateMon, 13 May 2019 10:53:39 +0000
treeherdermozilla-beta@77e0fe8dbdd3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgcp
bugs1535304
milestone68.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 1535304 - Remove provider from about:url-classifier if no table is being used. r=gcp Differential Revision: https://phabricator.services.mozilla.com/D24290
toolkit/content/aboutUrlClassifier.js
--- a/toolkit/content/aboutUrlClassifier.js
+++ b/toolkit/content/aboutUrlClassifier.js
@@ -183,17 +183,20 @@ var Provider = {
 
   updatingProvider: "",
 
   init() {
     this.providers = new Set();
     let branch = Services.prefs.getBranch("browser.safebrowsing.provider.");
     let children = branch.getChildList("", {});
     for (let child of children) {
-      this.providers.add(child.split(".")[0]);
+      let provider = child.split(".")[0];
+      if (this.isActiveProvider(provider)) {
+        this.providers.add(provider);
+      }
     }
 
     this.register();
     this.render();
     this.refresh();
   },
 
   uninit() {
@@ -322,16 +325,35 @@ var Provider = {
 
     if (!listmanager.forceUpdates(tables)) {
       // This may because of back-off algorithm.
       let elem = document.getElementById(provider + "-col-lastupdateresult");
       document.l10n.setAttributes(elem, "url-classifier-cannot-update");
     }
   },
 
+  // if we can find any table registered an updateURL in the listmanager,
+  // the provider is active. This is used to filter out google v2 provider
+  // without changing the preference.
+  isActiveProvider(provider) {
+    let listmanager = Cc["@mozilla.org/url-classifier/listmanager;1"]
+                      .getService(Ci.nsIUrlListManager);
+
+    let pref = "browser.safebrowsing.provider." + provider + ".lists";
+    let tables = Services.prefs.getCharPref(pref, "").split(",");
+
+    for (let i = 0; i < tables.length; i++) {
+      let updateUrl = listmanager.getUpdateUrl(tables[i]);
+      if (updateUrl) {
+        return true;
+      }
+    }
+
+    return false;
+  },
 };
 
 /*
  * Cache
  */
 var Cache = {
   // Tables that show cahe entries.
   showCacheEnties: null,