Bug 949224 - Collect UITelemetry on how many items are in the addon bar. r=jaws, a=lsblakk.
authorMike Conley <mconley@mozilla.com>
Mon, 16 Dec 2013 14:14:22 -0500
changeset 174329 c48afe7549080e5df4997233c81b2a0674ef0a79
parent 174328 b20cdabdfb5b0004c80101f7732a935901c6f726
child 174330 f7e5a0bf9500ca2e6c39883115e83641da29bc76
push id3224
push userlsblakk@mozilla.com
push dateTue, 04 Feb 2014 01:06:49 +0000
treeherdermozilla-beta@60c04d0987f1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjaws, lsblakk
bugs949224
milestone28.0a2
Bug 949224 - Collect UITelemetry on how many items are in the addon bar. r=jaws, a=lsblakk.
browser/modules/BrowserUITelemetry.jsm
--- a/browser/modules/BrowserUITelemetry.jsm
+++ b/browser/modules/BrowserUITelemetry.jsm
@@ -499,16 +499,17 @@ this.BrowserUITelemetry = {
     result.bookmarksBarEnabled = bookmarksBar && !bookmarksBar.collapsed;
 
     // Examine the default toolbars and see what default items
     // are present and missing.
     let defaultKept = [];
     let defaultMoved = [];
     let nondefaultAdded = [];
     let customToolbars = 0;
+    let addonBarItems = 0;
 
     let toolbars = document.querySelectorAll("toolbar[customizable=true]");
     for (let toolbar of toolbars) {
       let toolbarID = toolbar.id;
       let currentset = toolbar.currentSet;
       // It's possible add-ons might have wiped out the currentSet property,
       // so we'll be a little defensive here.
       currentset = (currentset && currentset.split(",")) || [];
@@ -526,16 +527,26 @@ this.BrowserUITelemetry = {
             defaultKept.push(item);
           } else {
             defaultMoved.push(item);
           }
         } else if (PALETTE_ITEMS.indexOf(item) != -1) {
           // It's a palette item that's been moved into a toolbar
           nondefaultAdded.push(item);
         }
+        // While we're here, if we're in the add-on bar, we're interested in
+        // counting how many items (built-in AND add-on provided) are in the
+        // toolbar, not counting the addonbar-closebutton and status-bar. We
+        // ignore springs, spacers and separators though.
+        if (toolbarID == "addon-bar" &&
+            DEFAULT_TOOLBAR_SETS["addon-bar"].indexOf(item) == -1 &&
+            !isSpecialToolbarItem(item)) {
+          addonBarItems++;
+        }
+
         // else, it's a generated item (like springs, spacers, etc), or
         // provided by an add-on, and we won't record it.
       }
       // Finally, let's see if this is a custom toolbar.
       if (toolbar.hasAttribute("customindex")) {
         customToolbars++;
       }
     }
@@ -549,16 +560,17 @@ this.BrowserUITelemetry = {
     let addonToolbars = toolbars.length - DEFAULT_TOOLBARS.length - customToolbars;
 
     result.defaultKept = defaultKept;
     result.defaultMoved = defaultMoved;
     result.nondefaultAdded = nondefaultAdded;
     result.defaultRemoved = defaultRemoved;
     result.customToolbars = customToolbars;
     result.addonToolbars = addonToolbars;
+    result.addonBarItems = addonBarItems;
 
     result.smallIcons = win.gNavToolbox.getAttribute("iconsize") == "small";
     result.buttonMode = win.gNavToolbox.getAttribute("mode");
 
     // Find out how many open tabs we have in each window
     let winEnumerator = Services.wm.getEnumerator("navigator:browser");
     let visibleTabs = [];
     let hiddenTabs = [];
@@ -597,8 +609,20 @@ function getIDBasedOnFirstIDedAncestor(a
     }
     if (aNode.id && aNode.id == aLimitID) {
       break;
     }
   }
 
   return aNode.id + ":child";
 }
+
+/**
+ * Returns whether or not the toolbar item ID being passed in is one of
+ * our "special" items (spring, spacer, separator).
+ *
+ * @param aItemID the item ID to check.
+ */
+function isSpecialToolbarItem(aItemID) {
+  return aItemID == "spring" ||
+         aItemID == "spacer" ||
+         aItemID == "separator";
+}
\ No newline at end of file