Bug 158968 - Implement kiosk mode. r=Gijs

Differential Revision: https://phabricator.services.mozilla.com/D41848

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Michael Kaply 2019-10-04 19:47:56 +00:00
parent f80662b1b5
commit d3547ee818
8 changed files with 73 additions and 3 deletions

View File

@ -8,6 +8,17 @@
ChromeUtils.import("resource:///modules/PermissionUI.jsm", this);
var { XPCOMUtils } = ChromeUtils.import(
"resource://gre/modules/XPCOMUtils.jsm"
);
XPCOMUtils.defineLazyServiceGetter(
this,
"BrowserHandler",
"@mozilla.org/browser/clh;1",
"nsIBrowserHandler"
);
var PointerlockFsWarning = {
_element: null,
_origin: null,
@ -649,6 +660,9 @@ var FullScreen = {
},
showNavToolbox(trackMouse = true) {
if (BrowserHandler.kiosk) {
return;
}
this._fullScrToggler.hidden = true;
gNavToolbox.removeAttribute("fullscreenShouldAnimate");
gNavToolbox.style.marginTop = "";
@ -690,11 +704,13 @@ var FullScreen = {
}
// a textbox in chrome is focused (location bar anyone?): don't collapse chrome
// unless we are kiosk mode
let focused = document.commandDispatcher.focusedElement;
if (
focused &&
focused.ownerDocument == document &&
focused.localName == "input"
focused.localName == "input" &&
!BrowserHandler.kiosk
) {
// But try collapse the chrome again when anything happens which can make
// it lose the focus. We cannot listen on "blur" event on focused here
@ -725,7 +741,8 @@ var FullScreen = {
if (
aAnimate &&
Services.prefs.getBoolPref("toolkit.cosmeticAnimations.enabled")
Services.prefs.getBoolPref("toolkit.cosmeticAnimations.enabled") &&
!BrowserHandler.kiosk
) {
gNavToolbox.setAttribute("fullscreenShouldAnimate", true);
// Hide the fullscreen toggler until the transition ends.

View File

@ -266,6 +266,7 @@ XPCOMUtils.defineLazyServiceGetters(this, {
],
Marionette: ["@mozilla.org/remote/marionette;1", "nsIMarionette"],
WindowsUIUtils: ["@mozilla.org/windows-ui-utils;1", "nsIWindowsUIUtils"],
BrowserHandler: ["@mozilla.org/browser/clh;1", "nsIBrowserHandler"],
});
if (AppConstants.MOZ_CRASHREPORTER) {
@ -2178,6 +2179,15 @@ var gBrowserInit = {
Services.obs.notifyObservers(window, "browser-delayed-startup-finished");
TelemetryTimestamps.add("delayedStartupFinished");
if (BrowserHandler.kiosk) {
// We don't modify popup windows for kiosk mode
if (!gURLBar.readOnly) {
// Don't show status tooltips in kiosk mode
document.getElementById("statuspanel").hidden = true;
window.fullScreen = true;
}
}
},
_setInitialFocus() {
@ -3853,7 +3863,7 @@ function getDefaultHomePage() {
}
function BrowserFullScreen() {
window.fullScreen = !window.fullScreen;
window.fullScreen = !window.fullScreen || BrowserHandler.kiosk;
}
function getWebNavigation() {

View File

@ -35,9 +35,20 @@ XPCOMUtils.defineLazyGetter(this, "ReferrerInfo", () =>
)
);
XPCOMUtils.defineLazyServiceGetter(
this,
"BrowserHandler",
"@mozilla.org/browser/clh;1",
"nsIBrowserHandler"
);
var gContextMenuContentData = null;
function openContextMenu(aMessage, aBrowser, aActor) {
if (BrowserHandler.kiosk) {
// Don't display context menus in kiosk mode
return;
}
let data = aMessage.data;
let browser = aBrowser;
let actor = aActor;

View File

@ -93,6 +93,8 @@ function resolveURIInternal(aCmdLine, aArgument) {
return uri;
}
let gKiosk = false;
let gRemoteInstallPage = null;
function getNewInstallPage() {
@ -393,6 +395,9 @@ nsBrowserContentHandler.prototype = {
/* nsICommandLineHandler */
handle: function bch_handle(cmdLine) {
if (cmdLine.handleFlag("kiosk", false)) {
gKiosk = true;
}
if (cmdLine.handleFlag("browser", false)) {
openBrowserWindow(cmdLine, gSystemPrincipal);
cmdLine.preventDefault = true;
@ -606,6 +611,7 @@ nsBrowserContentHandler.prototype = {
info += " --setDefaultBrowser Set this app as the default browser.\n";
info +=
" --first-startup Run post-install actions before opening a new window.\n";
info += " --kiosk Start the browser in kiosk mode.\n";
return info;
},
@ -821,6 +827,10 @@ nsBrowserContentHandler.prototype = {
return this.mFeatures;
},
get kiosk() {
return gKiosk;
},
/* nsIContentHandler */
handleContent: function bch_handleContent(contentType, context, request) {

View File

@ -0,0 +1,18 @@
Enterprise Policies
===================
Introduction
------------
Firefox provides policies to manage various aspects of Firefox. The best documentation is in `GitHub <https://github.com/mozilla/policy-templates/>`_.
Kiosk Mode
----------
The kiosk mode provided by Firefox on the command line (--kiosk) is a very basic mode intended for kiosks where the content loaded in the browser is strictly limited by the owner of the kiosk and either there is no keyboard or keyboard access is limited (particularly Ctrl and Alt). It is their responsibility to ensure the content does not surprise/confuse users or break browser UI in this setup.
It does three main things:
1. Switch all main browser windows (not popup windows) into full screen mode.
2. Don't show the context menu.
3. Don't show status for URLs or pageloading.

View File

@ -7,6 +7,8 @@
with Files("**"):
BUG_COMPONENT = ("Firefox", "Enterprise Policies")
SPHINX_TREES['docs'] = 'docs'
DIRS += [
'helpers',
'schemas',

View File

@ -11,6 +11,7 @@ interface nsIBrowserHandler : nsISupports
{
attribute AUTF8String startPage;
attribute AUTF8String defaultArgs;
attribute boolean kiosk;
/**
* Extract the width and height specified on the command line, if present.

View File

@ -9,6 +9,7 @@ This is the nascent documentation of the Firefox front-end code.
urlbar/index
BrowserUsageTelemetry
components/enterprisepolicies/docs/index
extensions/formautofill/docs/index
components/newtab/docs/index
installer/windows/installer/index