LEFT | RIGHT |
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 27 matching lines...) Expand all Loading... |
38 // Some types cannot be distinguished | 38 // Some types cannot be distinguished |
39 RegExpFilter.typeMap.OBJECT_SUBREQUEST = RegExpFilter.typeMap.OBJECT; | 39 RegExpFilter.typeMap.OBJECT_SUBREQUEST = RegExpFilter.typeMap.OBJECT; |
40 RegExpFilter.typeMap.MEDIA = RegExpFilter.typeMap.FONT = RegExpFilter.typeMap.OT
HER; | 40 RegExpFilter.typeMap.MEDIA = RegExpFilter.typeMap.FONT = RegExpFilter.typeMap.OT
HER; |
41 | 41 |
42 var isFirstRun = false; | 42 var isFirstRun = false; |
43 var seenDataCorruption = false; | 43 var seenDataCorruption = false; |
44 require("filterNotifier").FilterNotifier.addListener(function(action) | 44 require("filterNotifier").FilterNotifier.addListener(function(action) |
45 { | 45 { |
46 if (action == "load") | 46 if (action == "load") |
47 { | 47 { |
48 importOldData(); | 48 var importingOldData = importOldData(); |
49 | 49 |
50 var addonVersion = require("info").addonVersion; | 50 var addonVersion = require("info").addonVersion; |
51 var prevVersion = localStorage["currentVersion"]; | 51 var prevVersion = localStorage.currentVersion; |
52 if (prevVersion != addonVersion) | 52 if (prevVersion != addonVersion) |
53 { | 53 { |
54 isFirstRun = !prevVersion; | 54 isFirstRun = !prevVersion; |
55 localStorage["currentVersion"] = addonVersion; | 55 localStorage.currentVersion = addonVersion; |
56 addSubscription(prevVersion); | 56 if (!importingOldData) |
| 57 addSubscription(prevVersion); |
57 } | 58 } |
58 } | 59 } |
59 }); | 60 }); |
60 | 61 |
61 // Special-case domains for which we cannot use style-based hiding rules. | 62 // Special-case domains for which we cannot use style-based hiding rules. |
62 // See http://crbug.com/68705. | 63 // See http://crbug.com/68705. |
63 var noStyleRulesHosts = ["mail.google.com", "mail.yahoo.com", "www.google.com"]; | 64 var noStyleRulesHosts = ["mail.google.com", "mail.yahoo.com", "www.google.com"]; |
64 | 65 |
65 function removeDeprecatedOptions() | 66 function removeDeprecatedOptions() |
66 { | 67 { |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 // Set context menu status according to whether current tab has whitelisted
domain | 143 // Set context menu status according to whether current tab has whitelisted
domain |
143 if (excluded) | 144 if (excluded) |
144 chrome.contextMenus.removeAll(); | 145 chrome.contextMenus.removeAll(); |
145 else | 146 else |
146 showContextMenu(); | 147 showContextMenu(); |
147 } | 148 } |
148 | 149 |
149 /** | 150 /** |
150 * Old versions for Opera stored patterns.ini in the localStorage object, this | 151 * Old versions for Opera stored patterns.ini in the localStorage object, this |
151 * will import it into FilterStorage properly. | 152 * will import it into FilterStorage properly. |
| 153 * @return {Boolean} true if data import is in progress |
152 */ | 154 */ |
153 function importOldData() | 155 function importOldData() |
154 { | 156 { |
155 if ("patterns.ini" in localStorage) | 157 if ("patterns.ini" in localStorage) |
156 { | 158 { |
157 FilterStorage.loadFromDisk(localStorage["patterns.ini"]); | 159 FilterStorage.loadFromDisk(localStorage["patterns.ini"]); |
158 | 160 |
159 var remove = []; | 161 var remove = []; |
160 for (var key in localStorage) | 162 for (var key in localStorage) |
161 if (key.indexOf("patterns.ini") == 0 || key.indexOf("patterns-backup") ==
0) | 163 if (key.indexOf("patterns.ini") == 0 || key.indexOf("patterns-backup") ==
0) |
162 remove.push(key); | 164 remove.push(key); |
163 for (var i = 0; i < remove.length; i++) | 165 for (var i = 0; i < remove.length; i++) |
164 delete localStorage[remove[i]]; | 166 delete localStorage[remove[i]]; |
165 } | 167 |
| 168 return true; |
| 169 } |
| 170 else |
| 171 return false; |
166 } | 172 } |
167 | 173 |
168 /** | 174 /** |
169 * This function is called on an extension update. It will add the default | 175 * This function is called on an extension update. It will add the default |
170 * filter subscription if necessary. | 176 * filter subscription if necessary. |
171 */ | 177 */ |
172 function addSubscription(prevVersion) | 178 function addSubscription(prevVersion) |
173 { | 179 { |
174 // Make sure to remove "Recommended filters", no longer necessary | 180 // Make sure to remove "Recommended filters", no longer necessary |
175 var toRemove = "https://easylist-downloads.adblockplus.org/chrome_supplement.t
xt"; | 181 var toRemove = "https://easylist-downloads.adblockplus.org/chrome_supplement.t
xt"; |
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
455 tab.sendMessage({type: "clickhide-deactivate"}); | 461 tab.sendMessage({type: "clickhide-deactivate"}); |
456 refreshIconAndContextMenu(tab); | 462 refreshIconAndContextMenu(tab); |
457 }); | 463 }); |
458 | 464 |
459 setTimeout(function() | 465 setTimeout(function() |
460 { | 466 { |
461 var notificationToShow = Notification.getNextToShow(); | 467 var notificationToShow = Notification.getNextToShow(); |
462 if (notificationToShow) | 468 if (notificationToShow) |
463 showNotification(notificationToShow); | 469 showNotification(notificationToShow); |
464 }, 3 * 60 * 1000); | 470 }, 3 * 60 * 1000); |
LEFT | RIGHT |