Select default UI according to target platform

More specifically, this commit makes it so that
the new default UI for Firefox Preview will be
automatically selected.

A default platform-specific UI can be cancelled
by setting the advanced setting `uiFlavor` to `-`.
This commit is contained in:
Raymond Hill 2020-02-06 11:42:12 -05:00
parent bead897380
commit 760d206bd4
No known key found for this signature in database
GPG key ID: 25E1490B761470C2

View file

@ -339,12 +339,21 @@ initializeTabs();
// active tab. // active tab.
µb.contextMenu.update(); µb.contextMenu.update();
// Maybe install non-default popup document // Maybe install non-default popup document, or automatically select
// default UI according to platform.
if ( if (
browser.browserAction instanceof Object && browser.browserAction instanceof Object &&
browser.browserAction.setPopup instanceof Function browser.browserAction.setPopup instanceof Function
) { ) {
const uiFlavor = µb.hiddenSettings.uiFlavor; let uiFlavor = µb.hiddenSettings.uiFlavor;
if (
uiFlavor === 'unset' &&
vAPI.webextFlavor.major > 68 &&
vAPI.webextFlavor.soup.has('firefox') &&
vAPI.webextFlavor.soup.has('mobile')
) {
uiFlavor = 'fenix';
}
if ( uiFlavor !== 'unset' && /\w+/.test(uiFlavor) ) { if ( uiFlavor !== 'unset' && /\w+/.test(uiFlavor) ) {
browser.browserAction.setPopup({ browser.browserAction.setPopup({
popup: vAPI.getURL(`popup-${uiFlavor}.html`) popup: vAPI.getURL(`popup-${uiFlavor}.html`)