Bug 944453 - Collect UITelemetry on if the menubar is displayed, and how many times menuitems are clicked. r=Gijs, a=bbajaj.
authorMike Conley <mconley@mozilla.com>
Wed, 22 Jan 2014 09:44:27 -0500
changeset 167972 f14cc0345552e00184193a9836e7a798efb3cd1c
parent 167971 840132b6f702ae359d954cbf6c0920e405de4825
child 167973 0045797de6160363502d54123a7f260bb9b982e5
push id428
push userbbajaj@mozilla.com
push dateTue, 28 Jan 2014 00:16:25 +0000
treeherdermozilla-release@cd72a7ff3a75 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersGijs, bbajaj
bugs944453
milestone27.0
Bug 944453 - Collect UITelemetry on if the menubar is displayed, and how many times menuitems are clicked. r=Gijs, a=bbajaj.
browser/modules/BrowserUITelemetry.jsm
--- a/browser/modules/BrowserUITelemetry.jsm
+++ b/browser/modules/BrowserUITelemetry.jsm
@@ -218,16 +218,17 @@ XPCOMUtils.defineLazyGetter(this, "ALL_B
                       .concat(SPECIAL_CASES);
 });
 
 const OTHER_MOUSEUP_MONITORED_ITEMS = [
    "appmenu-button",
    "PlacesChevron",
    "PlacesToolbarItems",
    "star-button",
+   "menubar-items",
 ];
 
 // Weakly maps browser windows to objects whose keys are relative
 // timestamps for when some kind of session started. For example,
 // when a customization session started. That way, when the window
 // exits customization mode, we can determine how long the session
 // lasted.
 const WINDOW_DURATION_MAP = new WeakMap();
@@ -391,16 +392,19 @@ this.BrowserUITelemetry = {
         this._PlacesToolbarItemsMouseUp(aEvent);
         break;
       case "PlacesChevron":
         this._PlacesChevronMouseUp(aEvent);
         break;
       case "star-button":
         this._starButtonMouseUp(aEvent);
         break;
+      case "menubar-items":
+        this._menubarMouseUp(aEvent);
+        break;
       default:
         this._checkForBuiltinItem(aEvent);
     }
   },
 
   _appmenuMouseUp: function(aEvent) {
     let itemId;
 
@@ -468,16 +472,23 @@ this.BrowserUITelemetry = {
   },
 
   _starButtonMouseUp: function(aEvent) {
     let starButton = aEvent.originalTarget;
     let action = starButton.hasAttribute("starred") ? "edit" : "add";
     this._countMouseUpEvent("click-star-button", action, aEvent.button);
   },
 
+  _menubarMouseUp: function(aEvent) {
+    let target = aEvent.originalTarget;
+    let tag = target.localName;
+    let result = (tag == "menu" || tag == "menuitem") ? tag : "other";
+    this._countMouseUpEvent("click-menubar", result, aEvent.button);
+  },
+
   countCustomizationEvent: function(aCustomizationEvent) {
     this._countEvent("customize", aCustomizationEvent);
   },
 
   startCustomizing: function(aWindow) {
     this.countCustomizationEvent("start");
     let durationMap = WINDOW_DURATION_MAP.get(aWindow);
     durationMap.customization = aWindow.performance.now();
@@ -507,16 +518,23 @@ this.BrowserUITelemetry = {
     // Determine if the add-on bar is currently visible
     let addonBar = document.getElementById("addon-bar");
     result.addonBarEnabled = addonBar && !addonBar.collapsed;
 
     // Determine if the Bookmarks bar is currently visible
     let bookmarksBar = document.getElementById("PersonalToolbar");
     result.bookmarksBarEnabled = bookmarksBar && !bookmarksBar.collapsed;
 
+    // Determine if the menubar is currently visible. On OS X, the menubar
+    // is never shown, despite not having the collapsed attribute set.
+    let menuBar = document.getElementById("toolbar-menubar");
+    result.menuBarEnabled =
+      menuBar && Services.appinfo.OS != "Darwin"
+              && menuBar.getAttribute("autohide") != "true";
+
     // 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;