Skip to content

Commit

Permalink
Fix kiosk mode not working in web apps (fixes #176)
Browse files Browse the repository at this point in the history
  • Loading branch information
filips123 committed Dec 28, 2024
1 parent a5d1da9 commit 2eb1935
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions native/userchrome/profile/chrome/pwa/content/browser.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class PwaBrowser {
setTimeout(() => { this.renameOpenImageAction() });
setTimeout(() => { this.disableNewTabShortcuts() });
this.renameHomepageWidget();
this.handleKioskMode();
}

loadLocalizationSources () {
Expand Down Expand Up @@ -86,16 +87,16 @@ class PwaBrowser {
const siteIcon = siteIcons.find(icon => icon.size >= 32) || siteIcons[siteIcons.length - 1];
if (siteIcon) tabIconImage.setAttribute('src', siteIcon.icon.src);

const siteName = sanitizeString(window.gFFPWASiteConfig?.config.name || window.gFFPWASiteConfig?.manifest.name || window.gFFPWASiteConfig?.manifest.short_name) || new URL(site.manifest.scope).host;
const siteScope = window.gFFPWASiteConfig?.manifest.scope ? new URL(window.gFFPWASiteConfig.manifest.scope).host : null;
const siteName = sanitizeString(window.gFFPWASiteConfig?.config.name || window.gFFPWASiteConfig?.manifest.name || window.gFFPWASiteConfig?.manifest.short_name) || siteScope;
tabLabel.replaceChildren(siteName);
document.title = siteName;

// Sync current tab favicon and title with custom info elements
// This can be disabled by user using our preferences
const docDS = document.documentElement.dataset;
docDS['contentTitleDefault'] = docDS['contentTitlePrivate'] = 'CONTENTTITLE'
docDS['titleDefault'] = docDS['titlePrivate'] = siteName

docDS['contentTitleDefault'] = docDS['contentTitlePrivate'] = 'CONTENTTITLE';
docDS['titleDefault'] = docDS['titlePrivate'] = siteName;
setTimeout(() => {
window.gBrowser.updateTitlebar = function () {
const dynamicTitle = xPref.get(ChromeLoader.PREF_DYNAMIC_WINDOW_TITLE);
Expand Down Expand Up @@ -903,6 +904,15 @@ class PwaBrowser {
});
}

handleKioskMode () {
window.addEventListener('MozAfterPaint', () => {
if (window.BrowserHandler.kiosk && window.toolbar.visible) {
// Enable fullscreen when kiosk mode is enabled for non-popup windows
window.fullScreen = true;
}
});
}

//////////////////////////////
// Widgets
//////////////////////////////
Expand Down

0 comments on commit 2eb1935

Please sign in to comment.