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-2013 Eyeo GmbH | 3 * Copyright (C) 2006-2013 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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 if (option in localStorage) | 93 if (option in localStorage) |
94 delete localStorage[option]; | 94 delete localStorage[option]; |
95 }); | 95 }); |
96 } | 96 } |
97 | 97 |
98 // Remove deprecated options before we do anything else. | 98 // Remove deprecated options before we do anything else. |
99 removeDeprecatedOptions(); | 99 removeDeprecatedOptions(); |
100 | 100 |
101 var activeNotification = null; | 101 var activeNotification = null; |
102 | 102 |
103 // Adds or removes browser action icon according to options. | 103 function getTabStatus(tab) |
| 104 { |
| 105 var whitelisted = isWhitelisted(tab.url); |
| 106 var animated = iconAnimation.tabs.has(tab); |
| 107 |
| 108 var icon; |
| 109 if (require("info").platform == "safari") |
| 110 // pick an icon with approtiate size for Safari. However since |
| 111 // toolbar item icons can't use different colors, we don't have |
| 112 // different versions indicating whether the page is whitelisted |
| 113 icon = "icons/abp-16"; |
| 114 else |
| 115 { |
| 116 // pick an icon with the approtiate size for Chrome/Opera |
| 117 // that indicates whether the page is whitelisted |
| 118 if (whitelisted && (!animated || iconAnimation.step < 10)) |
| 119 icon = "icons/abp-19-whitelisted"; |
| 120 else |
| 121 icon = "icons/abp-19"; |
| 122 } |
| 123 |
| 124 // pick the current frame if the icon is currently animating |
| 125 // in order to indicate a pending notification |
| 126 if (animated && iconAnimation.step > 0) |
| 127 { |
| 128 icon += "-notification-" + iconAnimation.severity; |
| 129 |
| 130 if (iconAnimation.step < 10) |
| 131 icon += "-" + iconAnimation.step; |
| 132 } |
| 133 |
| 134 icon += ".png"; |
| 135 |
| 136 return {icon: icon, whitelisted: whitelisted}; |
| 137 } |
| 138 |
104 function refreshIconAndContextMenu(tab) | 139 function refreshIconAndContextMenu(tab) |
105 { | 140 { |
106 var whitelisted = isWhitelisted(tab.url); | 141 var status = getTabStatus(tab); |
107 | 142 |
108 var iconFilename; | 143 // update icon indicating whether the page is whitelisted. |
109 if (require("info").platform == "safari") | 144 // But don't interfere the icon animation if active. |
110 // There is no grayscale version of the icon for whitelisted tabs | 145 // In that case the icon animation takes care to update |
111 // when using Safari, because icons are grayscale already and icons | 146 // the icon to its new status with its next frame. |
112 // aren't per tab in Safari. | 147 if (!iconAnimation.tabs.has(tab)) |
113 iconFilename = "icons/abp-16.png" | 148 tab.browserAction.setIcon(status.icon); |
114 else | |
115 iconFilename = whitelisted ? "icons/abp-19-whitelisted.png" : "icons/abp-19.
png"; | |
116 | 149 |
117 tab.browserAction.setIcon(iconFilename); | 150 // show or hide the context menu entry dependent on whether |
118 iconAnimation.registerTab(tab, iconFilename); | 151 // adblocking is active in that tab |
119 | 152 if (status.whitelisted || !/^https?:/.test(tab.url)) |
120 // Set context menu status according to whether current tab has whitelisted do
main | |
121 if (whitelisted || !/^https?:/.test(tab.url)) | |
122 ext.contextMenus.hideMenuItems(); | 153 ext.contextMenus.hideMenuItems(); |
123 else | 154 else |
124 ext.contextMenus.showMenuItems(); | 155 ext.contextMenus.showMenuItems(); |
125 } | 156 } |
126 | 157 |
127 /** | 158 /** |
128 * Old versions for Opera stored patterns.ini in the localStorage object, this | 159 * Old versions for Opera stored patterns.ini in the localStorage object, this |
129 * will import it into FilterStorage properly. | 160 * will import it into FilterStorage properly. |
130 * @return {Boolean} true if data import is in progress | 161 * @return {Boolean} true if data import is in progress |
131 */ | 162 */ |
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
496 tab.sendMessage({type: "clickhide-deactivate"}); | 527 tab.sendMessage({type: "clickhide-deactivate"}); |
497 refreshIconAndContextMenu(tab); | 528 refreshIconAndContextMenu(tab); |
498 }); | 529 }); |
499 | 530 |
500 setTimeout(function() | 531 setTimeout(function() |
501 { | 532 { |
502 var notificationToShow = Notification.getNextToShow(); | 533 var notificationToShow = Notification.getNextToShow(); |
503 if (notificationToShow) | 534 if (notificationToShow) |
504 showNotification(notificationToShow); | 535 showNotification(notificationToShow); |
505 }, 3 * 60 * 1000); | 536 }, 3 * 60 * 1000); |
OLD | NEW |