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