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

Unified 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.
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
Index: chrome/content/ui/sidebar.js
===================================================================
--- a/chrome/content/ui/sidebar.js
+++ b/chrome/content/ui/sidebar.js
@@ -15,16 +15,19 @@
* along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
*/
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
// Main browser window
var mainWin = parent;
+// Location of the content window that the list refers to
+var contentLocation = null;
+
// The window handler currently in use
var requestNotifier = null;
var cacheStorage = null;
// Matcher for disabled filters
var disabledMatcher = new CombinedMatcher();
@@ -82,16 +85,17 @@ function init() {
let wnd = parent.document.documentElement;
for (let attr in defaults)
if (!wnd.hasAttribute(attr))
wnd.setAttribute(attr, defaults[attr]);
}
let {getBrowser, addBrowserLocationListener} = require("appSupport");
+ updateContentLocation();
Object.defineProperty(window, "content", { get: () => getBrowser(mainWin).contentWindow });
// Initialize matcher for disabled filters
reloadDisabledFilters();
FilterNotifier.addListener(reloadDisabledFilters);
Prefs.addListener(onPrefChange);
// Activate flasher
@@ -108,16 +112,25 @@ function init() {
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();
}
+function updateContentLocation()
+{
+ let {getCurrentLocation} = require("appSupport");
+ let location = getCurrentLocation(mainWin);
+ if (location instanceof Ci.nsIURI)
+ location = location.spec;
+ contentLocation = location;
+}
+
function getFilter(item)
{
if ("filter" in item && item.filter)
return Filter.fromText(item.filter);
else
return null;
}
@@ -200,24 +213,26 @@ function onSelectionChange() {
requestNotifier.flashNodes(item ? item.ids : null, Prefs.flash_scrolltoitem);
}
function handleLocationChange()
{
if (requestNotifier)
requestNotifier.shutdown();
+ updateContentLocation();
treeView.clearData();
let {getBrowser, addBrowserLocationListener} = require("appSupport");
let browser = getBrowser(mainWin);
if ("selectedBrowser" in browser)
browser = browser.selectedBrowser;
let outerWindowID = browser.outerWindowID;
- treeView.itemToSelect = RequestNotifier.getSelection(window.content);
+ if (window.content)
+ treeView.itemToSelect = RequestNotifier.getSelection(window.content);
requestNotifier = new RequestNotifier(outerWindowID, function(item, scanComplete)
{
if (item)
treeView.addItem(item, scanComplete);
});
cacheStorage = null;
}
@@ -929,21 +944,21 @@ var treeView = {
else
return this.data[row].location;
}
else {
// Empty list, show dummy
if (row > 0 || (col != "address" && col != "filter"))
return "";
if (col == "filter") {
- var filter = Policy.isWindowWhitelisted(window.content);
+ var filter = Policy.isWhitelisted(contentLocation);
return filter ? filter.text : "";
}
- return (Policy.isWindowWhitelisted(window.content) ? this.whitelistDummy : this.itemsDummy);
+ return (Policy.isWhitelisted(contentLocation) ? this.whitelistDummy : this.itemsDummy);
}
},
generateProperties: function(list, properties)
{
if (properties)
{
// Gecko 21 and below: we have an nsISupportsArray parameter, add atoms
@@ -993,17 +1008,17 @@ var treeView = {
else if (filter instanceof ElemHideException)
state = "state-hiddenexception";
}
}
else {
list.push("dummy-true");
state = "state-filtered";
- if (this.data && Policy.isWindowWhitelisted(window.content))
+ if (this.data && Policy.isWhitelisted(contentLocation))
state = "state-whitelisted";
}
list.push(state);
return this.generateProperties(list, properties);
},
getCellProperties: function(row, col, properties)
{
@@ -1303,17 +1318,17 @@ var treeView = {
this.boxObject.getCellAt(x, y, {}, col, {});
return (col.value ? col.value.id : null);
},
getDummyTooltip: function() {
if (!this.data || this.data.length)
return null;
- var filter = Policy.isWindowWhitelisted(window.content);
+ var filter = Policy.isWhitelisted(contentLocation);
if (filter)
return {tooltip: this.whitelistDummyTooltip, filter: filter.text};
else
return {tooltip: this.itemsDummyTooltip};
},
invalidateItem: function(item)
{

Powered by Google App Engine
This is Rietveld