Index: chrome/ext/background.js |
diff --git a/chrome/ext/background.js b/chrome/ext/background.js |
index e61c20ffd175d697f149aa726a6528b747ec238f..62f15c233420a1ad77ab9f79cc2e828c717d45ea 100644 |
--- a/chrome/ext/background.js |
+++ b/chrome/ext/background.js |
@@ -612,38 +612,47 @@ |
/* Options */ |
- ext.showOptions = function(callback) |
+ if ("openOptionsPage" in chrome.runtime) |
{ |
- chrome.windows.getLastFocused(function(win) |
+ 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
|
+ } |
+ else |
+ { |
+ // Edge does not yet support runtime.openOptionsPage (tested version 38) |
+ // and so this workaround needs to stay for now. |
+ ext.showOptions = function(callback) |
{ |
- var optionsUrl = chrome.extension.getURL("options.html"); |
- var queryInfo = {url: optionsUrl}; |
+ chrome.windows.getLastFocused(function(win) |
+ { |
+ var optionsUrl = chrome.extension.getURL("options.html"); |
+ var queryInfo = {url: optionsUrl}; |
- // extension pages can't be accessed in incognito windows. In order to |
- // correctly mimic the way in which Chrome opens extension options, |
- // we have to focus the options page in any other window. |
- if (!win.incognito) |
- queryInfo.windowId = win.id; |
+ // extension pages can't be accessed in incognito windows. In order to |
+ // correctly mimic the way in which Chrome opens extension options, |
+ // we have to focus the options page in any other window. |
+ if (!win.incognito) |
+ queryInfo.windowId = win.id; |
- chrome.tabs.query(queryInfo, function(tabs) |
- { |
- if (tabs.length > 0) |
+ chrome.tabs.query(queryInfo, function(tabs) |
{ |
- var tab = tabs[0]; |
+ if (tabs.length > 0) |
+ { |
+ var tab = tabs[0]; |
- chrome.windows.update(tab.windowId, {focused: true}); |
- chrome.tabs.update(tab.id, {active: true}); |
+ chrome.windows.update(tab.windowId, {focused: true}); |
+ chrome.tabs.update(tab.id, {active: true}); |
- if (callback) |
- callback(new Page(tab)); |
- } |
- else |
- { |
- ext.pages.open(optionsUrl, callback); |
- } |
+ if (callback) |
+ callback(new Page(tab)); |
+ } |
+ else |
+ { |
+ ext.pages.open(optionsUrl, callback); |
+ } |
+ }); |
}); |
- }); |
- }; |
+ }; |
+ } |
/* Windows */ |
ext.windows = { |