OLD | NEW |
1 /* | 1 /* |
2 * This file is part of Adblock Plus <http://adblockplus.org/>, | 2 * This file is part of Adblock Plus <http://adblockplus.org/>, |
3 * Copyright (C) 2006-2014 Eyeo GmbH | 3 * Copyright (C) 2006-2014 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 1070 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1081 * Updates Adblock Plus icon state for a single application window. | 1081 * Updates Adblock Plus icon state for a single application window. |
1082 */ | 1082 */ |
1083 updateIconState: function(/**Window*/ window, /**Element*/ icon) | 1083 updateIconState: function(/**Window*/ window, /**Element*/ icon) |
1084 { | 1084 { |
1085 if (!icon) | 1085 if (!icon) |
1086 return; | 1086 return; |
1087 | 1087 |
1088 let state = (Prefs.enabled ? "active" : "disabled"); | 1088 let state = (Prefs.enabled ? "active" : "disabled"); |
1089 if (state == "active") | 1089 if (state == "active") |
1090 { | 1090 { |
1091 let location = this.getCurrentLocation(window); | 1091 let {getBrowser} = require("appSupport"); |
1092 if (location && Policy.isWhitelisted(location.spec)) | 1092 if (Policy.isWindowWhitelisted(getBrowser(window).contentWindow)) |
1093 state = "whitelisted"; | 1093 state = "whitelisted"; |
1094 } | 1094 } |
1095 | 1095 |
1096 let popupId = "abp-status-popup"; | 1096 let popupId = "abp-status-popup"; |
1097 if (icon.localName == "statusbarpanel") | 1097 if (icon.localName == "statusbarpanel") |
1098 { | 1098 { |
1099 if (Prefs.defaultstatusbaraction == 0) | 1099 if (Prefs.defaultstatusbaraction == 0) |
1100 { | 1100 { |
1101 icon.setAttribute("popup", popupId); | 1101 icon.setAttribute("popup", popupId); |
1102 icon.removeAttribute("context"); | 1102 icon.removeAttribute("context"); |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1323 if (!this.removeWhitelist(window)) | 1323 if (!this.removeWhitelist(window)) |
1324 this.togglePref("enabled"); | 1324 this.togglePref("enabled"); |
1325 } | 1325 } |
1326 }, | 1326 }, |
1327 | 1327 |
1328 /** | 1328 /** |
1329 * Removes/disables the exception rule applying for the current page. | 1329 * Removes/disables the exception rule applying for the current page. |
1330 */ | 1330 */ |
1331 removeWhitelist: function(/**Window*/ window) | 1331 removeWhitelist: function(/**Window*/ window) |
1332 { | 1332 { |
1333 let location = this.getCurrentLocation(window); | |
1334 let filter = null; | 1333 let filter = null; |
1335 if (location) | 1334 let {getBrowser} = require("appSupport"); |
1336 filter = Policy.isWhitelisted(location.spec); | 1335 filter = Policy.isWindowWhitelisted(getBrowser(window).contentWindow); |
1337 if (filter && filter.subscriptions.length && !filter.disabled) | 1336 if (filter && filter.subscriptions.length && !filter.disabled) |
1338 { | 1337 { |
1339 UI.toggleFilter(filter); | 1338 UI.toggleFilter(filter); |
1340 return true; | 1339 return true; |
1341 } | 1340 } |
1342 return false; | 1341 return false; |
1343 }, | 1342 }, |
1344 | 1343 |
1345 /** | 1344 /** |
1346 * Updates state of the icon tooltip. | 1345 * Updates state of the icon tooltip. |
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1675 break; | 1674 break; |
1676 } | 1675 } |
1677 } | 1676 } |
1678 } | 1677 } |
1679 | 1678 |
1680 node = node.parentNode; | 1679 node = node.parentNode; |
1681 } | 1680 } |
1682 } | 1681 } |
1683 | 1682 |
1684 // Add "Remove exception" menu item if necessary | 1683 // Add "Remove exception" menu item if necessary |
1685 let location = this.getCurrentLocation(window); | 1684 let {getBrowser} = require("appSupport"); |
1686 let filter = (location ? Policy.isWhitelisted(location.spec) : null); | 1685 let filter = Policy.isWindowWhitelisted(getBrowser(window).contentWindow); |
1687 if (filter && filter.subscriptions.length && !filter.disabled) | 1686 if (filter && filter.subscriptions.length && !filter.disabled) |
1688 { | 1687 { |
1689 let label = this.overlay.attributes.whitelistcontextlabel; | 1688 let label = this.overlay.attributes.whitelistcontextlabel; |
1690 if (!label) | 1689 if (!label) |
1691 return; | 1690 return; |
1692 | 1691 |
1693 let item = popup.ownerDocument.createElement("menuitem"); | 1692 let item = popup.ownerDocument.createElement("menuitem"); |
1694 item.setAttribute("label", label); | 1693 item.setAttribute("label", label); |
1695 item.setAttribute("class", "abp-contextmenuitem"); | 1694 item.setAttribute("class", "abp-contextmenuitem"); |
1696 item.addEventListener("command", this.toggleFilter.bind(this, filter), fal
se); | 1695 item.addEventListener("command", this.toggleFilter.bind(this, filter), fal
se); |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1950 ["abp-command-contribute", "command", UI.openContributePage.bind(UI)], | 1949 ["abp-command-contribute", "command", UI.openContributePage.bind(UI)], |
1951 ["abp-command-contribute-hide", "command", UI.hideContributeButton.bind(UI)] | 1950 ["abp-command-contribute-hide", "command", UI.hideContributeButton.bind(UI)] |
1952 ]; | 1951 ]; |
1953 | 1952 |
1954 onShutdown.add(function() | 1953 onShutdown.add(function() |
1955 { | 1954 { |
1956 for (let window in UI.applicationWindows) | 1955 for (let window in UI.applicationWindows) |
1957 if (UI.isBottombarOpen(window)) | 1956 if (UI.isBottombarOpen(window)) |
1958 UI.toggleBottombar(window); | 1957 UI.toggleBottombar(window); |
1959 }); | 1958 }); |
OLD | NEW |