| LEFT | RIGHT |
| 1 /* | 1 /* |
| 2 * This file is part of Adblock Plus <https://adblockplus.org/>, | 2 * This file is part of Adblock Plus <https://adblockplus.org/>, |
| 3 * Copyright (C) 2006-2016 Eyeo GmbH | 3 * Copyright (C) 2006-2016 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 |
| 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 * GNU General Public License for more details. | 12 * GNU General Public License for more details. |
| 13 * | 13 * |
| 14 * You should have received a copy of the GNU General Public License | 14 * You should have received a copy of the GNU General Public License |
| 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. | 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
| 16 */ | 16 */ |
| 17 | 17 |
| 18 /** | 18 /** |
| 19 * @fileOverview Definition of Subscription class and its subclasses. | 19 * @fileOverview Definition of Subscription class and its subclasses. |
| 20 */ | 20 */ |
| 21 | 21 |
| 22 let {ActiveFilter, BlockingFilter, WhitelistFilter, ElemHideBase} = require("fil
terClasses"); | 22 let {ActiveFilter, BlockingFilter, WhitelistFilter, ElemHideBase} = require("fil
terClasses"); |
| 23 let {FilterNotifier} = require("filterNotifier"); | 23 let {FilterNotifier} = require("filterNotifier"); |
| 24 let {desc} = require("coreUtils"); | 24 let {desc, extend} = require("coreUtils"); |
| 25 | 25 |
| 26 /** | 26 /** |
| 27 * Abstract base class for filter subscriptions | 27 * Abstract base class for filter subscriptions |
| 28 * | 28 * |
| 29 * @param {String} url download location of the subscription | 29 * @param {String} url download location of the subscription |
| 30 * @param {String} [title] title of the filter subscription | 30 * @param {String} [title] title of the filter subscription |
| 31 * @constructor | 31 * @constructor |
| 32 */ | 32 */ |
| 33 function Subscription(url, title) | 33 function Subscription(url, title) |
| 34 { | 34 { |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 * @param {String} [title] see Subscription() | 223 * @param {String} [title] see Subscription() |
| 224 * @constructor | 224 * @constructor |
| 225 * @augments Subscription | 225 * @augments Subscription |
| 226 */ | 226 */ |
| 227 function SpecialSubscription(url, title) | 227 function SpecialSubscription(url, title) |
| 228 { | 228 { |
| 229 Subscription.call(this, url, title); | 229 Subscription.call(this, url, title); |
| 230 } | 230 } |
| 231 exports.SpecialSubscription = SpecialSubscription; | 231 exports.SpecialSubscription = SpecialSubscription; |
| 232 | 232 |
| 233 SpecialSubscription.prototype = Object.create(Subscription.prototype, desc({ | 233 SpecialSubscription.prototype = extend(Subscription, { |
| 234 /** | 234 /** |
| 235 * Filter types that should be added to this subscription by default | 235 * Filter types that should be added to this subscription by default |
| 236 * (entries should correspond to keys in SpecialSubscription.defaultsMap). | 236 * (entries should correspond to keys in SpecialSubscription.defaultsMap). |
| 237 * @type string[] | 237 * @type string[] |
| 238 */ | 238 */ |
| 239 defaults: null, | 239 defaults: null, |
| 240 | 240 |
| 241 /** | 241 /** |
| 242 * Tests whether a filter should be added to this group by default | 242 * Tests whether a filter should be added to this group by default |
| 243 * @param {Filter} filter filter to be tested | 243 * @param {Filter} filter filter to be tested |
| (...skipping 19 matching lines...) Expand all Loading... |
| 263 * See Subscription.serialize() | 263 * See Subscription.serialize() |
| 264 */ | 264 */ |
| 265 serialize: function(buffer) | 265 serialize: function(buffer) |
| 266 { | 266 { |
| 267 Subscription.prototype.serialize.call(this, buffer); | 267 Subscription.prototype.serialize.call(this, buffer); |
| 268 if (this.defaults && this.defaults.length) | 268 if (this.defaults && this.defaults.length) |
| 269 buffer.push("defaults=" + this.defaults.filter((type) => type in SpecialSu
bscription.defaultsMap).join(" ")); | 269 buffer.push("defaults=" + this.defaults.filter((type) => type in SpecialSu
bscription.defaultsMap).join(" ")); |
| 270 if (this._lastDownload) | 270 if (this._lastDownload) |
| 271 buffer.push("lastDownload=" + this._lastDownload); | 271 buffer.push("lastDownload=" + this._lastDownload); |
| 272 } | 272 } |
| 273 })); | 273 }); |
| 274 | 274 |
| 275 SpecialSubscription.defaultsMap = Object.create(null, desc({ | 275 SpecialSubscription.defaultsMap = Object.create(null, desc({ |
| 276 "whitelist": WhitelistFilter, | 276 "whitelist": WhitelistFilter, |
| 277 "blocking": BlockingFilter, | 277 "blocking": BlockingFilter, |
| 278 "elemhide": ElemHideBase | 278 "elemhide": ElemHideBase |
| 279 })); | 279 })); |
| 280 | 280 |
| 281 /** | 281 /** |
| 282 * Creates a new user-defined filter group. | 282 * Creates a new user-defined filter group. |
| 283 * @param {String} [title] title of the new filter group | 283 * @param {String} [title] title of the new filter group |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 317 * @param {String} [title] see Subscription() | 317 * @param {String} [title] see Subscription() |
| 318 * @constructor | 318 * @constructor |
| 319 * @augments Subscription | 319 * @augments Subscription |
| 320 */ | 320 */ |
| 321 function RegularSubscription(url, title) | 321 function RegularSubscription(url, title) |
| 322 { | 322 { |
| 323 Subscription.call(this, url, title || url); | 323 Subscription.call(this, url, title || url); |
| 324 } | 324 } |
| 325 exports.RegularSubscription = RegularSubscription; | 325 exports.RegularSubscription = RegularSubscription; |
| 326 | 326 |
| 327 RegularSubscription.prototype = Object.create(Subscription.prototype, desc({ | 327 RegularSubscription.prototype = extend(Subscription, { |
| 328 _homepage: null, | 328 _homepage: null, |
| 329 _lastDownload: 0, | 329 _lastDownload: 0, |
| 330 | 330 |
| 331 /** | 331 /** |
| 332 * Filter subscription homepage if known | 332 * Filter subscription homepage if known |
| 333 * @type String | 333 * @type String |
| 334 */ | 334 */ |
| 335 get homepage() | 335 get homepage() |
| 336 { | 336 { |
| 337 return this._homepage; | 337 return this._homepage; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 * See Subscription.serialize() | 370 * See Subscription.serialize() |
| 371 */ | 371 */ |
| 372 serialize: function(buffer) | 372 serialize: function(buffer) |
| 373 { | 373 { |
| 374 Subscription.prototype.serialize.call(this, buffer); | 374 Subscription.prototype.serialize.call(this, buffer); |
| 375 if (this._homepage) | 375 if (this._homepage) |
| 376 buffer.push("homepage=" + this._homepage); | 376 buffer.push("homepage=" + this._homepage); |
| 377 if (this._lastDownload) | 377 if (this._lastDownload) |
| 378 buffer.push("lastDownload=" + this._lastDownload); | 378 buffer.push("lastDownload=" + this._lastDownload); |
| 379 } | 379 } |
| 380 })); | 380 }); |
| 381 | 381 |
| 382 /** | 382 /** |
| 383 * Class for filter subscriptions updated externally (by other extension) | 383 * Class for filter subscriptions updated externally (by other extension) |
| 384 * @param {String} url see Subscription() | 384 * @param {String} url see Subscription() |
| 385 * @param {String} [title] see Subscription() | 385 * @param {String} [title] see Subscription() |
| 386 * @constructor | 386 * @constructor |
| 387 * @augments RegularSubscription | 387 * @augments RegularSubscription |
| 388 */ | 388 */ |
| 389 function ExternalSubscription(url, title) | 389 function ExternalSubscription(url, title) |
| 390 { | 390 { |
| 391 RegularSubscription.call(this, url, title); | 391 RegularSubscription.call(this, url, title); |
| 392 } | 392 } |
| 393 exports.ExternalSubscription = ExternalSubscription; | 393 exports.ExternalSubscription = ExternalSubscription; |
| 394 | 394 |
| 395 ExternalSubscription.prototype = Object.create(RegularSubscription.prototype, de
sc({ | 395 ExternalSubscription.prototype = extend(RegularSubscription, { |
| 396 /** | 396 /** |
| 397 * See Subscription.serialize() | 397 * See Subscription.serialize() |
| 398 */ | 398 */ |
| 399 serialize: function(buffer) | 399 serialize: function(buffer) |
| 400 { | 400 { |
| 401 throw new Error("Unexpected call, external subscriptions should not be seria
lized"); | 401 throw new Error("Unexpected call, external subscriptions should not be seria
lized"); |
| 402 } | 402 } |
| 403 })); | 403 }); |
| 404 | 404 |
| 405 /** | 405 /** |
| 406 * Class for filter subscriptions updated externally (by other extension) | 406 * Class for filter subscriptions updated externally (by other extension) |
| 407 * @param {String} url see Subscription() | 407 * @param {String} url see Subscription() |
| 408 * @param {String} [title] see Subscription() | 408 * @param {String} [title] see Subscription() |
| 409 * @constructor | 409 * @constructor |
| 410 * @augments RegularSubscription | 410 * @augments RegularSubscription |
| 411 */ | 411 */ |
| 412 function DownloadableSubscription(url, title) | 412 function DownloadableSubscription(url, title) |
| 413 { | 413 { |
| 414 RegularSubscription.call(this, url, title); | 414 RegularSubscription.call(this, url, title); |
| 415 } | 415 } |
| 416 exports.DownloadableSubscription = DownloadableSubscription; | 416 exports.DownloadableSubscription = DownloadableSubscription; |
| 417 | 417 |
| 418 DownloadableSubscription.prototype = Object.create(RegularSubscription.prototype
, desc({ | 418 DownloadableSubscription.prototype = extend(RegularSubscription, { |
| 419 _downloadStatus: null, | 419 _downloadStatus: null, |
| 420 _lastCheck: 0, | 420 _lastCheck: 0, |
| 421 _errors: 0, | 421 _errors: 0, |
| 422 | 422 |
| 423 /** | 423 /** |
| 424 * Status of the last download (ID of a string) | 424 * Status of the last download (ID of a string) |
| 425 * @type String | 425 * @type String |
| 426 */ | 426 */ |
| 427 get downloadStatus() | 427 get downloadStatus() |
| 428 { | 428 { |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 530 buffer.push("softExpiration=" + this.softExpiration); | 530 buffer.push("softExpiration=" + this.softExpiration); |
| 531 if (this.errors) | 531 if (this.errors) |
| 532 buffer.push("errors=" + this.errors); | 532 buffer.push("errors=" + this.errors); |
| 533 if (this.version) | 533 if (this.version) |
| 534 buffer.push("version=" + this.version); | 534 buffer.push("version=" + this.version); |
| 535 if (this.requiredVersion) | 535 if (this.requiredVersion) |
| 536 buffer.push("requiredVersion=" + this.requiredVersion); | 536 buffer.push("requiredVersion=" + this.requiredVersion); |
| 537 if (this.downloadCount) | 537 if (this.downloadCount) |
| 538 buffer.push("downloadCount=" + this.downloadCount); | 538 buffer.push("downloadCount=" + this.downloadCount); |
| 539 } | 539 } |
| 540 })); | 540 }); |
| LEFT | RIGHT |