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 719 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
730 } | 730 } |
731 } | 731 } |
732 else | 732 else |
733 { | 733 { |
734 // Edge does not yet support runtime.openOptionsPage (tested version 38) | 734 // Edge does not yet support runtime.openOptionsPage (tested version 38) |
735 // nor does Firefox for Android, | 735 // nor does Firefox for Android, |
736 // and so this workaround needs to stay for now. | 736 // and so this workaround needs to stay for now. |
737 // We are not using extension.getURL to get the absolute path here | 737 // We are not using extension.getURL to get the absolute path here |
738 // because of the Edge issue: | 738 // because of the Edge issue: |
739 // https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/10
276332/ | 739 // https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/10
276332/ |
740 let open = win => | |
741 { | |
742 let optionsUrl = "options.html"; | |
743 let queryInfo = {url: optionsUrl}; | |
744 | |
745 // extension pages can't be accessed in incognito windows. In order to | |
746 // correctly mimic the way in which Chrome opens extension options, | |
747 // we have to focus the options page in any other window. | |
748 if (win && !win.incognito) | |
749 queryInfo.windowId = win.id; | |
750 | |
751 chrome.tabs.query(queryInfo, tabs => | |
752 { | |
753 if (tabs && tabs.length > 0) | |
754 { | |
755 let tab = tabs[0]; | |
756 | |
757 if ("windows" in chrome) | |
758 chrome.windows.update(tab.windowId, {focused: true}); | |
759 | |
760 chrome.tabs.update(tab.id, {active: true}); | |
761 | |
762 if (callback) | |
763 callback(new Page(tab)); | |
764 } | |
765 else | |
766 { | |
767 ext.pages.open(optionsUrl, callback); | |
768 } | |
769 }); | |
770 }; | |
771 | |
772 if ("windows" in chrome) | 740 if ("windows" in chrome) |
773 { | 741 { |
774 chrome.windows.getLastFocused(open); | 742 chrome.windows.getLastFocused(win => |
| 743 { |
| 744 let optionsUrl = "options.html"; |
| 745 let queryInfo = {url: optionsUrl}; |
| 746 |
| 747 // extension pages can't be accessed in incognito windows. In order to |
| 748 // correctly mimic the way in which Chrome opens extension options, |
| 749 // we have to focus the options page in any other window. |
| 750 if (!win.incognito) |
| 751 queryInfo.windowId = win.id; |
| 752 |
| 753 chrome.tabs.query(queryInfo, tabs => |
| 754 { |
| 755 if (tabs && tabs.length > 0) |
| 756 { |
| 757 let tab = tabs[0]; |
| 758 |
| 759 if ("windows" in chrome) |
| 760 chrome.windows.update(tab.windowId, {focused: true}); |
| 761 |
| 762 chrome.tabs.update(tab.id, {active: true}); |
| 763 |
| 764 if (callback) |
| 765 callback(new Page(tab)); |
| 766 } |
| 767 else |
| 768 { |
| 769 ext.pages.open(optionsUrl, callback); |
| 770 } |
| 771 }); |
| 772 }); |
775 } | 773 } |
776 else | 774 else |
777 { | 775 { |
778 // Firefox for Android does not support the windows API. Since there is | 776 // Firefox for Android does not support the windows API. Since there is |
779 // effectively only one window on the mobile browser, there's no need | 777 // effectively only one window on the mobile browser, there's no need |
780 // to bring it into focus. | 778 // to bring it into focus. |
781 open(); | 779 ext.pages.open("options.html", callback); |
782 } | 780 } |
783 } | 781 } |
784 }; | 782 }; |
785 | 783 |
786 /* Windows */ | 784 /* Windows */ |
787 ext.windows = { | 785 ext.windows = { |
788 create(createData, callback) | 786 create(createData, callback) |
789 { | 787 { |
790 chrome.windows.create(createData, createdWindow => | 788 chrome.windows.create(createData, createdWindow => |
791 { | 789 { |
792 afterTabLoaded(callback)(createdWindow.tabs[0]); | 790 afterTabLoaded(callback)(createdWindow.tabs[0]); |
793 }); | 791 }); |
794 } | 792 } |
795 }; | 793 }; |
796 }()); | 794 }()); |
OLD | NEW |