| 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 299 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 310   chrome.tabs.onRemoved.addListener(forgetTab); | 310   chrome.tabs.onRemoved.addListener(forgetTab); | 
| 311 | 311 | 
| 312   chrome.tabs.onActivated.addListener(details => | 312   chrome.tabs.onActivated.addListener(details => | 
| 313   { | 313   { | 
| 314     ext.pages.onActivated._dispatch(new Page({id: details.tabId})); | 314     ext.pages.onActivated._dispatch(new Page({id: details.tabId})); | 
| 315   }); | 315   }); | 
| 316 | 316 | 
| 317 | 317 | 
| 318   /* Browser actions */ | 318   /* Browser actions */ | 
| 319 | 319 | 
| 320   // On Firefox for Android, open the options page directly when the browser |  | 
| 321   // action is clicked. |  | 
| 322   if (!("getPopup" in chrome.browserAction)) |  | 
| 323   { |  | 
| 324     chrome.browserAction.onClicked.addListener(() => |  | 
| 325     { |  | 
| 326       ext.showOptions(); |  | 
| 327     }); |  | 
| 328   } |  | 
| 329 |  | 
| 330   let BrowserAction = function(tabId) | 320   let BrowserAction = function(tabId) | 
| 331   { | 321   { | 
| 332     this._tabId = tabId; | 322     this._tabId = tabId; | 
| 333     this._changes = null; | 323     this._changes = null; | 
| 334   }; | 324   }; | 
| 335   BrowserAction.prototype = { | 325   BrowserAction.prototype = { | 
| 336     _applyChanges() | 326     _applyChanges() | 
| 337     { | 327     { | 
| 338       if ("iconPath" in this._changes) | 328       if ("iconPath" in this._changes) | 
| 339       { | 329       { | 
| (...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 695     onChanged: chrome.storage.onChanged | 685     onChanged: chrome.storage.onChanged | 
| 696   }; | 686   }; | 
| 697 | 687 | 
| 698   /* Options */ | 688   /* Options */ | 
| 699 | 689 | 
| 700   ext.showOptions = callback => | 690   ext.showOptions = callback => | 
| 701   { | 691   { | 
| 702     let info = require("info"); | 692     let info = require("info"); | 
| 703 | 693 | 
| 704     if ("openOptionsPage" in chrome.runtime && | 694     if ("openOptionsPage" in chrome.runtime && | 
| 705         // Some versions of Firefox for Android before version 57 do have a | 695         // We don't use runtime.openOptionsPage on Firefox for Android because | 
| 706         // runtime.openOptionsPage but it doesn't do anything. | 696         // we have a different options page for mobile. | 
| 707         // https://bugzilla.mozilla.org/show_bug.cgi?id=1364945 | 697         info.application != "fennec") | 
| 708         (info.application != "fennec" || |  | 
| 709          parseInt(info.applicationVersion, 10) >= 57)) |  | 
| 710     { | 698     { | 
| 711       if (!callback) | 699       if (!callback) | 
| 712       { | 700       { | 
| 713         chrome.runtime.openOptionsPage(); | 701         chrome.runtime.openOptionsPage(); | 
| 714       } | 702       } | 
| 715       else | 703       else | 
| 716       { | 704       { | 
| 717         chrome.runtime.openOptionsPage(() => | 705         chrome.runtime.openOptionsPage(() => | 
| 718         { | 706         { | 
| 719           if (chrome.runtime.lastError) | 707           if (chrome.runtime.lastError) | 
| 720             return; | 708             return; | 
| 721 | 709 | 
| 722           chrome.tabs.query({active: true, lastFocusedWindow: true}, tabs => | 710           chrome.tabs.query({active: true, lastFocusedWindow: true}, tabs => | 
| 723           { | 711           { | 
| 724             if (tabs.length > 0) | 712             if (tabs.length > 0) | 
| 725             { | 713             { | 
| 726               if (tabs[0].status == "complete") | 714               if (tabs[0].status == "complete") | 
| 727                 callback(new Page(tabs[0])); | 715                 callback(new Page(tabs[0])); | 
| 728               else | 716               else | 
| 729                 afterTabLoaded(callback)(tabs[0]); | 717                 afterTabLoaded(callback)(tabs[0]); | 
| 730             } | 718             } | 
| 731           }); | 719           }); | 
| 732         }); | 720         }); | 
| 733       } | 721       } | 
| 734     } | 722     } | 
| 735     else if ("windows" in chrome) | 723     else | 
| 736     { | 724     { | 
| 737       // Edge does not yet support runtime.openOptionsPage (tested version 38) | 725       // Edge does not yet support runtime.openOptionsPage (tested version 38) | 
| 738       // and so this workaround needs to stay for now. |  | 
| 739       // We are not using extension.getURL to get the absolute path here |  | 
| 740       // because of the Edge issue: |  | 
| 741       // https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/10
     276332/ |  | 
| 742       let optionsUrl = "options.html"; | 726       let optionsUrl = "options.html"; | 
| 743       let fullOptionsUrl = ext.getURL(optionsUrl); | 727 | 
|  | 728       // Firefox for Android has its own options page. | 
|  | 729       if (info.application == "fennec") | 
|  | 730         optionsUrl = "mobile-options.html"; | 
| 744 | 731 | 
| 745       chrome.tabs.query({}, tabs => | 732       chrome.tabs.query({}, tabs => | 
| 746       { | 733       { | 
| 747         // We find a tab ourselves because Edge has a bug when quering tabs | 734         // We find a tab ourselves because Edge has a bug when quering tabs | 
| 748         // with extension URL protocol: | 735         // with extension URL protocol: | 
| 749         // https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/
     8094141/ | 736         // https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/
     8094141/ | 
| 750         // https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/
     8604703/ | 737         // https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/
     8604703/ | 
|  | 738         // Firefox won't let us query for moz-extension:// pages either, though | 
|  | 739         // starting with Firefox 56 an extension can query for its own URLs: | 
|  | 740         // https://bugzilla.mozilla.org/show_bug.cgi?id=1271354 | 
|  | 741         let fullOptionsUrl = ext.getURL(optionsUrl); | 
| 751         let tab = tabs.find(element => element.url == fullOptionsUrl); | 742         let tab = tabs.find(element => element.url == fullOptionsUrl); | 
| 752         if (tab) | 743         if (tab) | 
| 753         { | 744         { | 
| 754           chrome.windows.update(tab.windowId, {focused: true}); | 745           // Firefox for Android doesn't support the windows API, and the | 
|  | 746           // mobile browser has only one window anyway. | 
|  | 747           if ("windows" in chrome) | 
|  | 748             chrome.windows.update(tab.windowId, {focused: true}); | 
|  | 749 | 
| 755           chrome.tabs.update(tab.id, {active: true}); | 750           chrome.tabs.update(tab.id, {active: true}); | 
| 756 | 751 | 
| 757           if (callback) | 752           if (callback) | 
| 758             callback(new Page(tab)); | 753             callback(new Page(tab)); | 
| 759         } | 754         } | 
| 760         else | 755         else | 
| 761         { | 756         { | 
|  | 757           // We don't use fullOptionsUrl here because of this Edge issue: | 
|  | 758           // https://developer.microsoft.com/en-us/microsoft-edge/platform/issue
     s/10276332 | 
| 762           ext.pages.open(optionsUrl, callback); | 759           ext.pages.open(optionsUrl, callback); | 
| 763         } | 760         } | 
| 764       }); | 761       }); | 
| 765     } | 762     } | 
| 766     else |  | 
| 767     { |  | 
| 768       // Firefox for Android before version 57 does not support |  | 
| 769       // runtime.openOptionsPage, nor does it support the windows API. Since |  | 
| 770       // there is effectively only one window on the mobile browser, there's no |  | 
| 771       // need to bring it into focus. |  | 
| 772       ext.pages.open("options.html", callback); |  | 
| 773     } |  | 
| 774   }; | 763   }; | 
| 775 | 764 | 
| 776   /* Windows */ | 765   /* Windows */ | 
| 777   ext.windows = { | 766   ext.windows = { | 
| 778     create(createData, callback) | 767     create(createData, callback) | 
| 779     { | 768     { | 
| 780       chrome.windows.create(createData, createdWindow => | 769       chrome.windows.create(createData, createdWindow => | 
| 781       { | 770       { | 
| 782         afterTabLoaded(callback)(createdWindow.tabs[0]); | 771         afterTabLoaded(callback)(createdWindow.tabs[0]); | 
| 783       }); | 772       }); | 
| 784     } | 773     } | 
| 785   }; | 774   }; | 
| 786 }()); | 775 }()); | 
| OLD | NEW | 
|---|