Bug 961034 - [Australis] Collect UITelemetry on how many times the Australis menu button is clicked. r=Gijs.

This commit is contained in:
Mike Conley 2014-01-20 16:33:21 -05:00
Родитель 8d3046b734
Коммит ab696390c1
1 изменённых файлов: 34 добавлений и 0 удалений

Просмотреть файл

@ -135,6 +135,13 @@ const OTHER_MOUSEUP_MONITORED_ITEMS = [
"menubar-items",
];
// Items that open arrow panels will often be overlapped by
// the panel that they're opening by the time the mouseup
// event is fired, so for these items, we monitor mousedown.
const MOUSEDOWN_MONITORED_ITEMS = [
"PanelUI-menu-button",
];
// 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
@ -261,6 +268,13 @@ this.BrowserUITelemetry = {
}
}
for (let itemID of MOUSEDOWN_MONITORED_ITEMS) {
let item = document.getElementById(itemID);
if (item) {
item.addEventListener("mousedown", this);
}
}
WINDOW_DURATION_MAP.set(aWindow, {});
},
@ -281,6 +295,13 @@ this.BrowserUITelemetry = {
item.removeEventListener("mouseup", this);
}
}
for (let itemID of MOUSEDOWN_MONITORED_ITEMS) {
let item = document.getElementById(itemID);
if (item) {
item.removeEventListener("mousedown", this);
}
}
},
handleEvent: function(aEvent) {
@ -291,6 +312,9 @@ this.BrowserUITelemetry = {
case "mouseup":
this._handleMouseUp(aEvent);
break;
case "mousedown":
this._handleMouseDown(aEvent);
break;
}
},
@ -312,6 +336,16 @@ this.BrowserUITelemetry = {
}
},
_handleMouseDown: function(aEvent) {
if (aEvent.currentTarget.id == "PanelUI-menu-button") {
// _countMouseUpEvent expects a detail for the second argument,
// but we don't really have any details to give. Just passing in
// "button" is probably simpler than trying to modify
// _countMouseUpEvent for this particular case.
this._countMouseUpEvent("click-menu-button", "button", aEvent.button);
}
},
_PlacesChevronMouseUp: function(aEvent) {
let target = aEvent.originalTarget;
let result = target.id == "PlacesChevron" ? "chevron" : "overflowed-item";