[open-ils-commits] r12937 - trunk/Open-ILS/web/js/dojo/openils (erickson)

svn at svn.open-ils.org svn at svn.open-ils.org
Tue Apr 21 11:22:46 EDT 2009


Author: erickson
Date: 2009-04-21 11:22:43 -0400 (Tue, 21 Apr 2009)
New Revision: 12937

Modified:
   trunk/Open-ILS/web/js/dojo/openils/XUL.js
Log:
added func to turn on UniversalXPConnect and offer a friendly error when it fails

Modified: trunk/Open-ILS/web/js/dojo/openils/XUL.js
===================================================================
--- trunk/Open-ILS/web/js/dojo/openils/XUL.js	2009-04-21 15:13:18 UTC (rev 12936)
+++ trunk/Open-ILS/web/js/dojo/openils/XUL.js	2009-04-21 15:22:43 UTC (rev 12937)
@@ -4,22 +4,40 @@
     dojo.declare('openils.XUL', null, {});
 
     openils.XUL.isXUL = function() {
-        return window.IAMXUL;
+        return Boolean(window.IAMXUL);
     }
     
     openils.XUL.getStash = function() {
         if(openils.XUL.isXUL()) {
             try {
-			    netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
-			    var CacheClass = new Components.Constructor("@mozilla.org/openils_data_cache;1", "nsIOpenILS");
-			    return new CacheClass().wrappedJSObject.OpenILS.prototype.data;
+                if(openils.XUL.enableXPConnect()) {
+			        var CacheClass = new Components.Constructor("@mozilla.org/openils_data_cache;1", "nsIOpenILS");
+			        return new CacheClass().wrappedJSObject.OpenILS.prototype.data;
+                }
             } catch(e) {
                 console.log("Error loading XUL stash: " + e);
             }
         }
 
         return {};
-    };
+    }
+
+    /** 
+     * This can be used by privileged Firefox in addition to XUL.
+     * To use use in Firefox directly, set signed.applets.codebase_principal_support to true in about:config
+     */ 
+    openils.XUL.enableXPConnect = function() {
+        try {
+            netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
+        } catch (E) {
+            if(dojo.isFF) {
+                console.error("Unable to enable UniversalXPConnect privileges.  " +
+                    "Try setting 'signed.applets.codebase_principal_support' to true in about:config");
+            }
+            return false;
+        }
+        return true;
+    }
 }
 
 



More information about the open-ils-commits mailing list