Bug 788704 - add telemetry for enablePrivilege; r=bholley
authorNathan Froyd <froydnj@mozilla.com>
Mon, 17 Sep 2012 17:03:42 -0400
changeset 107386 703fb179c834b67cb55953d10dc44a693a52cbb4
parent 107385 b898c97f998d5360db69ae767e23ce40201aad41
child 107387 af44e1c2035219e319aac901373784930d674ce6
push id74
push usershu@rfrn.org
push dateTue, 18 Sep 2012 19:23:47 +0000
reviewersbholley
bugs788704
milestone18.0a1
Bug 788704 - add telemetry for enablePrivilege; r=bholley
caps/src/nsSecurityManagerFactory.cpp
toolkit/components/telemetry/Histograms.json
--- a/caps/src/nsSecurityManagerFactory.cpp
+++ b/caps/src/nsSecurityManagerFactory.cpp
@@ -22,16 +22,19 @@
 #include "nsIClassInfoImpl.h"
 #include "nsJSUtils.h"
 #include "nsPIDOMWindow.h"
 #include "nsIScriptGlobalObject.h"
 #include "nsIDocument.h"
 #include "jsfriendapi.h"
 #include "xpcprivate.h"
 #include "mozilla/Preferences.h"
+#include "mozilla/Telemetry.h"
+
+using namespace mozilla;
 
 ///////////////////////
 // nsSecurityNameSet //
 ///////////////////////
 
 nsSecurityNameSet::nsSecurityNameSet()
 {
 }
@@ -40,16 +43,17 @@ nsSecurityNameSet::~nsSecurityNameSet()
 {
 }
 
 NS_IMPL_ISUPPORTS1(nsSecurityNameSet, nsIScriptExternalNameSet)
 
 static JSBool
 netscape_security_enablePrivilege(JSContext *cx, unsigned argc, jsval *vp)
 {
+    Telemetry::Accumulate(Telemetry::ENABLE_PRIVILEGE_EVER_CALLED, true);
     return xpc::EnableUniversalXPConnect(cx);
 }
 
 static JSFunctionSpec PrivilegeManager_static_methods[] = {
     JS_FS("enablePrivilege", netscape_security_enablePrivilege, 1, 0),
     JS_FS_END
 };
 
@@ -64,17 +68,17 @@ nsSecurityNameSet::InitializeNameSet(nsI
     JSObject *global = JS_ObjectToInnerObject(cx, JS_GetGlobalObject(cx));
 
     // We hide enablePrivilege behind a pref because it has been altered in a
     // way that makes it fundamentally insecure to use in production. Mozilla
     // uses this pref during automated testing to support legacy test code that
     // uses enablePrivilege. If you're not doing test automation, you _must_ not
     // flip this pref, or you will be exposing all your users to security
     // vulnerabilities.
-    if (!mozilla::Preferences::GetBool("security.enablePrivilege.enable_for_tests"))
+    if (!Preferences::GetBool("security.enablePrivilege.enable_for_tests"))
         return NS_OK;
 
     /*
      * Find Object.prototype's class by walking up the global object's
      * prototype chain.
      */
     JSObject *obj = global;
     JSObject *proto;
--- a/toolkit/components/telemetry/Histograms.json
+++ b/toolkit/components/telemetry/Histograms.json
@@ -2211,10 +2211,14 @@
   },
   "SOCIAL_ENABLED_ON_SESSION": {
     "kind": "flag",
     "description": "Social has been enabled at least once on the current session"
   },
   "SOCIAL_TOGGLED": {
     "kind": "boolean",
     "description": "Social has been toggled to on or off"
+  },
+  "ENABLE_PRIVILEGE_EVER_CALLED": {
+    "kind": "flag",
+    "description": "Whether enablePrivilege has ever been called during the current session"
   }
 }