| 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-2016 Eyeo GmbH | 3 * Copyright (C) 2006-2016 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 594 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 605 }, | 605 }, |
| 606 remove: function(key, callback) | 606 remove: function(key, callback) |
| 607 { | 607 { |
| 608 chrome.storage.local.remove(key, callback); | 608 chrome.storage.local.remove(key, callback); |
| 609 }, | 609 }, |
| 610 onChanged: chrome.storage.onChanged | 610 onChanged: chrome.storage.onChanged |
| 611 }; | 611 }; |
| 612 | 612 |
| 613 /* Options */ | 613 /* Options */ |
| 614 | 614 |
| 615 ext.showOptions = function(callback) | 615 if ("openOptionsPage" in chrome.runtime) |
| 616 { | 616 { |
| 617 chrome.windows.getLastFocused(function(win) | 617 ext.showOptions = chrome.runtime.openOptionsPage; |
|
Sebastian Noack
2016/12/08 15:26:42
I wonder how/whether this can work? The old code (
kzar
2016/12/09 09:11:02
Damn you're right. Sorry I'll open a review to fix
| |
| 618 } | |
| 619 else | |
| 620 { | |
| 621 // Edge does not yet support runtime.openOptionsPage (tested version 38) | |
| 622 // and so this workaround needs to stay for now. | |
| 623 ext.showOptions = function(callback) | |
| 618 { | 624 { |
| 619 var optionsUrl = chrome.extension.getURL("options.html"); | 625 chrome.windows.getLastFocused(function(win) |
| 620 var queryInfo = {url: optionsUrl}; | 626 { |
| 627 var optionsUrl = chrome.extension.getURL("options.html"); | |
| 628 var queryInfo = {url: optionsUrl}; | |
| 621 | 629 |
| 622 // extension pages can't be accessed in incognito windows. In order to | 630 // extension pages can't be accessed in incognito windows. In order to |
| 623 // correctly mimic the way in which Chrome opens extension options, | 631 // correctly mimic the way in which Chrome opens extension options, |
| 624 // we have to focus the options page in any other window. | 632 // we have to focus the options page in any other window. |
| 625 if (!win.incognito) | 633 if (!win.incognito) |
| 626 queryInfo.windowId = win.id; | 634 queryInfo.windowId = win.id; |
| 627 | 635 |
| 628 chrome.tabs.query(queryInfo, function(tabs) | 636 chrome.tabs.query(queryInfo, function(tabs) |
| 629 { | |
| 630 if (tabs.length > 0) | |
| 631 { | 637 { |
| 632 var tab = tabs[0]; | 638 if (tabs.length > 0) |
| 639 { | |
| 640 var tab = tabs[0]; | |
| 633 | 641 |
| 634 chrome.windows.update(tab.windowId, {focused: true}); | 642 chrome.windows.update(tab.windowId, {focused: true}); |
| 635 chrome.tabs.update(tab.id, {active: true}); | 643 chrome.tabs.update(tab.id, {active: true}); |
| 636 | 644 |
| 637 if (callback) | 645 if (callback) |
| 638 callback(new Page(tab)); | 646 callback(new Page(tab)); |
| 639 } | 647 } |
| 640 else | 648 else |
| 641 { | 649 { |
| 642 ext.pages.open(optionsUrl, callback); | 650 ext.pages.open(optionsUrl, callback); |
| 643 } | 651 } |
| 652 }); | |
| 644 }); | 653 }); |
| 645 }); | 654 }; |
| 646 }; | 655 } |
| 647 | 656 |
| 648 /* Windows */ | 657 /* Windows */ |
| 649 ext.windows = { | 658 ext.windows = { |
| 650 create: function(createData, callback) | 659 create: function(createData, callback) |
| 651 { | 660 { |
| 652 chrome.windows.create(createData, function(createdWindow) | 661 chrome.windows.create(createData, function(createdWindow) |
| 653 { | 662 { |
| 654 afterTabLoaded(callback)(createdWindow.tabs[0]); | 663 afterTabLoaded(callback)(createdWindow.tabs[0]); |
| 655 }); | 664 }); |
| 656 } | 665 } |
| 657 }; | 666 }; |
| 658 })(); | 667 })(); |
| OLD | NEW |