Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: chrome/content/ui/sidebar.js

Issue 29329473: Issue 3222 - Don`t do localization in the contentPolicy module (Closed)
Patch Set: Addressed comments Created Nov. 5, 2015, 3:45 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/content/ui/composer.js ('k') | lib/contentPolicy.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/content/ui/sidebar.js
===================================================================
--- a/chrome/content/ui/sidebar.js
+++ b/chrome/content/ui/sidebar.js
@@ -28,16 +28,19 @@ var noFlash = false;
// Matcher for disabled filters
var disabledMatcher = new CombinedMatcher();
// Cached string values
var docDomainThirdParty = null;
var docDomainFirstParty = null;
+// Localized type names
+var localizedTypes = new Map();
+
function init() {
docDomainThirdParty = document.documentElement.getAttribute("docDomainThirdParty");
docDomainFirstParty = document.documentElement.getAttribute("docDomainFirstParty");
var list = E("list");
list.view = treeView;
// Restore previous state
@@ -96,16 +99,19 @@ function init() {
list.addEventListener("select", onSelectionChange, false);
// Initialize data
handleLocationChange();
// Install a progress listener to catch location changes
if (addBrowserLocationListener)
addBrowserLocationListener(mainWin, handleLocationChange, true);
+
+ for (let type of Policy.contentTypes)
+ localizedTypes.set(type, Utils.getString("type_label_" + type.toLowerCase()));
}
// To be called for a detached window when the main window has been closed
function mainUnload() {
parent.close();
}
// To be called on unload
@@ -253,17 +259,17 @@ function fillInTooltip(e) {
if ("tooltip" in item)
E("tooltipDummy").setAttribute("value", item.tooltip);
else
{
E("tooltipAddress").parentNode.hidden = (item.typeDescr == "ELEMHIDE");
setMultilineContent(E("tooltipAddress"), item.location);
- var type = item.localizedDescr;
+ var type = localizedTypes.get(item.type);
if (filter && filter instanceof WhitelistFilter)
type += " " + E("tooltipType").getAttribute("whitelisted");
else if (filter && item.typeDescr != "ELEMHIDE")
type += " " + E("tooltipType").getAttribute("filtered");
E("tooltipType").setAttribute("value", type);
if (size)
E("tooltipSize").setAttribute("value", size.join(" x "));
@@ -309,17 +315,17 @@ function fillInTooltip(e) {
let loadContext = content.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIWebNavigation)
.QueryInterface(Ci.nsILoadContext);
cacheStorage = Services.cache2.diskCacheStorage(LoadContextInfo.fromLoadContext(loadContext, false), false);
}
else
cacheStorage = Services.cache.createSession("HTTP", Ci.nsICache.STORE_ANYWHERE, true);
}
-
+
let showTooltipPreview = function ()
{
E("tooltipPreview").setAttribute("src", item.location);
E("tooltipPreviewBox").hidden = false;
};
try
{
if (Ci.nsICacheStorage && cacheStorage instanceof Ci.nsICacheStorage)
@@ -673,19 +679,21 @@ function sortByAddress(item1, item2) {
return 0;
}
function sortByAddressDesc(item1, item2) {
return -sortByAddress(item1, item2);
}
function compareType(item1, item2) {
- if (item1.localizedDescr < item2.localizedDescr)
+ let type1 = localizedTypes.get(item1.type);
+ let type2 = localizedTypes.get(item2.type);
+ if (type1 < type2)
return -1;
- else if (item1.localizedDescr > item2.localizedDescr)
+ else if (type1 > type2)
return 1;
else
return 0;
}
function compareFilter(item1, item2) {
var hasFilter1 = (item1.filter ? 1 : 0);
var hasFilter2 = (item2.filter ? 1 : 0);
@@ -841,17 +849,17 @@ var treeView = {
getCellText: function(row, col) {
col = col.id;
if (col != "type" && col != "address" && col != "filter" && col != "size" && col != "docDomain" && col != "filterSource")
return "";
if (this.data && this.data.length) {
if (row >= this.data.length)
return "";
if (col == "type")
- return this.data[row].localizedDescr;
+ return localizedTypes.get(this.data[row].type);
else if (col == "filter")
return (this.data[row].filter ? this.data[row].filter.text : "");
else if (col == "size")
{
let size = getItemSize(this.data[row]);
return (size ? size.join(" x ") : "");
}
else if (col == "docDomain")
@@ -1156,17 +1164,17 @@ var treeView = {
matchesFilter: function(item)
{
if (!this.filter)
return true;
return (item.location.toLowerCase().indexOf(this.filter) >= 0 ||
(item.filter && item.filter.text.toLowerCase().indexOf(this.filter) >= 0) ||
item.typeDescr.toLowerCase().indexOf(this.filter.replace(/-/g, "_")) >= 0 ||
- item.localizedDescr.toLowerCase().indexOf(this.filter) >= 0 ||
+ localizedTypes.get(item.type).toLowerCase().indexOf(this.filter) >= 0 ||
(item.docDomain && item.docDomain.toLowerCase().indexOf(this.filter) >= 0) ||
(item.docDomain && item.thirdParty && docDomainThirdParty.toLowerCase().indexOf(this.filter) >= 0) ||
(item.docDomain && !item.thirdParty && docDomainFirstParty.toLowerCase().indexOf(this.filter) >= 0));
},
setFilter: function(filter) {
var oldRows = this.rowCount;
« no previous file with comments | « chrome/content/ui/composer.js ('k') | lib/contentPolicy.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld