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

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

Issue 29333159: Issue 3407 - Remove Policy.isWindowWhitelisted() method and its callers (Closed)
Patch Set: Removed unrelated change Created Jan. 4, 2016, 7:34 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
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
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details. 12 * GNU General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU General Public License 14 * You should have received a copy of the GNU General Public License
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
16 */ 16 */
17 17
18 Cu.import("resource://gre/modules/XPCOMUtils.jsm"); 18 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
19 19
20 // Main browser window 20 // Main browser window
21 var mainWin = parent; 21 var mainWin = parent;
22 22
23 // Location of the content window that the list refers to
24 var contentLocation = null;
25
23 // The window handler currently in use 26 // The window handler currently in use
24 var requestNotifier = null; 27 var requestNotifier = null;
25 28
26 var cacheStorage = null; 29 var cacheStorage = null;
27 30
28 // Matcher for disabled filters 31 // Matcher for disabled filters
29 var disabledMatcher = new CombinedMatcher(); 32 var disabledMatcher = new CombinedMatcher();
30 33
31 // Cached string values 34 // Cached string values
32 var docDomainThirdParty = null; 35 var docDomainThirdParty = null;
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 if (params && params.position) 83 if (params && params.position)
81 defaults = params.position; 84 defaults = params.position;
82 85
83 let wnd = parent.document.documentElement; 86 let wnd = parent.document.documentElement;
84 for (let attr in defaults) 87 for (let attr in defaults)
85 if (!wnd.hasAttribute(attr)) 88 if (!wnd.hasAttribute(attr))
86 wnd.setAttribute(attr, defaults[attr]); 89 wnd.setAttribute(attr, defaults[attr]);
87 } 90 }
88 91
89 let {getBrowser, addBrowserLocationListener} = require("appSupport"); 92 let {getBrowser, addBrowserLocationListener} = require("appSupport");
93 updateContentLocation();
90 Object.defineProperty(window, "content", { get: () => getBrowser(mainWin).cont entWindow }); 94 Object.defineProperty(window, "content", { get: () => getBrowser(mainWin).cont entWindow });
91 95
92 // Initialize matcher for disabled filters 96 // Initialize matcher for disabled filters
93 reloadDisabledFilters(); 97 reloadDisabledFilters();
94 FilterNotifier.addListener(reloadDisabledFilters); 98 FilterNotifier.addListener(reloadDisabledFilters);
95 Prefs.addListener(onPrefChange); 99 Prefs.addListener(onPrefChange);
96 100
97 // Activate flasher 101 // Activate flasher
98 list.addEventListener("select", onSelectionChange, false); 102 list.addEventListener("select", onSelectionChange, false);
99 103
100 // Initialize data 104 // Initialize data
101 handleLocationChange(); 105 handleLocationChange();
102 106
103 // Install a progress listener to catch location changes 107 // Install a progress listener to catch location changes
104 if (addBrowserLocationListener) 108 if (addBrowserLocationListener)
105 addBrowserLocationListener(mainWin, handleLocationChange, true); 109 addBrowserLocationListener(mainWin, handleLocationChange, true);
106 110
107 for (let type of Policy.contentTypes) 111 for (let type of Policy.contentTypes)
108 localizedTypes.set(type, Utils.getString("type_label_" + type.toLowerCase()) ); 112 localizedTypes.set(type, Utils.getString("type_label_" + type.toLowerCase()) );
109 } 113 }
110 114
111 // To be called for a detached window when the main window has been closed 115 // To be called for a detached window when the main window has been closed
112 function mainUnload() { 116 function mainUnload() {
113 parent.close(); 117 parent.close();
114 } 118 }
115 119
120 function updateContentLocation()
121 {
122 let {getCurrentLocation} = require("appSupport");
123 let location = getCurrentLocation(mainWin);
124 if (location instanceof Ci.nsIURI)
125 location = location.spec;
126 contentLocation = location;
127 }
128
116 function getFilter(item) 129 function getFilter(item)
117 { 130 {
118 if ("filter" in item && item.filter) 131 if ("filter" in item && item.filter)
119 return Filter.fromText(item.filter); 132 return Filter.fromText(item.filter);
120 else 133 else
121 return null; 134 return null;
122 } 135 }
123 136
124 // To be called on unload 137 // To be called on unload
125 function cleanUp() { 138 function cleanUp() {
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 211
199 if (requestNotifier) 212 if (requestNotifier)
200 requestNotifier.flashNodes(item ? item.ids : null, Prefs.flash_scrolltoitem) ; 213 requestNotifier.flashNodes(item ? item.ids : null, Prefs.flash_scrolltoitem) ;
201 } 214 }
202 215
203 function handleLocationChange() 216 function handleLocationChange()
204 { 217 {
205 if (requestNotifier) 218 if (requestNotifier)
206 requestNotifier.shutdown(); 219 requestNotifier.shutdown();
207 220
221 updateContentLocation();
208 treeView.clearData(); 222 treeView.clearData();
209 223
210 let {getBrowser, addBrowserLocationListener} = require("appSupport"); 224 let {getBrowser, addBrowserLocationListener} = require("appSupport");
211 let browser = getBrowser(mainWin); 225 let browser = getBrowser(mainWin);
212 if ("selectedBrowser" in browser) 226 if ("selectedBrowser" in browser)
213 browser = browser.selectedBrowser; 227 browser = browser.selectedBrowser;
214 let outerWindowID = browser.outerWindowID; 228 let outerWindowID = browser.outerWindowID;
215 treeView.itemToSelect = RequestNotifier.getSelection(window.content); 229 if (window.content)
230 treeView.itemToSelect = RequestNotifier.getSelection(window.content);
216 requestNotifier = new RequestNotifier(outerWindowID, function(item, scanComple te) 231 requestNotifier = new RequestNotifier(outerWindowID, function(item, scanComple te)
217 { 232 {
218 if (item) 233 if (item)
219 treeView.addItem(item, scanComplete); 234 treeView.addItem(item, scanComplete);
220 }); 235 });
221 cacheStorage = null; 236 cacheStorage = null;
222 } 237 }
223 238
224 // Fills a box with text splitting it up into multiple lines if necessary 239 // Fills a box with text splitting it up into multiple lines if necessary
225 function setMultilineContent(box, text, noRemove) 240 function setMultilineContent(box, text, noRemove)
(...skipping 701 matching lines...) Expand 10 before | Expand all | Expand 10 after
927 return filter.subscriptions.filter(s => !s.disabled).map(s => s.title).j oin(", "); 942 return filter.subscriptions.filter(s => !s.disabled).map(s => s.title).j oin(", ");
928 } 943 }
929 else 944 else
930 return this.data[row].location; 945 return this.data[row].location;
931 } 946 }
932 else { 947 else {
933 // Empty list, show dummy 948 // Empty list, show dummy
934 if (row > 0 || (col != "address" && col != "filter")) 949 if (row > 0 || (col != "address" && col != "filter"))
935 return ""; 950 return "";
936 if (col == "filter") { 951 if (col == "filter") {
937 var filter = Policy.isWindowWhitelisted(window.content); 952 var filter = Policy.isWhitelisted(contentLocation);
938 return filter ? filter.text : ""; 953 return filter ? filter.text : "";
939 } 954 }
940 955
941 return (Policy.isWindowWhitelisted(window.content) ? this.whitelistDummy : this.itemsDummy); 956 return (Policy.isWhitelisted(contentLocation) ? this.whitelistDummy : this .itemsDummy);
942 } 957 }
943 }, 958 },
944 959
945 generateProperties: function(list, properties) 960 generateProperties: function(list, properties)
946 { 961 {
947 if (properties) 962 if (properties)
948 { 963 {
949 // Gecko 21 and below: we have an nsISupportsArray parameter, add atoms 964 // Gecko 21 and below: we have an nsISupportsArray parameter, add atoms
950 // to that. 965 // to that.
951 for (let i = 0; i < list.length; i++) 966 for (let i = 0; i < list.length; i++)
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
991 else if (filter instanceof ElemHideFilter) 1006 else if (filter instanceof ElemHideFilter)
992 state = "state-hidden"; 1007 state = "state-hidden";
993 else if (filter instanceof ElemHideException) 1008 else if (filter instanceof ElemHideException)
994 state = "state-hiddenexception"; 1009 state = "state-hiddenexception";
995 } 1010 }
996 } 1011 }
997 else { 1012 else {
998 list.push("dummy-true"); 1013 list.push("dummy-true");
999 1014
1000 state = "state-filtered"; 1015 state = "state-filtered";
1001 if (this.data && Policy.isWindowWhitelisted(window.content)) 1016 if (this.data && Policy.isWhitelisted(contentLocation))
1002 state = "state-whitelisted"; 1017 state = "state-whitelisted";
1003 } 1018 }
1004 list.push(state); 1019 list.push(state);
1005 return this.generateProperties(list, properties); 1020 return this.generateProperties(list, properties);
1006 }, 1021 },
1007 1022
1008 getCellProperties: function(row, col, properties) 1023 getCellProperties: function(row, col, properties)
1009 { 1024 {
1010 return this.getRowProperties(row, properties) + " " + this.getColumnProperti es(col, properties); 1025 return this.getRowProperties(row, properties) + " " + this.getColumnProperti es(col, properties);
1011 }, 1026 },
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
1301 1316
1302 let col = {}; 1317 let col = {};
1303 this.boxObject.getCellAt(x, y, {}, col, {}); 1318 this.boxObject.getCellAt(x, y, {}, col, {});
1304 return (col.value ? col.value.id : null); 1319 return (col.value ? col.value.id : null);
1305 }, 1320 },
1306 1321
1307 getDummyTooltip: function() { 1322 getDummyTooltip: function() {
1308 if (!this.data || this.data.length) 1323 if (!this.data || this.data.length)
1309 return null; 1324 return null;
1310 1325
1311 var filter = Policy.isWindowWhitelisted(window.content); 1326 var filter = Policy.isWhitelisted(contentLocation);
1312 if (filter) 1327 if (filter)
1313 return {tooltip: this.whitelistDummyTooltip, filter: filter.text}; 1328 return {tooltip: this.whitelistDummyTooltip, filter: filter.text};
1314 else 1329 else
1315 return {tooltip: this.itemsDummyTooltip}; 1330 return {tooltip: this.itemsDummyTooltip};
1316 }, 1331 },
1317 1332
1318 invalidateItem: function(item) 1333 invalidateItem: function(item)
1319 { 1334 {
1320 let row = this.data.indexOf(item); 1335 let row = this.data.indexOf(item);
1321 if (row >= 0) 1336 if (row >= 0)
1322 this.boxObject.invalidateRow(row); 1337 this.boxObject.invalidateRow(row);
1323 } 1338 }
1324 } 1339 }
OLDNEW

Powered by Google App Engine
This is Rietveld