Index: ext/background.js |
=================================================================== |
--- a/ext/background.js |
+++ b/ext/background.js |
@@ -312,16 +312,26 @@ |
chrome.tabs.onActivated.addListener(details => |
{ |
ext.pages.onActivated._dispatch(new Page({id: details.tabId})); |
}); |
/* Browser actions */ |
+ // On Firefox for Android, open the options page directly when the browser |
+ // action is clicked. |
+ if (!("getPopup" in chrome.browserAction)) |
+ { |
+ chrome.browserAction.onClicked.addListener(() => |
+ { |
+ ext.showOptions(); |
+ }); |
+ } |
+ |
let BrowserAction = function(tabId) |
{ |
this._tabId = tabId; |
this._changes = null; |
}; |
BrowserAction.prototype = { |
_applyChanges() |
{ |
@@ -660,19 +670,23 @@ |
{ |
chrome.storage.local.remove(key, callback); |
}, |
onChanged: chrome.storage.onChanged |
}; |
/* Options */ |
- if ("openOptionsPage" in chrome.runtime) |
+ ext.showOptions = callback => |
{ |
- ext.showOptions = callback => |
+ if ("openOptionsPage" in chrome.runtime && |
+ // Firefox for Android does have a runtime.openOptionsPage but it |
+ // doesn't do anything. |
+ // https://bugzilla.mozilla.org/show_bug.cgi?id=1364945 |
+ require("info").application != "fennec") |
{ |
if (!callback) |
{ |
chrome.runtime.openOptionsPage(); |
} |
else |
{ |
chrome.runtime.openOptionsPage(() => |
@@ -687,58 +701,56 @@ |
if (tabs[0].status == "complete") |
callback(new Page(tabs[0])); |
else |
afterTabLoaded(callback)(tabs[0]); |
} |
}); |
}); |
} |
- }; |
- } |
- else |
- { |
- // Edge does not yet support runtime.openOptionsPage (tested version 38) |
- // and so this workaround needs to stay for now. |
- // We are not using extension.getURL to get the absolute path here |
- // because of the Edge issue: |
- // https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/10276332/ |
- ext.showOptions = callback => |
+ } |
+ else |
{ |
+ // Edge does not yet support runtime.openOptionsPage (tested version 38) |
+ // nor does Firefox for Android, |
+ // and so this workaround needs to stay for now. |
+ // We are not using extension.getURL to get the absolute path here |
+ // because of the Edge issue: |
+ // https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/10276332/ |
chrome.windows.getLastFocused(win => |
{ |
let optionsUrl = "options.html"; |
let 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; |
chrome.tabs.query(queryInfo, tabs => |
{ |
- if (tabs.length > 0) |
+ if (tabs && tabs.length > 0) |
{ |
let tab = tabs[0]; |
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); |
} |
}); |
}); |
- }; |
- } |
+ } |
+ }; |
/* Windows */ |
ext.windows = { |
create(createData, callback) |
{ |
chrome.windows.create(createData, createdWindow => |
{ |
afterTabLoaded(callback)(createdWindow.tabs[0]); |