diff --git a/browser/base/content/browser.js b/browser/base/content/browser.js index 984f3faaa237..3a6e8dea2288 100644 --- a/browser/base/content/browser.js +++ b/browser/base/content/browser.js @@ -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 = { diff --git a/browser/base/content/urlbarBindings.xml b/browser/base/content/urlbarBindings.xml index 1c43aa9dd2df..04cd1e20e043 100644 --- a/browser/base/content/urlbarBindings.xml +++ b/browser/base/content/urlbarBindings.xml @@ -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 @@ diff --git a/browser/components/search/content/search.xml b/browser/components/search/content/search.xml index aec20bca1234..207487b5e57f 100644 --- a/browser/components/search/content/search.xml +++ b/browser/components/search/content/search.xml @@ -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(); ]]> @@ -513,7 +537,7 @@ { + // 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) { diff --git a/toolkit/content/widgets/autocomplete.xml b/toolkit/content/widgets/autocomplete.xml index f2fdd1dbfe6e..3757738eba0d 100644 --- a/toolkit/content/widgets/autocomplete.xml +++ b/toolkit/content/widgets/autocomplete.xml @@ -422,6 +422,7 @@ + null