mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 725407 - create opt-out Telemetry notification for Nightly and Aurora; r=gavin
--HG-- extra : rebase_source : c350a62b4e6db5ae942200822b6217a7d5c3d898
This commit is contained in:
parent
85d80030c2
commit
0126ede99d
@ -1,3 +1,4 @@
|
|||||||
|
# -*- indent-tabs-mode: nil -*-
|
||||||
# ***** BEGIN LICENSE BLOCK *****
|
# ***** BEGIN LICENSE BLOCK *****
|
||||||
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||||
#
|
#
|
||||||
@ -774,18 +775,71 @@ BrowserGlue.prototype = {
|
|||||||
const PREF_TELEMETRY_REJECTED = "toolkit.telemetry.rejected";
|
const PREF_TELEMETRY_REJECTED = "toolkit.telemetry.rejected";
|
||||||
const PREF_TELEMETRY_INFOURL = "toolkit.telemetry.infoURL";
|
const PREF_TELEMETRY_INFOURL = "toolkit.telemetry.infoURL";
|
||||||
const PREF_TELEMETRY_SERVER_OWNER = "toolkit.telemetry.server_owner";
|
const PREF_TELEMETRY_SERVER_OWNER = "toolkit.telemetry.server_owner";
|
||||||
|
const PREF_TELEMETRY_ENABLED_BY_DEFAULT = "toolkit.telemetry.enabledByDefault";
|
||||||
|
const PREF_TELEMETRY_NOTIFIED_OPTOUT = "toolkit.telemetry.notifiedOptOut";
|
||||||
// This is used to reprompt users when privacy message changes
|
// This is used to reprompt users when privacy message changes
|
||||||
const TELEMETRY_PROMPT_REV = 2;
|
const TELEMETRY_PROMPT_REV = 2;
|
||||||
|
|
||||||
function appendTelemetryNotification(notifyBox, message, buttons, hideclose) {
|
// Stick notifications onto the selected tab of the active browser window.
|
||||||
|
var win = this.getMostRecentBrowserWindow();
|
||||||
|
var tabbrowser = win.gBrowser;
|
||||||
|
var notifyBox = tabbrowser.getNotificationBox();
|
||||||
|
|
||||||
|
var browserBundle = Services.strings.createBundle("chrome://browser/locale/browser.properties");
|
||||||
|
var brandBundle = Services.strings.createBundle("chrome://branding/locale/brand.properties");
|
||||||
|
var productName = brandBundle.GetStringFromName("brandFullName");
|
||||||
|
var serverOwner = Services.prefs.getCharPref(PREF_TELEMETRY_SERVER_OWNER);
|
||||||
|
|
||||||
|
function appendTelemetryNotification(message, buttons, hideclose) {
|
||||||
let notification = notifyBox.appendNotification(message, "telemetry", null,
|
let notification = notifyBox.appendNotification(message, "telemetry", null,
|
||||||
notifyBox.PRIORITY_INFO_LOW,
|
notifyBox.PRIORITY_INFO_LOW,
|
||||||
buttons);
|
buttons);
|
||||||
|
if (hideclose)
|
||||||
notification.setAttribute("hideclose", hideclose);
|
notification.setAttribute("hideclose", hideclose);
|
||||||
notification.persistence = -1; // Until user closes it
|
notification.persistence = -1; // Until user closes it
|
||||||
return notification;
|
return notification;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function appendLearnMoreLink(notification) {
|
||||||
|
let XULNS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
|
||||||
|
let link = notification.ownerDocument.createElementNS(XULNS, "label");
|
||||||
|
link.className = "text-link telemetry-text-link";
|
||||||
|
link.setAttribute("value", browserBundle.GetStringFromName("telemetryLinkLabel"));
|
||||||
|
let description = notification.ownerDocument.getAnonymousElementByAttribute(notification, "anonid", "messageText");
|
||||||
|
description.appendChild(link);
|
||||||
|
return link;
|
||||||
|
}
|
||||||
|
|
||||||
|
var telemetryEnabledByDefault = false;
|
||||||
|
try {
|
||||||
|
telemetryEnabledByDefault = Services.prefs.getBoolPref(PREF_TELEMETRY_ENABLED_BY_DEFAULT);
|
||||||
|
} catch(e) {}
|
||||||
|
if (telemetryEnabledByDefault) {
|
||||||
|
var telemetryNotifiedOptOut = false;
|
||||||
|
try {
|
||||||
|
telemetryNotifiedOptOut = Services.prefs.getBoolPref(PREF_TELEMETRY_NOTIFIED_OPTOUT);
|
||||||
|
} catch(e) {}
|
||||||
|
if (telemetryNotifiedOptOut)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var telemetryPrompt = browserBundle.formatStringFromName("telemetryOptOutPrompt",
|
||||||
|
[productName, serverOwner, productName], 3);
|
||||||
|
|
||||||
|
Services.prefs.setBoolPref(PREF_TELEMETRY_NOTIFIED_OPTOUT, true);
|
||||||
|
|
||||||
|
let notification = appendTelemetryNotification(telemetryPrompt, null, false);
|
||||||
|
let link = appendLearnMoreLink(notification);
|
||||||
|
link.addEventListener('click', function() {
|
||||||
|
// Open the learn more url in a new tab
|
||||||
|
let url = Services.urlFormatter.formatURLPref("app.support.baseURL");
|
||||||
|
url += "how-can-i-help-submitting-performance-data";
|
||||||
|
tabbrowser.selectedTab = tabbrowser.addTab(url);
|
||||||
|
// Remove the notification on which the user clicked
|
||||||
|
notification.parentNode.removeNotification(notification, true);
|
||||||
|
}, false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var telemetryPrompted = null;
|
var telemetryPrompted = null;
|
||||||
try {
|
try {
|
||||||
telemetryPrompted = Services.prefs.getIntPref(PREF_TELEMETRY_PROMPTED);
|
telemetryPrompted = Services.prefs.getIntPref(PREF_TELEMETRY_PROMPTED);
|
||||||
@ -798,16 +852,6 @@ BrowserGlue.prototype = {
|
|||||||
Services.prefs.clearUserPref(PREF_TELEMETRY_PROMPTED);
|
Services.prefs.clearUserPref(PREF_TELEMETRY_PROMPTED);
|
||||||
Services.prefs.clearUserPref(PREF_TELEMETRY_ENABLED);
|
Services.prefs.clearUserPref(PREF_TELEMETRY_ENABLED);
|
||||||
|
|
||||||
// Stick the notification onto the selected tab of the active browser window.
|
|
||||||
var win = this.getMostRecentBrowserWindow();
|
|
||||||
var browser = win.gBrowser; // for closure in notification bar callback
|
|
||||||
var notifyBox = browser.getNotificationBox();
|
|
||||||
|
|
||||||
var browserBundle = Services.strings.createBundle("chrome://browser/locale/browser.properties");
|
|
||||||
var brandBundle = Services.strings.createBundle("chrome://branding/locale/brand.properties");
|
|
||||||
|
|
||||||
var productName = brandBundle.GetStringFromName("brandFullName");
|
|
||||||
var serverOwner = Services.prefs.getCharPref(PREF_TELEMETRY_SERVER_OWNER);
|
|
||||||
var telemetryPrompt = browserBundle.formatStringFromName("telemetryPrompt", [productName, serverOwner], 2);
|
var telemetryPrompt = browserBundle.formatStringFromName("telemetryPrompt", [productName, serverOwner], 2);
|
||||||
|
|
||||||
var buttons = [
|
var buttons = [
|
||||||
@ -832,23 +876,17 @@ BrowserGlue.prototype = {
|
|||||||
// Set pref to indicate we've shown the notification.
|
// Set pref to indicate we've shown the notification.
|
||||||
Services.prefs.setIntPref(PREF_TELEMETRY_PROMPTED, TELEMETRY_PROMPT_REV);
|
Services.prefs.setIntPref(PREF_TELEMETRY_PROMPTED, TELEMETRY_PROMPT_REV);
|
||||||
|
|
||||||
let notification = appendTelemetryNotification(notifyBox, telemetryPrompt,
|
let notification = appendTelemetryNotification(telemetryPrompt, buttons, true);
|
||||||
buttons, true);
|
let link = appendLearnMoreLink(notification);
|
||||||
let XULNS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
|
|
||||||
let link = notification.ownerDocument.createElementNS(XULNS, "label");
|
|
||||||
link.className = "text-link telemetry-text-link";
|
|
||||||
link.setAttribute("value", browserBundle.GetStringFromName("telemetryLinkLabel"));
|
|
||||||
link.addEventListener('click', function() {
|
link.addEventListener('click', function() {
|
||||||
// Open the learn more url in a new tab
|
// Open the learn more url in a new tab
|
||||||
browser.selectedTab = browser.addTab(Services.prefs.getCharPref(PREF_TELEMETRY_INFOURL));
|
tabbrowser.selectedTab = tabbrowser.addTab(Services.prefs.getCharPref(PREF_TELEMETRY_INFOURL));
|
||||||
// Remove the notification on which the user clicked
|
// Remove the notification on which the user clicked
|
||||||
notification.parentNode.removeNotification(notification, true);
|
notification.parentNode.removeNotification(notification, true);
|
||||||
// Add a new notification to that tab, with no "Learn more" link
|
// Add a new notification to that tab, with no "Learn more" link
|
||||||
notifyBox = browser.getNotificationBox();
|
notifyBox = tabbrowser.getNotificationBox();
|
||||||
appendTelemetryNotification(notifyBox, telemetryPrompt, buttons, true);
|
appendTelemetryNotification(telemetryPrompt, buttons, true);
|
||||||
}, false);
|
}, false);
|
||||||
let description = notification.ownerDocument.getAnonymousElementByAttribute(notification, "anonid", "messageText");
|
|
||||||
description.appendChild(link);
|
|
||||||
},
|
},
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -333,3 +333,7 @@ telemetryYesButtonLabel2 = Yes, I want to help
|
|||||||
telemetryYesButtonAccessKey = Y
|
telemetryYesButtonAccessKey = Y
|
||||||
telemetryNoButtonLabel = No
|
telemetryNoButtonLabel = No
|
||||||
telemetryNoButtonAccessKey = N
|
telemetryNoButtonAccessKey = N
|
||||||
|
# Telemetry opt-out prompt for Aurora and Nightly
|
||||||
|
# LOCALIZATION NOTE (telemetryOptOutPrompt): %1$S and %3$S will be replaced by
|
||||||
|
# brandFullName, and %2$S by the value of the toolkit.telemetry.server_owner preference.
|
||||||
|
telemetryOptOutPrompt = %1$S sends information about performance, hardware, usage and customizations back to %2$S to help improve %3$S.
|
||||||
|
Loading…
Reference in New Issue
Block a user