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

Side by Side Diff: chrome/content/ui/composer.js

Issue 29329450: Issue 3208 - Don`t use numerical content types outside nsIContentPolicy.shouldLoad (Closed)
Patch Set: Created Oct. 28, 2015, 2:42 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | lib/contentPolicy.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2015 Eyeo GmbH 3 * Copyright (C) 2006-2015 Eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 // IOService returned nsIURI - not much we can do with it 112 // IOService returned nsIURI - not much we can do with it
113 addSuggestion(item.location); 113 addSuggestion(item.location);
114 E("patternGroup").value = ""; 114 E("patternGroup").value = "";
115 } 115 }
116 if (Prefs.composer_default == 0) 116 if (Prefs.composer_default == 0)
117 E("customPattern").focus(); 117 E("customPattern").focus();
118 else 118 else
119 E("patternGroup").focus(); 119 E("patternGroup").focus();
120 120
121 let types = []; 121 let types = [];
122 for (let type in Policy.localizedDescr) 122 for (let type of Policy.localizedDescr.keys())
123 { 123 types.push(type);
124 types.push(parseInt(type)); 124 types.sort();
125 }
126 types.sort(function(a, b) {
127 if (a < b)
128 return -1;
129 else if (a > b)
130 return 1;
131 else
132 return 0;
133 });
134 125
135 let docDomain = item.docDomain; 126 let docDomain = item.docDomain;
136 let thirdParty = item.thirdParty; 127 let thirdParty = item.thirdParty;
137 128
138 if (docDomain) 129 if (docDomain)
139 docDomain = docDomain.replace(/^www\./i, "").replace(/\.+$/, ""); 130 docDomain = docDomain.replace(/^www\./i, "").replace(/\.+$/, "");
140 if (docDomain) 131 if (docDomain)
141 E("domainRestriction").value = docDomain; 132 E("domainRestriction").value = docDomain;
142 133
143 E("thirdParty").hidden = !thirdParty; 134 E("thirdParty").hidden = !thirdParty;
144 E("firstParty").hidden = thirdParty; 135 E("firstParty").hidden = thirdParty;
145 136
146 let typeGroup = E("typeGroup"); 137 let typeGroup = E("typeGroup");
147 let defaultTypes = RegExpFilter.prototype.contentType & ~RegExpFilter.typeMap. DOCUMENT; 138 let defaultTypes = RegExpFilter.prototype.contentType & ~RegExpFilter.typeMap. DOCUMENT;
148 let isDefaultType = (RegExpFilter.typeMap[item.typeDescr] & defaultTypes) != 0 ; 139 let isDefaultType = (RegExpFilter.typeMap[item.typeDescr] & defaultTypes) != 0 ;
149 for (let type of types) 140 for (let type of types)
150 { 141 {
151 if (type == Policy.type.ELEMHIDE) 142 if (type == "ELEMHIDE")
152 continue; 143 continue;
153 144
154 let typeNode = document.createElement("checkbox"); 145 let typeNode = document.createElement("checkbox");
155 typeNode.setAttribute("value", Policy.typeDescr[type].toLowerCase().replace( /\_/g, "-")); 146 typeNode.setAttribute("value", type.toLowerCase().replace(/\_/g, "-"));
156 typeNode.setAttribute("label", Policy.localizedDescr[type].toLowerCase()); 147 typeNode.setAttribute("label", Policy.localizedDescr.get(type).toLowerCase() );
157 148
158 let typeMask = RegExpFilter.typeMap[Policy.typeDescr[type]]; 149 let typeMask = RegExpFilter.typeMap[type];
159 typeNode._defaultType = (typeMask & defaultTypes) != 0; 150 typeNode._defaultType = (typeMask & defaultTypes) != 0;
160 if ((isDefaultType && typeNode._defaultType) || (!isDefaultType && item.type == type)) 151 if ((isDefaultType && typeNode._defaultType) || (!isDefaultType && item.type == type))
161 typeNode.setAttribute("checked", "true"); 152 typeNode.setAttribute("checked", "true");
162 153
163 if (item.type == type) 154 if (item.type == type)
164 typeNode.setAttribute("disabled", "true"); 155 typeNode.setAttribute("disabled", "true");
165 typeNode.addEventListener("command", () => checkboxUpdated(typeNode), false) ; 156 typeNode.addEventListener("command", () => checkboxUpdated(typeNode), false) ;
166 typeGroup.appendChild(typeNode); 157 typeGroup.appendChild(typeNode);
167 } 158 }
168 159
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 * Selects or unselects all type checkboxes except those 394 * Selects or unselects all type checkboxes except those
404 * that are disabled. 395 * that are disabled.
405 */ 396 */
406 function selectAllTypes(/**Boolean*/ select) 397 function selectAllTypes(/**Boolean*/ select)
407 { 398 {
408 for (let typeNode = E("typeGroup").firstChild; typeNode; typeNode = typeNode.n extSibling) 399 for (let typeNode = E("typeGroup").firstChild; typeNode; typeNode = typeNode.n extSibling)
409 if (typeNode.getAttribute("disabled") != "true") 400 if (typeNode.getAttribute("disabled") != "true")
410 typeNode.checked = select; 401 typeNode.checked = select;
411 updateFilter(); 402 updateFilter();
412 } 403 }
OLDNEW
« no previous file with comments | « no previous file | lib/contentPolicy.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld