зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1102937 - Add UITelemetry for the improved search bar UI. r=florian, r=felipe
This commit is contained in:
Родитель
fec5f30c06
Коммит
fe9799f4da
|
@ -3568,6 +3568,11 @@ const BrowserSearch = {
|
|||
let count = Services.telemetry.getKeyedHistogramById("SEARCH_COUNTS");
|
||||
count.add(countId);
|
||||
},
|
||||
|
||||
recordOneoffSearchInTelemetry: function (engine, source, type, where) {
|
||||
let id = this._getSearchEngineId(engine) + "." + source;
|
||||
BrowserUITelemetry.countOneoffSearchEvent(id, type, where);
|
||||
}
|
||||
};
|
||||
|
||||
const SearchHighlight = {
|
||||
|
|
|
@ -923,6 +923,12 @@
|
|||
var controller = this.view.QueryInterface(Components.interfaces.nsIAutoCompleteController);
|
||||
|
||||
// Check for unmodified left-click, and use default behavior
|
||||
var searchBar = BrowserSearch.searchBar;
|
||||
searchBar.telemetrySearchDetails = {
|
||||
index: controller.selection.currentIndex,
|
||||
kind: "mouse"
|
||||
};
|
||||
|
||||
if (aEvent.button == 0 && !aEvent.shiftKey && !aEvent.ctrlKey &&
|
||||
!aEvent.altKey && !aEvent.metaKey) {
|
||||
controller.handleEnter(true);
|
||||
|
@ -930,7 +936,6 @@
|
|||
}
|
||||
|
||||
// Check for middle-click or modified clicks on the search bar
|
||||
var searchBar = BrowserSearch.searchBar;
|
||||
if (searchBar && searchBar.textbox == this.mInput) {
|
||||
// Handle search bar popup clicks
|
||||
var search = controller.getValueAt(this.selectedIndex);
|
||||
|
@ -996,7 +1001,7 @@
|
|||
<xul:vbox anonid="add-engines"/>
|
||||
<xul:button anonid="search-settings"
|
||||
xbl:inherits="showonlysettings"
|
||||
oncommand="openPreferences('paneSearch')"
|
||||
oncommand="BrowserUITelemetry.countSearchSettingsEvent('searchbar');openPreferences('paneSearch')"
|
||||
class="search-setting-button search-panel-header"
|
||||
label="&changeSearchSettings.button;"/>
|
||||
</content>
|
||||
|
|
|
@ -501,7 +501,31 @@
|
|||
where = "tab-background";
|
||||
}
|
||||
|
||||
let selection = this.telemetrySearchDetails;
|
||||
this.doSearch(textValue, where, aEngine);
|
||||
|
||||
if (!selection || (selection.index == -1)) {
|
||||
let target = aEvent.originalTarget;
|
||||
let source = "unknown";
|
||||
let type = "unknown";
|
||||
if (aEvent instanceof KeyboardEvent) {
|
||||
type = "key";
|
||||
if (this._textbox.getSelectedOneOff()) {
|
||||
source = "oneoff";
|
||||
}
|
||||
} else if (aEvent instanceof MouseEvent) {
|
||||
type = "mouse";
|
||||
if (target.classList.contains("searchbar-engine-one-off-item")) {
|
||||
source = "oneoff";
|
||||
} else if (target.classList.contains("search-panel-header") ||
|
||||
target.parentNode.classList.contains("search-panel-header")) {
|
||||
source = "header";
|
||||
}
|
||||
}
|
||||
|
||||
BrowserSearch.recordOneoffSearchInTelemetry(aEngine, source, type, where);
|
||||
}
|
||||
|
||||
if (where == "tab-background")
|
||||
this.focus();
|
||||
]]></body>
|
||||
|
@ -513,7 +537,7 @@
|
|||
<parameter name="aEngine"/>
|
||||
<body><![CDATA[
|
||||
var textBox = this._textbox;
|
||||
|
||||
|
||||
// Save the current value in the form history
|
||||
if (aData && !PrivateBrowsingUtils.isWindowPrivate(window)) {
|
||||
this.FormHistory.update(
|
||||
|
@ -527,7 +551,12 @@
|
|||
|
||||
let engine = aEngine || this.currentEngine;
|
||||
var submission = engine.getSubmission(aData, null, "searchbar");
|
||||
BrowserSearch.recordSearchInHealthReport(engine, "searchbar");
|
||||
let telemetrySearchDetails = this.telemetrySearchDetails;
|
||||
this.telemetrySearchDetails = null;
|
||||
if (telemetrySearchDetails && telemetrySearchDetails.index == -1) {
|
||||
telemetrySearchDetails = null;
|
||||
}
|
||||
BrowserSearch.recordSearchInHealthReport(engine, "searchbar", telemetrySearchDetails);
|
||||
// null parameter below specifies HTML response for search
|
||||
let params = {
|
||||
postData: submission.postData,
|
||||
|
@ -942,6 +971,11 @@
|
|||
let oneOff = this.getSelectedOneOff();
|
||||
if (oneOff)
|
||||
engine = oneOff.engine;
|
||||
if (this.mEnterEvent && this._selectionDetails &&
|
||||
this._selectionDetails.currentIndex != -1) {
|
||||
BrowserSearch.searchBar.telemetrySearchDetails = this._selectionDetails;
|
||||
this._selectionDetails = null;
|
||||
}
|
||||
document.getBindingParent(this).handleSearchCommand(evt, engine);
|
||||
|
||||
this.mEnterEvent = null;
|
||||
|
|
|
@ -285,9 +285,11 @@ this.BrowserUITelemetry = {
|
|||
allowPopups: false,
|
||||
});
|
||||
|
||||
// If there are no such windows, we're out of luck. :(
|
||||
this._firstWindowMeasurements = win ? this._getWindowMeasurements(win)
|
||||
: {};
|
||||
Services.search.init(rv => {
|
||||
// If there are no such windows, we're out of luck. :(
|
||||
this._firstWindowMeasurements = win ? this._getWindowMeasurements(win, rv)
|
||||
: {};
|
||||
});
|
||||
},
|
||||
|
||||
_registerWindow: function(aWindow) {
|
||||
|
@ -464,7 +466,7 @@ this.BrowserUITelemetry = {
|
|||
}
|
||||
},
|
||||
|
||||
_getWindowMeasurements: function(aWindow) {
|
||||
_getWindowMeasurements: function(aWindow, searchResult) {
|
||||
let document = aWindow.document;
|
||||
let result = {};
|
||||
|
||||
|
@ -553,6 +555,10 @@ this.BrowserUITelemetry = {
|
|||
result.visibleTabs = visibleTabs;
|
||||
result.hiddenTabs = hiddenTabs;
|
||||
|
||||
if (Components.isSuccessCode(searchResult)) {
|
||||
result.currentSearchEngine = Services.search.currentEngine;
|
||||
}
|
||||
|
||||
return result;
|
||||
},
|
||||
|
||||
|
@ -577,6 +583,14 @@ this.BrowserUITelemetry = {
|
|||
}
|
||||
},
|
||||
|
||||
countOneoffSearchEvent: function(id, type, where) {
|
||||
this._countEvent(["search-oneoff", id, type, where]);
|
||||
},
|
||||
|
||||
countSearchSettingsEvent: function(source) {
|
||||
this._countEvent(["click-builtin-item", source, "search-settings"]);
|
||||
},
|
||||
|
||||
_logAwesomeBarSearchResult: function (url) {
|
||||
let spec = Services.search.parseSubmissionURL(url);
|
||||
if (spec.engine) {
|
||||
|
|
|
@ -422,6 +422,7 @@
|
|||
|
||||
<!-- ::::::::::::: key handling ::::::::::::: -->
|
||||
|
||||
<field name="_selectionDetails">null</field>
|
||||
<method name="onKeyPress">
|
||||
<parameter name="aEvent"/>
|
||||
<body><![CDATA[
|
||||
|
@ -485,6 +486,12 @@
|
|||
aEvent.preventDefault();
|
||||
#endif
|
||||
this.mEnterEvent = aEvent;
|
||||
if (this.mController.selection) {
|
||||
this._selectionDetails = {
|
||||
index: this.mController.selection.currentIndex,
|
||||
kind: "key"
|
||||
};
|
||||
}
|
||||
cancel = this.mController.handleEnter(false);
|
||||
break;
|
||||
case KeyEvent.DOM_VK_DELETE:
|
||||
|
|
Загрузка…
Ссылка в новой задаче