Left: | ||
Right: |
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 => | 740 let optionsUrl = "options.html"; |
741 let fullOptionsUrl = ext.getURL("options.html"); | |
742 | |
743 chrome.tabs.query({}, tabs => | |
741 { | 744 { |
742 let optionsUrl = "options.html"; | 745 // We find a tab ourselves because Edge has a bug when quering tabs |
743 let queryInfo = {url: optionsUrl}; | 746 // with extension URL protocol: |
747 // https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/ 8094141/ | |
748 // https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/ 8604703/ | |
749 let tab = tabs == null ? null : tabs.find(element => | |
Sebastian Noack
2017/08/29 04:04:26
In which case is `tabs == null`? According to my u
Manish Jethani
2017/08/29 04:18:33
tabs was null on Firefox for Android when we were
| |
750 { | |
751 return element.url == fullOptionsUrl; | |
Sebastian Noack
2017/08/29 04:04:26
The braces + return statement is redundant for sin
| |
752 }); | |
744 | 753 |
745 // extension pages can't be accessed in incognito windows. In order to | 754 if (tab) |
746 // correctly mimic the way in which Chrome opens extension options, | 755 { |
747 // we have to focus the options page in any other window. | 756 // Firefox for Android does not support the windows API. Since there |
748 if (win && !win.incognito) | 757 // is effectively only one window on the mobile browser, there's no |
749 queryInfo.windowId = win.id; | 758 // need to bring it into focus. |
759 if ("windows" in chrome) | |
760 chrome.windows.update(tab.windowId, {focused: true}); | |
750 | 761 |
751 chrome.tabs.query(queryInfo, tabs => | 762 chrome.tabs.update(tab.id, {active: true}); |
763 | |
764 if (callback) | |
765 callback(new Page(tab)); | |
766 } | |
767 else | |
752 { | 768 { |
753 if (tabs && tabs.length > 0) | 769 ext.pages.open(optionsUrl, callback); |
754 { | 770 } |
755 let tab = tabs[0]; | 771 }); |
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) | |
773 { | |
774 chrome.windows.getLastFocused(open); | |
775 } | |
776 else | |
777 { | |
778 // 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 | |
780 // to bring it into focus. | |
781 open(); | |
782 } | |
783 } | 772 } |
784 }; | 773 }; |
785 | 774 |
786 /* Windows */ | 775 /* Windows */ |
787 ext.windows = { | 776 ext.windows = { |
788 create(createData, callback) | 777 create(createData, callback) |
789 { | 778 { |
790 chrome.windows.create(createData, createdWindow => | 779 chrome.windows.create(createData, createdWindow => |
791 { | 780 { |
792 afterTabLoaded(callback)(createdWindow.tabs[0]); | 781 afterTabLoaded(callback)(createdWindow.tabs[0]); |
793 }); | 782 }); |
794 } | 783 } |
795 }; | 784 }; |
796 }()); | 785 }()); |
OLD | NEW |