Bug 949217 - Collect UITelemetry on how many extra toolbars there are. r=jaws, a=lsblakk.
authorMike Conley <mconley@mozilla.com>
Mon, 16 Dec 2013 14:14:22 -0500
changeset 174328 b20cdabdfb5b0004c80101f7732a935901c6f726
parent 174327 69a28e540c9bdf6b54bb6eb6e8a6a0bfc7053d81
child 174329 c48afe7549080e5df4997233c81b2a0674ef0a79
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
bugs949217
milestone28.0a2
Bug 949217 - Collect UITelemetry on how many extra toolbars there are. r=jaws, a=lsblakk.
browser/modules/BrowserUITelemetry.jsm
--- a/browser/modules/BrowserUITelemetry.jsm
+++ b/browser/modules/BrowserUITelemetry.jsm
@@ -134,21 +134,22 @@ const APPMENU_WHITELIST = [
 ];
 
 const APPMENU_PREFIX_WHITELIST = [
   'appmenu_developer_charset',
   'appmenu_charset',
 ];
 
 const DEFAULT_TOOLBAR_SETS = {
-#ifndef XP_MACOSX
+  // It's true that toolbar-menubar is not visible
+  // on OS X, but the XUL node is definitely present
+  // in the document.
   "toolbar-menubar": [
     "menubar-items"
   ],
-#endif
   "nav-bar": [
     "unified-back-forward-button",
     "urlbar-container",
     "reload-button",
     "stop-button",
     "search-container",
     "webrtc-status-button",
     "bookmarks-menu-button",
@@ -193,16 +194,20 @@ const PALETTE_ITEMS = [
 XPCOMUtils.defineLazyGetter(this, "DEFAULT_ITEMS", function() {
   let result = [];
   for (let [, buttons] of Iterator(DEFAULT_TOOLBAR_SETS)) {
     result = result.concat(buttons);
   }
   return result;
 });
 
+XPCOMUtils.defineLazyGetter(this, "DEFAULT_TOOLBARS", function() {
+  return Object.keys(DEFAULT_TOOLBAR_SETS);
+});
+
 XPCOMUtils.defineLazyGetter(this, "ALL_BUILTIN_ITEMS", function() {
   // We also want to detect clicks on individual parts of the URL bar container,
   // so we special-case them here.
   const SPECIAL_CASES = [
     "back-button",
     "forward-button",
     "urlbar-stop-button",
     "urlbar-go-button",
@@ -493,16 +498,17 @@ this.BrowserUITelemetry = {
     let bookmarksBar = document.getElementById("PersonalToolbar");
     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 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(",")) || [];
@@ -523,28 +529,36 @@ this.BrowserUITelemetry = {
           }
         } else if (PALETTE_ITEMS.indexOf(item) != -1) {
           // It's a palette item that's been moved into a toolbar
           nondefaultAdded.push(item);
         }
         // 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++;
+      }
     }
 
     // Now go through the items in the palette to see what default
     // items are in there.
     let paletteChildren = win.gNavToolbox.palette.childNodes;
     let defaultRemoved = [node.id for (node of paletteChildren)
                           if (DEFAULT_ITEMS.indexOf(node.id) != -1)];
 
+    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.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 = [];