| OLD | NEW | 
|    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-present eyeo GmbH |    3  * Copyright (C) 2006-present 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 500 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  511   /* Web requests */ |  511   /* Web requests */ | 
|  512  |  512  | 
|  513   let framesOfTabs = new Map(); |  513   let framesOfTabs = new Map(); | 
|  514  |  514  | 
|  515   ext.getFrame = (tabId, frameId) => |  515   ext.getFrame = (tabId, frameId) => | 
|  516   { |  516   { | 
|  517     let frames = framesOfTabs.get(tabId); |  517     let frames = framesOfTabs.get(tabId); | 
|  518     return frames && frames.get(frameId); |  518     return frames && frames.get(frameId); | 
|  519   }; |  519   }; | 
|  520  |  520  | 
|  521   let handlerBehaviorChangedQuota = |  | 
|  522     browser.webRequest.MAX_HANDLER_BEHAVIOR_CHANGED_CALLS_PER_10_MINUTES; |  | 
|  523  |  | 
|  524   function propagateHandlerBehaviorChange() |  | 
|  525   { |  | 
|  526     // Make sure to not call handlerBehaviorChanged() more often than allowed |  | 
|  527     // by browser.webRequest.MAX_HANDLER_BEHAVIOR_CHANGED_CALLS_PER_10_MINUTES. |  | 
|  528     // Otherwise Chrome notifies the user that this extension is causing issues. |  | 
|  529     if (handlerBehaviorChangedQuota > 0) |  | 
|  530     { |  | 
|  531       browser.webNavigation.onBeforeNavigate.removeListener( |  | 
|  532         propagateHandlerBehaviorChange |  | 
|  533       ); |  | 
|  534       browser.webRequest.handlerBehaviorChanged(); |  | 
|  535  |  | 
|  536       handlerBehaviorChangedQuota--; |  | 
|  537       setTimeout(() => { handlerBehaviorChangedQuota++; }, 600000); |  | 
|  538     } |  | 
|  539   } |  | 
|  540  |  | 
|  541   ext.webRequest = { |  | 
|  542     handlerBehaviorChanged() |  | 
|  543     { |  | 
|  544       // Defer handlerBehaviorChanged() until navigation occurs. |  | 
|  545       // There wouldn't be any visible effect when calling it earlier, |  | 
|  546       // but it's an expensive operation and that way we avoid to call |  | 
|  547       // it multiple times, if multiple filters are added/removed. |  | 
|  548       let {onBeforeNavigate} = browser.webNavigation; |  | 
|  549       if (!onBeforeNavigate.hasListener(propagateHandlerBehaviorChange)) |  | 
|  550         onBeforeNavigate.addListener(propagateHandlerBehaviorChange); |  | 
|  551     } |  | 
|  552   }; |  | 
|  553  |  | 
|  554   browser.tabs.query({}, tabs => |  521   browser.tabs.query({}, tabs => | 
|  555   { |  522   { | 
|  556     tabs.forEach(tab => |  523     tabs.forEach(tab => | 
|  557     { |  524     { | 
|  558       browser.webNavigation.getAllFrames({tabId: tab.id}, details => |  525       browser.webNavigation.getAllFrames({tabId: tab.id}, details => | 
|  559       { |  526       { | 
|  560         if (details && details.length > 0) |  527         if (details && details.length > 0) | 
|  561         { |  528         { | 
|  562           let frames = new Map(); |  529           let frames = new Map(); | 
|  563           framesOfTabs.set(tab.id, frames); |  530           framesOfTabs.set(tab.id, frames); | 
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  638   ext.windows = { |  605   ext.windows = { | 
|  639     create(createData, callback) |  606     create(createData, callback) | 
|  640     { |  607     { | 
|  641       browser.windows.create(createData, createdWindow => |  608       browser.windows.create(createData, createdWindow => | 
|  642       { |  609       { | 
|  643         afterTabLoaded(callback)(createdWindow.tabs[0]); |  610         afterTabLoaded(callback)(createdWindow.tabs[0]); | 
|  644       }); |  611       }); | 
|  645     } |  612     } | 
|  646   }; |  613   }; | 
|  647 } |  614 } | 
| OLD | NEW |