Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: ext/background.js

Issue 29527610: Noissue - Add version check for runtime.openOptionsPage for Firefox for Android (Closed) Base URL: https://hg.adblockplus.org/adblockpluschrome/
Patch Set: Update comment Created Aug. 25, 2017, 9:30 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 681 matching lines...) Expand 10 before | Expand all | Expand 10 after
692 { 692 {
693 chrome.storage.local.remove(key, callback); 693 chrome.storage.local.remove(key, callback);
694 }, 694 },
695 onChanged: chrome.storage.onChanged 695 onChanged: chrome.storage.onChanged
696 }; 696 };
697 697
698 /* Options */ 698 /* Options */
699 699
700 ext.showOptions = callback => 700 ext.showOptions = callback =>
701 { 701 {
702 let info = require("info");
703
702 if ("openOptionsPage" in chrome.runtime && 704 if ("openOptionsPage" in chrome.runtime &&
703 // Firefox for Android does have a runtime.openOptionsPage but it 705 // Some versions of Firefox for Android before version 57 do have a
704 // doesn't do anything. 706 // runtime.openOptionsPage but it doesn't do anything.
705 // https://bugzilla.mozilla.org/show_bug.cgi?id=1364945 707 // https://bugzilla.mozilla.org/show_bug.cgi?id=1364945
706 require("info").application != "fennec") 708 (info.application != "fennec" ||
709 (parseInt(info.applicationVersion, 10) >= 57 &&
710 info.applicationVersion != "57.0a1")))
Wladimir Palant 2017/08/25 09:56:46 It should be sufficient to check that it's Firefox
Manish Jethani 2017/08/25 11:02:31 Done.
707 { 711 {
708 if (!callback) 712 if (!callback)
709 { 713 {
710 chrome.runtime.openOptionsPage(); 714 chrome.runtime.openOptionsPage();
711 } 715 }
712 else 716 else
713 { 717 {
714 chrome.runtime.openOptionsPage(() => 718 chrome.runtime.openOptionsPage(() =>
715 { 719 {
716 if (chrome.runtime.lastError) 720 if (chrome.runtime.lastError)
717 return; 721 return;
718 722
719 chrome.tabs.query({active: true, lastFocusedWindow: true}, tabs => 723 chrome.tabs.query({active: true, lastFocusedWindow: true}, tabs =>
720 { 724 {
721 if (tabs.length > 0) 725 if (tabs.length > 0)
722 { 726 {
723 if (tabs[0].status == "complete") 727 if (tabs[0].status == "complete")
724 callback(new Page(tabs[0])); 728 callback(new Page(tabs[0]));
725 else 729 else
726 afterTabLoaded(callback)(tabs[0]); 730 afterTabLoaded(callback)(tabs[0]);
727 } 731 }
728 }); 732 });
729 }); 733 });
730 } 734 }
731 } 735 }
732 else 736 else
733 { 737 {
734 // Edge does not yet support runtime.openOptionsPage (tested version 38) 738 // Edge does not yet support runtime.openOptionsPage (tested version 38)
735 // nor does Firefox for Android, 739 // nor does Firefox for Android before version 57,
736 // and so this workaround needs to stay for now. 740 // and so this workaround needs to stay for now.
737 // We are not using extension.getURL to get the absolute path here 741 // We are not using extension.getURL to get the absolute path here
738 // because of the Edge issue: 742 // because of the Edge issue:
739 // https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/10 276332/ 743 // https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/10 276332/
740 let open = win => 744 let open = win =>
741 { 745 {
742 let optionsUrl = "options.html"; 746 let optionsUrl = "options.html";
743 let queryInfo = {url: optionsUrl}; 747 let queryInfo = {url: optionsUrl};
744 748
745 // extension pages can't be accessed in incognito windows. In order to 749 // extension pages can't be accessed in incognito windows. In order to
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
787 ext.windows = { 791 ext.windows = {
788 create(createData, callback) 792 create(createData, callback)
789 { 793 {
790 chrome.windows.create(createData, createdWindow => 794 chrome.windows.create(createData, createdWindow =>
791 { 795 {
792 afterTabLoaded(callback)(createdWindow.tabs[0]); 796 afterTabLoaded(callback)(createdWindow.tabs[0]);
793 }); 797 });
794 } 798 }
795 }; 799 };
796 }()); 800 }());
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld