Bug 420356: Ship blocklist.xml with Firefox. r=gavin.sharp
authordtownsend@oxymoronical.com
Wed, 19 Mar 2008 15:35:03 -0700
changeset 13327 39e04a34dc742dffb709fed3ad1f50399216e072
parent 13326 470f78a71424c0487ade76d3d4c093f22774525a
child 13328 acc7a9c4e9ed88560bd3e251d44f9371a5a4a643
push idunknown
push userunknown
push dateunknown
reviewersgavin
bugs420356
milestone1.9b5pre
Bug 420356: Ship blocklist.xml with Firefox. r=gavin.sharp
browser/app/Makefile.in
browser/app/blocklist.xml
browser/installer/unix/packages-static
browser/installer/windows/packages-static
toolkit/mozapps/extensions/src/nsBlocklistService.js
--- a/browser/app/Makefile.in
+++ b/browser/app/Makefile.in
@@ -358,16 +358,19 @@ endif
 endif
 
 libs::
 	touch $(DIST)/bin/.autoreg
 
 libs:: $(srcdir)/profile/prefs.js
 	$(INSTALL) $^ $(DIST)/bin/defaults/profile
 
+libs:: $(srcdir)/blocklist.xml
+	$(INSTALL) $^ $(DIST)/bin
+
 ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
 
 APP_NAME = $(MOZ_APP_DISPLAYNAME)
 
 ifdef MOZ_DEBUG
 APP_NAME := $(APP_NAME)Debug
 endif
 
new file mode 100644
--- /dev/null
+++ b/browser/app/blocklist.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0"?>
+<blocklist xmlns="http://www.mozilla.org/2006/addons-blocklist">
+  <emItems>
+    <emItem id="fdm_ffext@freedownloadmanager.org">
+      <versionRange minVersion="1.0" maxVersion="1.3.1">
+        <targetApplication id="{ec8030f7-c20a-464f-9b0e-13a3a9e97384}">
+           <versionRange minVersion="3.0a1" maxVersion="*"/>
+        </targetApplication>
+      </versionRange>
+    </emItem>
+    <emItem id="mozilla_cc@internetdownloadmanager.com">
+      <versionRange minVersion="2.1" maxVersion="3.3">
+        <targetApplication id="{ec8030f7-c20a-464f-9b0e-13a3a9e97384}">
+           <versionRange minVersion="3.0a1" maxVersion="*"/>
+        </targetApplication>
+      </versionRange>
+    </emItem>
+  </emItems>
+</blocklist>
--- a/browser/installer/unix/packages-static
+++ b/browser/installer/unix/packages-static
@@ -46,16 +46,17 @@ bin/@MOZ_APP_NAME@-bin
 bin/@MOZ_APP_NAME@
 bin/application.ini
 bin/platform.ini
 bin/mozilla-xremote-client
 bin/run-mozilla.sh
 bin/plugins/libnullplugin.so
 bin/libsqlite3.so
 bin/README.txt
+bin/blocklist.xml
 
 ; [Components]
 bin/components/alerts.xpt
 bin/components/accessibility.xpt
 bin/components/appshell.xpt
 bin/components/appstartup.xpt
 bin/components/autocomplete.xpt
 bin/components/autoconfig.xpt
--- a/browser/installer/windows/packages-static
+++ b/browser/installer/windows/packages-static
@@ -55,16 +55,17 @@ bin\mozcrt19.dll
 ; [Base Browser Files]
 bin\@MOZ_APP_NAME@.exe
 bin\application.ini
 bin\platform.ini
 bin\plugins\npnul32.dll
 bin\LICENSE
 bin\README.txt
 bin\sqlite3.dll
+bin\blocklist.xml
 
 ; [Components]
 bin\components\alerts.xpt
 bin\AccessibleMarshal.dll
 bin\components\accessibility.xpt
 bin\components\accessibility-msaa.xpt
 bin\components\appshell.xpt
 bin\components\appstartup.xpt
--- a/toolkit/mozapps/extensions/src/nsBlocklistService.js
+++ b/toolkit/mozapps/extensions/src/nsBlocklistService.js
@@ -42,16 +42,17 @@
 const Cc = Components.classes;
 const Ci = Components.interfaces;
 const Cr = Components.results;
 
 Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
 
 const TOOLKIT_ID                      = "toolkit@mozilla.org"
 const KEY_PROFILEDIR                  = "ProfD";
+const KEY_APPDIR                      = "XCurProcD";
 const FILE_BLOCKLIST                  = "blocklist.xml";
 const PREF_BLOCKLIST_URL              = "extensions.blocklist.url";
 const PREF_BLOCKLIST_ENABLED          = "extensions.blocklist.enabled";
 const PREF_BLOCKLIST_INTERVAL         = "extensions.blocklist.interval";
 const PREF_EM_LOGGING_ENABLED         = "extensions.logging.enabled";
 const XMLURI_BLOCKLIST                = "http://www.mozilla.org/2006/addons-blocklist";
 const XMLURI_PARSE_ERROR              = "http://www.mozilla.org/newlayout/xml/parsererror.xml"
 
@@ -270,17 +271,17 @@ Blocklist.prototype = {
       gVersionChecker = null;
       gApp = null;
       break;
     }
   },
 
   isAddonBlocklisted: function(id, version, appVersion, toolkitVersion) {
     if (!this._addonEntries)
-      this._loadBlocklistFromFile(getFile(KEY_PROFILEDIR, [FILE_BLOCKLIST]));
+      this._loadBlocklist();
     if (!appVersion)
       appVersion = gApp.version;
     if (!toolkitVersion)
       toolkitVersion = gApp.platformVersion;
 
     var blItem = this._addonEntries[id];
     if (!blItem)
       return false;
@@ -394,16 +395,31 @@ Blocklist.prototype = {
     // When status is 0 we don't have a valid channel.
     if (status == 0)
       statusText = "nsIXMLHttpRequest channel unavailable";
     LOG("Blocklist:onError: There was an error loading the blocklist file\r\n" +
         statusText);
   },
 
   /**
+   * Finds the newest blocklist file from the application and the profile and
+   * load it or does nothing if neither exist.
+   */
+  _loadBlocklist: function() {
+    var profFile = getFile(KEY_PROFILEDIR, [FILE_BLOCKLIST]);
+    if (profFile.exists()) {
+      this._loadBlocklistFromFile(profFile);
+      return;
+    }
+    var appFile = getFile(KEY_APPDIR, [FILE_BLOCKLIST]);
+    if (appFile.exists())
+      this._loadBlocklistFromFile(appFile);
+  },
+
+  /**
 #    The blocklist XML file looks something like this:
 #
 #    <blocklist xmlns="http://www.mozilla.org/2006/addons-blocklist">
 #      <emItems>
 #        <emItem id="item_1@domain">
 #          <versionRange minVersion="1.0" maxVersion="2.0.*">
 #            <targetApplication id="{ec8030f7-c20a-464f-9b0e-13a3a9e97384}">
 #              <versionRange minVersion="1.5" maxVersion="1.5.*"/>
@@ -576,17 +592,17 @@ Blocklist.prototype = {
         return;
       }
     }
     plugin.blocklisted = false;
   },
 
   _checkPluginsList: function() {
     if (!this._addonEntries)
-      this._loadBlocklistFromFile(getFile(KEY_PROFILEDIR, [FILE_BLOCKLIST]));
+      this._loadBlocklist();
     var phs = Cc["@mozilla.org/plugin/host;1"].
               getService(Ci.nsIPluginHost);
     phs.getPluginTags({ }).forEach(this._checkPlugin, this);
   },
 
   classDescription: "Blocklist Service",
   contractID: "@mozilla.org/extensions/blocklist;1",
   classID: Components.ID("{66354bc9-7ed1-4692-ae1d-8da97d6b205e}"),