fixes for firefox 4
authorDave Raggett <dsr@w3.org>
Fri, 29 Apr 2011 12:19:15 +0100
changeset 1 fe95b601b6c5
parent 0 8ed5ca0acbac
child 2 31a229b2b546
fixes for firefox 4
dashboard/chrome/content/dashboard.js
dashboard/chrome/content/database.js
dashboard/chrome/content/overlay.js
dashboard/dashboard.xpi
dashboard/install.rdf
--- a/dashboard/chrome/content/dashboard.js	Thu Apr 28 17:55:08 2011 +0100
+++ b/dashboard/chrome/content/dashboard.js	Fri Apr 29 12:19:15 2011 +0100
@@ -171,13 +171,28 @@
     // activate helper object for assessing current site
     assess.start_up(this);
 
-    // get extension's version number
-    let gExtensionManager = Components.classes["@mozilla.org/extensions/manager;1"]
+    // copy version number into about tab
+
+    try
+    {
+      // Firefox 4 and later; Mozilla 2 and later
+      Components.utils.import("resource://gre/modules/AddonManager.jsm");
+      AddonManager.getAddonByID("[email protected]",
+        function(addon)
+        {
+          let about_heading = document.getElementById("dashboard_heading");
+          about_heading.innerHTML = about_heading.innerHTML + " " + addon.version;
+        });
+    }
+    catch (e)
+    {
+      // Firefox 3.6 and before; Mozilla 1.9.2 and before
+      let gExtensionManager = Components.classes["@mozilla.org/extensions/manager;1"]
                         .getService(Components.interfaces.nsIExtensionManager);
-    let myVersion = gExtensionManager.getItemForID("[email protected]").version;
-
-    let about_heading = document.getElementById("dashboard_heading");
-    about_heading.innerHTML = about_heading.innerHTML + " " + myVersion;
+      let addon = gExtensionManager.getItemForID("[email protected]");
+      let about_heading = document.getElementById("dashboard_heading");
+      about_heading.innerHTML = about_heading.innerHTML + " " + addon.version;
+    }
 
     // record whether site supports P3P
 
--- a/dashboard/chrome/content/database.js	Thu Apr 28 17:55:08 2011 +0100
+++ b/dashboard/chrome/content/database.js	Fri Apr 29 12:19:15 2011 +0100
@@ -811,6 +811,7 @@
   // encoded as a bit vector
   set_prefs: function (host, prefs)
   {
+    console.log("database:set_prefs " + prefs);
     this.update_or_insert(host, "prefs", prefs);
 
     // and synchronise session cache
--- a/dashboard/chrome/content/overlay.js	Thu Apr 28 17:55:08 2011 +0100
+++ b/dashboard/chrome/content/overlay.js	Fri Apr 29 12:19:15 2011 +0100
@@ -164,7 +164,7 @@
     // dashbot support
     this.site_index = 0;
 
-    if (top_sites)  // see top-sites.js
+    if (typeof(top_sites) != "undefined")  // see top-sites.js
     {
       let ioService = Components.classes["@mozilla.org/network/io-service;1"]
                               .getService(Components.interfaces.nsIIOService);
@@ -210,7 +210,7 @@
     {
       Components.utils.import("resource://gre/modules/AddonManager.jsm");
       AddonManager.getAddonByID("[email protected]",
-                  function(addon) { this.check_version(addon.version); });
+                  function(addon) { dashboard_overlay.check_version(addon.version); });
     }
     catch (e) // fall back for Firefox 3.6 and earlier
     {
@@ -345,7 +345,7 @@
 
   sync_prefs: function (host, prefs)
   {
-    if (host && prefs)
+    if (typeof(host) != "undefined" && typeof(prefs) != "undefined")
     {
       this.context.preferences[host] = prefs;
       this.apply_prefs(prefs);
@@ -421,6 +421,15 @@
 
     if (typeof(prefs) != "undefined")
     {
+      if (prefs < 3)
+      {
+        // default is carefree: don't block anything
+        if (prefs == 1)
+          prefs |= (1 << 4)|(1<<9);  // thoughtful
+        else if (prefs == 2) // paranoid, so block pretty much everything!
+          prefs |= (1<<4)|(1<<5)|(1<<6)|(1<<7)|(1<<8)|(1<<9)|(1<<10)|(1<<11)|(1<<12)|(1<<13);
+      }
+
       // see assess:save_prefs for bit position
       let block_scripting = prefs & (1 << 7);
       javascript_prefs.setBoolPref("enabled", !block_scripting);
@@ -435,6 +444,7 @@
     }
     else
     {
+      console.log("prefs is undefined");
       javascript_prefs.setBoolPref("enabled", true);
       geo_prefs.setBoolPref("enabled", true);
       browser_prefs.setBoolPref("send_pings", false);  // Firefox default
Binary file dashboard/dashboard.xpi has changed
--- a/dashboard/install.rdf	Thu Apr 28 17:55:08 2011 +0100
+++ b/dashboard/install.rdf	Fri Apr 29 12:19:15 2011 +0100
@@ -3,7 +3,7 @@
  xmlns:em="http://www.mozilla.org/2004/em-rdf#">
   <Description about="urn:mozilla:install-manifest">
     <em:id>[email protected]</em:id>
-    <em:version>0.9.2</em:version>
+    <em:version>0.9.3</em:version>
     <em:localized>
       <Description> <!-- example localization via google translate -->
         <em:locale>fr-FR</em:locale>