Bug 1457021 - Migrate the JS of Preferences::Blocklists to Fluent. r=flod,Gijs

MozReview-Commit-ID: DlcJNPukzHW

--HG--
extra : rebase_source : cf5385f90381a66408b18ac046eebf2d678a8c18
This commit is contained in:
Zibi Braniecki 2018-04-19 16:59:44 -07:00
Родитель 79bc45e84a
Коммит a0b03ccae1
5 изменённых файлов: 33 добавлений и 49 удалений

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

@ -12,7 +12,6 @@ const LISTS_PREF_BRANCH = "browser.safebrowsing.provider.mozilla.lists.";
var gBlocklistManager = {
_type: "",
_blockLists: [],
_bundle: null,
_tree: null,
_view: {
@ -23,10 +22,7 @@ var gBlocklistManager = {
getCellText(row, column) {
if (column.id == "listCol") {
let list = gBlocklistManager._blockLists[row];
let desc = list.description ? list.description : "";
let text = gBlocklistManager._bundle.getFormattedString("mozNameTemplate",
[list.name, desc]);
return text;
return list.name;
}
return "";
},
@ -62,7 +58,6 @@ var gBlocklistManager = {
},
onLoad() {
this._bundle = document.getElementById("bundlePreferences");
let params = window.arguments[0];
this.init(params);
},
@ -119,7 +114,7 @@ var gBlocklistManager = {
window.close();
},
_loadBlockLists() {
async _loadBlockLists() {
this._blockLists = [];
// Load blocklists into a table.
@ -127,7 +122,8 @@ var gBlocklistManager = {
let itemArray = branch.getChildList("");
for (let itemName of itemArray) {
try {
this._createOrUpdateBlockList(itemName);
let list = await this._createBlockList(itemName);
this._blockLists.push(list);
} catch (e) {
// Ignore bogus or missing list name.
continue;
@ -137,25 +133,21 @@ var gBlocklistManager = {
this._updateTree();
},
_createOrUpdateBlockList(itemName) {
async _createBlockList(id) {
let branch = Services.prefs.getBranch(LISTS_PREF_BRANCH);
let key = branch.getCharPref(itemName);
let value = this._bundle.getString(key);
let l10nKey = branch.getCharPref(id);
let [listName, description] = await document.l10n.formatValues([
[`blocklist-item-${l10nKey}-name`],
[`blocklist-item-${l10nKey}-desc`],
]);
let name = await document.l10n.formatValue(
"blocklist-item-list-template", {listName, description});
let suffix = itemName.slice(itemName.lastIndexOf("."));
let id = itemName.replace(suffix, "");
let list = this._blockLists.find(el => el.id === id);
if (!list) {
list = { id };
this._blockLists.push(list);
}
list.selected = this._getActiveList() === id;
// Get the property name from the suffix (e.g. ".name" -> "name").
let prop = suffix.slice(1);
list[prop] = value;
return list;
return {
id,
name,
selected: this._getActiveList() === id,
};
},
_updateTree() {

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

@ -24,9 +24,6 @@
<script src="chrome://global/content/treeUtils.js"/>
<script src="chrome://browser/content/preferences/blocklists.js"/>
<stringbundle id="bundlePreferences"
src="chrome://browser/locale/preferences/preferences.properties"/>
<keyset>
<key data-l10n-id="blocklist-close-key" modifiers="accel" oncommand="window.close();"/>
</keyset>

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

@ -20,3 +20,17 @@ blocklist-button-cancel =
blocklist-button-ok =
.label = Save Changes
.accesskey = S
# This template constructs the name of the block list in the block lists dialog.
# It combines the list name and description.
# e.g. "Standard (Recommended). This list does a pretty good job."
#
# Variables:
# $listName {string, "Standard (Recommended)."} - List name.
# $description {string, "This list does a pretty good job."} - Description of the list.
blocklist-item-list-template = { $listName } { $description }
blocklist-item-moz-std-name = Disconnect.me basic protection (Recommended).
blocklist-item-moz-std-desc = Allows some trackers so websites function properly.
blocklist-item-moz-full-name = Disconnect.me strict protection.
blocklist-item-moz-full-desc = Blocks known trackers. Some websites may not function properly.

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

@ -18,23 +18,6 @@ veryLargeMinimumFontTitle=Large minimum font size
veryLargeMinimumFontWarning=You have selected a very large minimum font size (more than 24 pixels). This may make it difficult or impossible to use some important configuration pages like this one.
acceptVeryLargeMinimumFont=Keep my changes anyway
#### Block List Manager
# LOCALIZATION NOTE (mozNameTemplate): This template constructs the name of the
# block list in the block lists dialog. It combines the list name and
# description.
# e.g. mozNameTemplate : "Standard (Recommended). This list does a pretty good job."
# %1$S = list name (fooName), %2$S = list descriptive text (fooDesc)
mozNameTemplate=%1$S %2$S
# LOCALIZATION NOTE (mozstdName, etc.): These labels appear in the tracking
# protection block lists dialog, mozNameTemplate is used to create the final
# string. Note that in the future these two strings (name, desc) could be
# displayed on two different lines.
mozstdName=Disconnect.me basic protection (Recommended).
mozstdDesc=Allows some trackers so websites function properly.
mozfullName=Disconnect.me strict protection.
mozfullDesc2=Blocks known trackers. Some websites may not function properly.
#### Master Password
pw_change2empty_in_fips_mode=You are currently in FIPS mode. FIPS requires a non-empty Master Password.

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

@ -5419,10 +5419,8 @@ pref("browser.safebrowsing.provider.mozilla.gethashURL", "https://shavar.service
pref("browser.safebrowsing.provider.mozilla.nextupdatetime", "1");
// Block lists for tracking protection. The name values will be used as the keys
// to lookup the localized name in preferences.properties.
pref("browser.safebrowsing.provider.mozilla.lists.base.name", "mozstdName");
pref("browser.safebrowsing.provider.mozilla.lists.base.description", "mozstdDesc");
pref("browser.safebrowsing.provider.mozilla.lists.content.name", "mozfullName");
pref("browser.safebrowsing.provider.mozilla.lists.content.description", "mozfullDesc2");
pref("browser.safebrowsing.provider.mozilla.lists.base", "moz-std");
pref("browser.safebrowsing.provider.mozilla.lists.content", "moz-full");
// The table and global pref for blocking plugin content
pref("browser.safebrowsing.blockedURIs.enabled", true);