Backed out 3 changesets (bug 1039069) for ESlint failures on browser/components/preferences/languages.js r=backout on a CLOSED TREE

Backed out changeset 036a91aed264 (bug 1039069)
Backed out changeset 69af55073d39 (bug 1039069)
Backed out changeset 4fce39a14630 (bug 1039069)
This commit is contained in:
Narcis Beleuzu 2017-11-30 23:38:27 +02:00
Родитель 675847149d
Коммит b5d0f0fad6
10 изменённых файлов: 3 добавлений и 278 удалений

Просмотреть файл

@ -582,12 +582,6 @@ pref("privacy.panicButton.enabled", true);
// Time until temporary permissions expire, in ms
pref("privacy.temporary_permission_expire_time_ms", 3600000);
// If Accept-Language should be spoofed by en-US
// 0 - will prompt
// 1 - don't spoof
// 2 - spoof
pref("privacy.spoof_english", 0);
pref("network.proxy.share_proxy_settings", false); // use the same proxy settings for all protocols
// simple gestures support

Просмотреть файл

@ -34,7 +34,6 @@ XPCOMUtils.defineLazyModuleGetters(this, {
E10SUtils: "resource:///modules/E10SUtils.jsm",
ExtensionsUI: "resource:///modules/ExtensionsUI.jsm",
FormValidationHandler: "resource:///modules/FormValidationHandler.jsm",
LanguagePrompt: "resource://gre/modules/LanguagePrompt.jsm",
LightweightThemeManager: "resource://gre/modules/LightweightThemeManager.jsm",
Log: "resource://gre/modules/Log.jsm",
LoginManagerParent: "resource://gre/modules/LoginManagerParent.jsm",
@ -1822,8 +1821,6 @@ var gBrowserInit = {
gAccessibilityServiceIndicator.uninit();
LanguagePrompt.uninit();
// Now either cancel delayedStartup, or clean up the services initialized from
// it.
if (this._boundDelayedStartup) {

Просмотреть файл

@ -41,7 +41,6 @@ XPCOMUtils.defineLazyModuleGetters(this, {
FormValidationHandler: "resource:///modules/FormValidationHandler.jsm",
Integration: "resource://gre/modules/Integration.jsm",
L10nRegistry: "resource://gre/modules/L10nRegistry.jsm",
LanguagePrompt: "resource://gre/modules/LanguagePrompt.jsm",
LightweightThemeManager: "resource://gre/modules/LightweightThemeManager.jsm",
LoginHelper: "resource://gre/modules/LoginHelper.jsm",
LoginManagerParent: "resource://gre/modules/LoginManagerParent.jsm",
@ -1167,10 +1166,6 @@ BrowserGlue.prototype = {
JawsScreenReaderVersionCheck.onWindowsRestored();
});
}
Services.tm.idleDispatchToMainThread(() => {
LanguagePrompt.init();
});
},
/**

Просмотреть файл

@ -149,10 +149,6 @@ var gLanguagesDialog = {
this._activeLanguages.selectedIndex = selectedIndex;
}
// Update states of accept-language list and buttons according to
// privacy.resistFingerprinting and privacy.spoof_english.
this.readSpoofEnglish();
return undefined;
},
@ -161,10 +157,8 @@ var gLanguagesDialog = {
},
onAvailableLanguageSelect() {
var availableLanguages = this._availableLanguages;
var addButton = document.getElementById("addButton");
addButton.disabled = availableLanguages.disabled ||
availableLanguages.selectedIndex < 0;
addButton.disabled = false;
this._availableLanguages.removeAttribute("accesskey");
},
@ -297,40 +291,6 @@ var gLanguagesDialog = {
downButton.disabled = true;
removeButton.disabled = false;
}
},
readSpoofEnglish() {
var checkbox = document.getElementById("spoofEnglish");
var resistFingerprinting = Services.prefs.getBoolPref("privacy.resistFingerprinting");
if (!resistFingerprinting) {
checkbox.hidden = true;
return false;
}
var spoofEnglish = document.getElementById("privacy.spoof_english").value;
var activeLanguages = this._activeLanguages;
var availableLanguages = this._availableLanguages;
checkbox.hidden = false;
switch (spoofEnglish) {
case 1: // don't spoof intl.accept_lanauges
activeLanguages.disabled = false;
activeLanguages.selectItem(activeLanguages.firstChild);
availableLanguages.disabled = false;
this.onAvailableLanguageSelect();
return false;
case 2: // spoof intl.accept_lanauges
activeLanguages.clearSelection();
activeLanguages.disabled = true;
availableLanguages.disabled = true;
this.onAvailableLanguageSelect();
return true;
default: // will prompt for spoofing intl.accept_lanauges if resisting fingerprinting
return false;
}
},
writeSpoofEnglish() {
return document.getElementById("spoofEnglish").checked ? 2 : 1;
}
};

Просмотреть файл

@ -40,9 +40,6 @@
<preference id="pref.browser.language.disable_button.remove"
name="pref.browser.language.disable_button.remove"
type="bool"/>
<preference id="privacy.spoof_english"
name="privacy.spoof_english"
type="int"/>
</preferences>
<script type="application/javascript" src="chrome://browser/content/preferences/languages.js"/>
@ -55,11 +52,6 @@
</stringbundleset>
<description>&languages.customize2.description;</description>
<checkbox id="spoofEnglish"
label="&languages.customize.spoofEnglish;"
preference="privacy.spoof_english"
onsyncfrompreference="return gLanguagesDialog.readSpoofEnglish();"
onsynctopreference="return gLanguagesDialog.writeSpoofEnglish();"/>
<grid flex="1">
<columns>
<column flex="1"/>

Просмотреть файл

@ -497,9 +497,6 @@ canvas.allow=Allow Data Access
canvas.allow.accesskey=A
canvas.remember=Always remember my decision
# Spoof Accept-Language prompt
privacy.spoof_english=Changing your language setting to English will make you more difficult to identify and enhance your privacy. Do you want to request English language versions of web pages?
identity.identified.verifier=Verified by: %S
identity.identified.verified_by_you=You have added a security exception for this site.
identity.identified.state_and_country=%S, %S

Просмотреть файл

@ -15,4 +15,4 @@
<!ENTITY languages.customize.selectLanguage.label "Select a language to add…">
<!ENTITY languages.customize.addButton.label "Add">
<!ENTITY languages.customize.addButton.accesskey "A">
<!ENTITY languages.customize.spoofEnglish "Request English versions of web pages for enhanced privacy">

Просмотреть файл

@ -1,201 +0,0 @@
// -*- indent-tabs-mode: nil; js-indent-level: 2 -*-
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
this.EXPORTED_SYMBOLS = ["LanguagePrompt"];
const {classes: Cc, interfaces: Ci, utils: Cu} = Components;
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
const kPrefResistFingerprinting = "privacy.resistFingerprinting";
const kPrefSpoofEnglish = "privacy.spoof_english";
const kTopicHttpOnModifyRequest = "http-on-modify-request";
class _LanguagePrompt {
constructor() {
this._initialized = false;
}
init() {
if (this._initialized) {
return;
}
this._initialized = true;
Services.prefs.addObserver(kPrefResistFingerprinting, this);
this._handleResistFingerprintingChanged();
}
uninit() {
if (!this._initialized) {
return;
}
this._initialized = false;
Services.prefs.removeObserver(kPrefResistFingerprinting, this);
this._removeObservers();
}
observe(subject, topic, data) {
switch (topic) {
case "nsPref:changed":
return this._handlePrefChanged(data);
case kTopicHttpOnModifyRequest:
return this._handleHttpOnModifyRequest(subject, data);
default:
break;
}
}
_removeObservers() {
try {
Services.pref.removeObserver(kPrefSpoofEnglish, this);
} catch (e) {
// do nothing
}
try {
Services.obs.removeObserver(this, kTopicHttpOnModifyRequest);
} catch (e) {
// do nothing
}
}
_shouldPromptForLanguagePref() {
return (Services.locale.getAppLocaleAsLangTag().substr(0, 2) !== "en")
&& (Services.prefs.getIntPref(kPrefSpoofEnglish) === 0);
}
_handlePrefChanged(data) {
switch (data) {
case kPrefResistFingerprinting:
return this._handleResistFingerprintingChanged();
case kPrefSpoofEnglish:
return this._handleSpoofEnglishChanged();
default:
break;
}
}
_handleResistFingerprintingChanged() {
if (Services.prefs.getBoolPref(kPrefResistFingerprinting)) {
Services.prefs.addObserver(kPrefSpoofEnglish, this);
if (this._shouldPromptForLanguagePref()) {
Services.obs.addObserver(this, kTopicHttpOnModifyRequest);
}
} else {
this._removeObservers();
Services.prefs.setIntPref(kPrefSpoofEnglish, 0);
}
}
_handleSpoofEnglishChanged() {
switch (Services.prefs.getIntPref(kPrefSpoofEnglish)) {
case 0: // will prompt
// This should only happen when turning privacy.resistFingerprinting off.
// Works like disabling accept-language spoofing.
case 1: // don't spoof
if (Services.prefs.prefHasUserValue("javascript.use_us_english_locale")) {
Services.prefs.clearUserPref("javascript.use_us_english_locale");
}
// We don't reset intl.accept_languages. Instead, setting
// privacy.spoof_english to 1 allows user to change preferred language
// settings through Preferences UI.
break;
case 2: // spoof
Services.prefs.setCharPref("intl.accept_languages", "en-US, en");
Services.prefs.setBoolPref("javascript.use_us_english_locale", true);
break;
default:
break;
}
}
_handleHttpOnModifyRequest(subject, data) {
// If we are loading an HTTP page from content, show the
// "request English language web pages?" prompt.
let httpChannel;
try {
httpChannel = subject.QueryInterface(Ci.nsIHttpChannel);
} catch (e) {
return;
}
if (!httpChannel) {
return;
}
let notificationCallbacks = httpChannel.notificationCallbacks;
if (!notificationCallbacks) {
return;
}
let loadContext = notificationCallbacks.getInterface(Ci.nsILoadContext);
if (!loadContext || !loadContext.isContent) {
return;
}
if (!subject.URI.schemeIs("http") && !subject.URI.schemeIs("https")) {
return;
}
// The above QI did not throw, the scheme is http[s], and we know the
// load context is content, so we must have a true HTTP request from content.
// Stop the observer and display the prompt if another window has
// not already done so.
Services.obs.removeObserver(this, kTopicHttpOnModifyRequest);
if (!this._shouldPromptForLanguagePref()) {
return;
}
this._promptForLanguagePreference();
// The Accept-Language header for this request was set when the
// channel was created. Reset it to match the value that will be
// used for future requests.
let val = this._getCurrentAcceptLanguageValue(subject.URI);
if (val) {
httpChannel.setRequestHeader("Accept-Language", val, false);
}
}
_promptForLanguagePreference() {
// Display two buttons, both with string titles.
let flags = Services.prompt.STD_YES_NO_BUTTONS;
let brandBundle = Services.strings.createBundle(
"chrome://branding/locale/brand.properties");
let brandShortName = brandBundle.GetStringFromName("brandShortName");
let navigatorBundle = Services.strings.createBundle(
"chrome://browser/locale/browser.properties");
let message = navigatorBundle.formatStringFromName(
"privacy.spoof_english", [brandShortName], 1);
let response = Services.prompt.confirmEx(
null, "", message, flags, null, null, null, null, {value: false});
// Update preferences to reflect their response and to prevent the prompt
// from being displayed again.
Services.prefs.setIntPref(kPrefSpoofEnglish, (response == 0) ? 2 : 1);
}
_getCurrentAcceptLanguageValue(uri) {
let channel = Services.io.newChannelFromURI2(
uri,
null, // aLoadingNode
Services.scriptSecurityManager.getSystemPrincipal(),
null, // aTriggeringPrincipal
Ci.nsILoadInfo.SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL,
Ci.nsIContentPolicy.TYPE_OTHER);
let httpChannel;
try {
httpChannel = channel.QueryInterface(Ci.nsIHttpChannel);
} catch (e) {
return null;
}
return httpChannel.getRequestHeader("Accept-Language");
}
}
let LanguagePrompt = new _LanguagePrompt();

Просмотреть файл

@ -13,7 +13,3 @@ FINAL_LIBRARY = 'xul'
EXPORTS += [
'nsRFPService.h',
]
EXTRA_JS_MODULES += [
'LanguagePrompt.jsm',
]

Просмотреть файл

@ -239,15 +239,10 @@ html|button:disabled,
html|select:disabled,
xul|button[disabled="true"],
xul|colorpicker[type="button"][disabled="true"],
xul|menulist[disabled="true"],
xul|listbox[disabled="true"] {
xul|menulist[disabled="true"] {
opacity: 0.5;
}
xul|listbox[disabled="true"] xul|listitem:hover {
background-color: transparent;
}
*|button.primary {
background-color: var(--in-content-primary-button-background);
border-color: transparent;