Backed out changeset 502893089232 (bug 1475571) for browser_preferences_usage.js on a CLOSED TREE

This commit is contained in:
Tiberius Oros 2018-08-07 04:46:22 +03:00
parent c9a517ec96
commit a6e0ebd8ef
4 changed files with 16 additions and 73 deletions

View File

@ -6,6 +6,7 @@
DIRS += [
'aushelper',
'followonsearch',
'formautofill',
'onboarding',
'pdfjs',

View File

@ -13,13 +13,10 @@ var EXPORTED_SYMBOLS = [
];
ChromeUtils.import("resource://gre/modules/Services.jsm");
ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
ChromeUtils.defineModuleGetter(this, "PrivateBrowsingUtils",
"resource://gre/modules/PrivateBrowsingUtils.jsm");
XPCOMUtils.defineLazyGlobalGetters(this, ["URLSearchParams"]);
// The upper bound for the count of the visited unique domain names.
const MAX_UNIQUE_VISITED_DOMAINS = 100;
@ -91,6 +88,7 @@ const URLBAR_SELECTED_RESULT_METHODS = {
const MINIMUM_TAB_COUNT_INTERVAL_MS = 5 * 60 * 1000; // 5 minutes, in ms
function getOpenTabsAndWinsCounts() {
let tabCount = 0;
let winCount = 0;
@ -161,10 +159,6 @@ let URICountListener = {
return;
}
// Don't include URI and domain counts when in private mode.
let shouldCountURI = !PrivateBrowsingUtils.isWindowPrivate(browser.ownerGlobal) ||
Services.prefs.getBoolPref("browser.engagement.total_uri_count.pbm", false);
// Track URI loads, even if they're not http(s).
let uriSpec = null;
try {
@ -172,9 +166,7 @@ let URICountListener = {
} catch (e) {
// If we have troubles parsing the spec, still count this as
// an unfiltered URI.
if (shouldCountURI) {
Services.telemetry.scalarAdd(UNFILTERED_URI_COUNT_SCALAR_NAME, 1);
}
Services.telemetry.scalarAdd(UNFILTERED_URI_COUNT_SCALAR_NAME, 1);
return;
}
@ -196,42 +188,12 @@ let URICountListener = {
// The URI wasn't from a restored tab. Count it among the unfiltered URIs.
// If this is an http(s) URI, this also gets counted by the "total_uri_count"
// probe.
if (shouldCountURI) {
Services.telemetry.scalarAdd(UNFILTERED_URI_COUNT_SCALAR_NAME, 1);
}
Services.telemetry.scalarAdd(UNFILTERED_URI_COUNT_SCALAR_NAME, 1);
if (!this.isHttpURI(uri)) {
return;
}
let parseURLResult = Services.search.parseSubmissionURL(uriSpec);
if (parseURLResult.engine) {
this._recordSearchTelemetry(uriSpec, parseURLResult);
} else if (this._urlsQueuedForParsing) {
if (Services.search.isInitialized) {
this._urlsQueuedForParsing = null;
} else {
this._urlsQueuedForParsing.push(uriSpec);
if (this._urlsQueuedForParsing.length == 1) {
Services.search.init(rv => {
if (Components.isSuccessCode(rv)) {
for (let url of this._urlsQueuedForParsing) {
let innerParseURLResult = Services.search.parseSubmissionURL(url);
if (innerParseURLResult.engine) {
this._recordSearchTelemetry(url, innerParseURLResult);
}
}
}
this._urlsQueuedForParsing = null;
});
}
}
}
if (!shouldCountURI) {
return;
}
// Update the URI counts.
Services.telemetry.scalarAdd(TOTAL_URI_COUNT_SCALAR_NAME, 1);
@ -264,31 +226,6 @@ let URICountListener = {
this._domainSet.clear();
},
_urlsQueuedForParsing: [],
_recordSearchTelemetry(url, parseURLResult) {
switch (parseURLResult.engine.identifier) {
case "google":
case "google-2018":
let type;
let queries = new URLSearchParams(url.split("?")[1]);
let code = queries.get("client");
if (code) {
// Detecting follow-on searches for sap is a little tricky.
// There are a few parameters that only show up
// with follow-ons, so we look for those. (oq/ved/ei)
type = queries.has("oq") || queries.has("ved") || queries.has("ei") ? "sap-follow-on" : "sap";
} else {
type = "organic";
}
let payload = `google.in-content.${type}:${code || "none"}`;
let histogram = Services.telemetry.getKeyedHistogramById("SEARCH_COUNTS");
histogram.add(payload);
break;
}
},
QueryInterface: ChromeUtils.generateQI([Ci.nsIWebProgressListener,
Ci.nsISupportsWeakReference]),
};
@ -677,6 +614,11 @@ let BrowserUsageTelemetry = {
win.addEventListener("unload", this);
win.addEventListener("TabOpen", this, true);
// Don't include URI and domain counts when in private mode.
if (PrivateBrowsingUtils.isWindowPrivate(win) &&
!Services.prefs.getBoolPref("browser.engagement.total_uri_count.pbm", false)) {
return;
}
win.gBrowser.tabContainer.addEventListener(TAB_RESTORING_TOPIC, this);
win.gBrowser.addTabsProgressListener(URICountListener);
},
@ -688,6 +630,11 @@ let BrowserUsageTelemetry = {
win.removeEventListener("unload", this);
win.removeEventListener("TabOpen", this, true);
// Don't include URI and domain counts when in private mode.
if (PrivateBrowsingUtils.isWindowPrivate(win.defaultView) &&
!Services.prefs.getBoolPref("browser.engagement.total_uri_count.pbm", false)) {
return;
}
win.defaultView.gBrowser.tabContainer.removeEventListener(TAB_RESTORING_TOPIC, this);
win.defaultView.gBrowser.removeTabsProgressListener(URICountListener);
},

View File

@ -4331,12 +4331,7 @@ SearchService.prototype = {
},
parseSubmissionURL: function SRCH_SVC_parseSubmissionURL(aURL) {
if (!gInitialized) {
// If search is not initialized, do nothing.
// This allows us to use this function early in telemetry.
// The only other consumer of this (places) uses it much later.
return gEmptyParseSubmissionResult;
}
this._ensureInitialized();
LOG("parseSubmissionURL: Parsing \"" + aURL + "\".");
if (!this._parseSubmissionMap) {

View File

@ -7827,7 +7827,7 @@
"kind": "count",
"keyed": true,
"releaseChannelCollection": "opt-out",
"description": "Records search counts for search access points and in content searches. For search access points, the format is: <engine-name>.<search-access-point> For in content searches, the format is <provider>.in-content:[sap|sap-follow-on|organic]:[code|none]"
"description": "Record the search counts for search engines"
},
"SEARCH_RESET_RESULT": {
"record_in_processes": ["main", "content"],