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

Side by Side Diff: ext/background.js

Issue 29536764: Issue 5587, 5748 - Use mobile options page on Firefox for Android (Closed) Base URL: https://hg.adblockplus.org/adblockpluschrome/
Patch Set: Forward query string and fragment identifier to iframe Created Sept. 13, 2017, 12:24 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
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 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 385 matching lines...) Expand 10 before | Expand all | Expand 10 after
725 { 715 {
726 if (tabs[0].status == "complete") 716 if (tabs[0].status == "complete")
727 callback(new Page(tabs[0])); 717 callback(new Page(tabs[0]));
728 else 718 else
729 afterTabLoaded(callback)(tabs[0]); 719 afterTabLoaded(callback)(tabs[0]);
730 } 720 }
731 }); 721 });
732 }); 722 });
733 } 723 }
734 } 724 }
735 else if ("windows" in chrome) 725 else if ("windows" in chrome)
Manish Jethani 2017/09/13 16:07:43 We need to query open tabs on Firefox for Android
736 { 726 {
737 // Edge does not yet support runtime.openOptionsPage (tested version 38) 727 // Edge does not yet support runtime.openOptionsPage (tested version 38)
738 // and so this workaround needs to stay for now. 728 // 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"; 729 let optionsUrl = "options.html";
743 let fullOptionsUrl = ext.getURL(optionsUrl);
744 730
745 chrome.tabs.query({}, tabs => 731 chrome.tabs.query({}, tabs =>
746 { 732 {
747 // We find a tab ourselves because Edge has a bug when quering tabs 733 // We find a tab ourselves because Edge has a bug when quering tabs
748 // with extension URL protocol: 734 // with extension URL protocol:
749 // https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/ 8094141/ 735 // https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/ 8094141/
750 // https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/ 8604703/ 736 // https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/ 8604703/
737 let fullOptionsUrl = ext.getURL(optionsUrl);
751 let tab = tabs.find(element => element.url == fullOptionsUrl); 738 let tab = tabs.find(element => element.url == fullOptionsUrl);
752 if (tab) 739 if (tab)
753 { 740 {
754 chrome.windows.update(tab.windowId, {focused: true}); 741 chrome.windows.update(tab.windowId, {focused: true});
755 chrome.tabs.update(tab.id, {active: true}); 742 chrome.tabs.update(tab.id, {active: true});
756 743
757 if (callback) 744 if (callback)
758 callback(new Page(tab)); 745 callback(new Page(tab));
759 } 746 }
760 else 747 else
761 { 748 {
749 // We don't use fullOptionsUrl here because of this Edge issue:
750 // https://developer.microsoft.com/en-us/microsoft-edge/platform/issue s/10276332
762 ext.pages.open(optionsUrl, callback); 751 ext.pages.open(optionsUrl, callback);
763 } 752 }
764 }); 753 });
765 } 754 }
766 else 755 else
767 { 756 {
768 // Firefox for Android before version 57 does not support 757 // Firefox for Android before version 57 does not support
Manish Jethani 2017/09/13 16:07:43 Moved this comment up.
769 // runtime.openOptionsPage, nor does it support the windows API. Since 758 // runtime.openOptionsPage, nor does it support the windows API. Since
770 // there is effectively only one window on the mobile browser, there's no 759 // there is effectively only one window on the mobile browser, there's no
771 // need to bring it into focus. 760 // need to bring it into focus.
772 ext.pages.open("options.html", callback); 761 ext.pages.open("options.html", callback);
773 } 762 }
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 }());
OLDNEW
« no previous file with comments | « desktop-options.js ('k') | lib/browserAction.js » ('j') | options.js » ('J')

Powered by Google App Engine
This is Rietveld