| 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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 */ | 110 */ |
| 111 knownSubscriptions: {__proto__: null}, | 111 knownSubscriptions: {__proto__: null}, |
| 112 | 112 |
| 113 /** | 113 /** |
| 114 * Finds the filter group that a filter should be added to by default. Will | 114 * Finds the filter group that a filter should be added to by default. Will |
| 115 * return null if this group doesn't exist yet. | 115 * return null if this group doesn't exist yet. |
| 116 */ | 116 */ |
| 117 getGroupForFilter: function(/**Filter*/ filter) /**SpecialSubscription*/ | 117 getGroupForFilter: function(/**Filter*/ filter) /**SpecialSubscription*/ |
| 118 { | 118 { |
| 119 let generalSubscription = null; | 119 let generalSubscription = null; |
| 120 for each (let subscription in FilterStorage.subscriptions) | 120 for (let subscription of FilterStorage.subscriptions) |
| 121 { | 121 { |
| 122 if (subscription instanceof SpecialSubscription && !subscription.disabled) | 122 if (subscription instanceof SpecialSubscription && !subscription.disabled) |
| 123 { | 123 { |
| 124 // Always prefer specialized subscriptions | 124 // Always prefer specialized subscriptions |
| 125 if (subscription.isDefaultFor(filter)) | 125 if (subscription.isDefaultFor(filter)) |
| 126 return subscription; | 126 return subscription; |
| 127 | 127 |
| 128 // If this is a general subscription - store it as fallback | 128 // If this is a general subscription - store it as fallback |
| 129 if (!generalSubscription && (!subscription.defaults || !subscription.def
aults.length)) | 129 if (!generalSubscription && (!subscription.defaults || !subscription.def
aults.length)) |
| 130 generalSubscription = subscription; | 130 generalSubscription = subscription; |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 * @param {Array of Filter} filters filters to be reset, if null all filters
will be reset | 340 * @param {Array of Filter} filters filters to be reset, if null all filters
will be reset |
| 341 */ | 341 */ |
| 342 resetHitCounts: function(filters) | 342 resetHitCounts: function(filters) |
| 343 { | 343 { |
| 344 if (!filters) | 344 if (!filters) |
| 345 { | 345 { |
| 346 filters = []; | 346 filters = []; |
| 347 for (let text in Filter.knownFilters) | 347 for (let text in Filter.knownFilters) |
| 348 filters.push(Filter.knownFilters[text]); | 348 filters.push(Filter.knownFilters[text]); |
| 349 } | 349 } |
| 350 for each (let filter in filters) | 350 for (let filter of filters) |
| 351 { | 351 { |
| 352 filter.hitCount = 0; | 352 filter.hitCount = 0; |
| 353 filter.lastHit = 0; | 353 filter.lastHit = 0; |
| 354 } | 354 } |
| 355 }, | 355 }, |
| 356 | 356 |
| 357 _loading: false, | 357 _loading: false, |
| 358 | 358 |
| 359 /** | 359 /** |
| 360 * Loads all subscriptions from the disk | 360 * Loads all subscriptions from the disk |
| (...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 688 | 688 |
| 689 /** | 689 /** |
| 690 * Joins subscription's filters to the subscription without any notifications. | 690 * Joins subscription's filters to the subscription without any notifications. |
| 691 * @param {Subscription} subscription filter subscription that should be connect
ed to its filters | 691 * @param {Subscription} subscription filter subscription that should be connect
ed to its filters |
| 692 */ | 692 */ |
| 693 function addSubscriptionFilters(subscription) | 693 function addSubscriptionFilters(subscription) |
| 694 { | 694 { |
| 695 if (!(subscription.url in FilterStorage.knownSubscriptions)) | 695 if (!(subscription.url in FilterStorage.knownSubscriptions)) |
| 696 return; | 696 return; |
| 697 | 697 |
| 698 for each (let filter in subscription.filters) | 698 for (let filter of subscription.filters) |
| 699 filter.subscriptions.push(subscription); | 699 filter.subscriptions.push(subscription); |
| 700 } | 700 } |
| 701 | 701 |
| 702 /** | 702 /** |
| 703 * Removes subscription's filters from the subscription without any notification
s. | 703 * Removes subscription's filters from the subscription without any notification
s. |
| 704 * @param {Subscription} subscription filter subscription to be removed | 704 * @param {Subscription} subscription filter subscription to be removed |
| 705 */ | 705 */ |
| 706 function removeSubscriptionFilters(subscription) | 706 function removeSubscriptionFilters(subscription) |
| 707 { | 707 { |
| 708 if (!(subscription.url in FilterStorage.knownSubscriptions)) | 708 if (!(subscription.url in FilterStorage.knownSubscriptions)) |
| 709 return; | 709 return; |
| 710 | 710 |
| 711 for each (let filter in subscription.filters) | 711 for (let filter of subscription.filters) |
| 712 { | 712 { |
| 713 let i = filter.subscriptions.indexOf(subscription); | 713 let i = filter.subscriptions.indexOf(subscription); |
| 714 if (i >= 0) | 714 if (i >= 0) |
| 715 filter.subscriptions.splice(i, 1); | 715 filter.subscriptions.splice(i, 1); |
| 716 } | 716 } |
| 717 } | 717 } |
| 718 | 718 |
| 719 /** | 719 /** |
| 720 * Observer listening to private browsing mode changes. | 720 * Observer listening to private browsing mode changes. |
| 721 * @class | 721 * @class |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 832 case "subscription": | 832 case "subscription": |
| 833 let subscription = Subscription.fromObject(this.curObj); | 833 let subscription = Subscription.fromObject(this.curObj); |
| 834 if (subscription) | 834 if (subscription) |
| 835 this.subscriptions.push(subscription); | 835 this.subscriptions.push(subscription); |
| 836 break; | 836 break; |
| 837 case "subscription filters": | 837 case "subscription filters": |
| 838 case "subscription patterns": | 838 case "subscription patterns": |
| 839 if (this.subscriptions.length) | 839 if (this.subscriptions.length) |
| 840 { | 840 { |
| 841 let subscription = this.subscriptions[this.subscriptions.length
- 1]; | 841 let subscription = this.subscriptions[this.subscriptions.length
- 1]; |
| 842 for each (let text in this.curObj) | 842 for (let text of this.curObj) |
| 843 { | 843 { |
| 844 let filter = Filter.fromText(text); | 844 let filter = Filter.fromText(text); |
| 845 subscription.filters.push(filter); | 845 subscription.filters.push(filter); |
| 846 filter.subscriptions.push(subscription); | 846 filter.subscriptions.push(subscription); |
| 847 } | 847 } |
| 848 } | 848 } |
| 849 break; | 849 break; |
| 850 case "user patterns": | 850 case "user patterns": |
| 851 this.userFilters = this.curObj; | 851 this.userFilters = this.curObj; |
| 852 break; | 852 break; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 885 Subscription.knownSubscriptions = origKnownSubscriptions; | 885 Subscription.knownSubscriptions = origKnownSubscriptions; |
| 886 } | 886 } |
| 887 | 887 |
| 888 // Allow events to be processed every now and then. | 888 // Allow events to be processed every now and then. |
| 889 // Note: IO.readFromFile() will deal with the potential reentrance here. | 889 // Note: IO.readFromFile() will deal with the potential reentrance here. |
| 890 this.linesProcessed++; | 890 this.linesProcessed++; |
| 891 if (this.linesProcessed % 1000 == 0) | 891 if (this.linesProcessed % 1000 == 0) |
| 892 Utils.yield(); | 892 Utils.yield(); |
| 893 } | 893 } |
| 894 }; | 894 }; |
| OLD | NEW |