| Left: | ||
| Right: |
| 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-2017 eyeo GmbH | 3 * Copyright (C) 2006-2017 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 48 for (let page of pages) | 48 for (let page of pages) |
| 49 page.browserAction.setBadge(); | 49 page.browserAction.setBadge(); |
| 50 }); | 50 }); |
| 51 } | 51 } |
| 52 | 52 |
| 53 function setContentBlocker() | 53 function setContentBlocker() |
| 54 { | 54 { |
| 55 return new Promise((resolve, reject) => | 55 return new Promise((resolve, reject) => |
| 56 { | 56 { |
| 57 // Reset state and either fulfill or reject this promise. | 57 // Reset state and either fulfill or reject this promise. |
| 58 let completePromise = error => | 58 function completePromise(error) |
|
kzar
2017/08/21 12:30:12
Nit: Since this is a named function maybe just use
Manish Jethani
2017/08/21 14:17:04
Done.
| |
| 59 { | 59 { |
| 60 lastSetContentBlockerError = error; | 60 lastSetContentBlockerError = error; |
| 61 contentBlockListDirty = false; | 61 contentBlockListDirty = false; |
| 62 | 62 |
| 63 if (error instanceof Error) | 63 if (error instanceof Error) |
| 64 reject(error); | 64 reject(error); |
| 65 else | 65 else |
| 66 resolve(); | 66 resolve(); |
| 67 }; | 67 } |
| 68 | 68 |
| 69 // When given the same rules as last time setContentBlocker will always | 69 // When given the same rules as last time setContentBlocker will always |
| 70 // resolve with null (success), even when there was actually an | 70 // resolve with null (success), even when there was actually an |
| 71 // error. We cache the last result therefore so that we can provide a | 71 // error. We cache the last result therefore so that we can provide a |
| 72 // consistent result and also to avoid wastefully regenerating an identical | 72 // consistent result and also to avoid wastefully regenerating an identical |
| 73 // blocklist. | 73 // blocklist. |
| 74 if (!contentBlockListDirty) | 74 if (!contentBlockListDirty) |
| 75 { | 75 { |
| 76 completePromise(lastSetContentBlockerError); | 76 completePromise(lastSetContentBlockerError); |
| 77 return; | 77 return; |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 203 }); | 203 }); |
| 204 }); | 204 }); |
| 205 } | 205 } |
| 206 | 206 |
| 207 port.on("safari.contentBlockingActive", (msg, sender) => | 207 port.on("safari.contentBlockingActive", (msg, sender) => |
| 208 { | 208 { |
| 209 if (!contentBlockingActive && afterContentBlockingFinished) | 209 if (!contentBlockingActive && afterContentBlockingFinished) |
| 210 return afterContentBlockingFinished; | 210 return afterContentBlockingFinished; |
| 211 return contentBlockingActive; | 211 return contentBlockingActive; |
| 212 }); | 212 }); |
| LEFT | RIGHT |