From 2aa4a82499d4becd2284cdb482213d541b8804dd Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 28 Apr 2024 16:29:10 +0200 Subject: Adding upstream version 86.0.1. Signed-off-by: Daniel Baumann --- browser/fxr/content/assets/icon-backward.svg | 4 + browser/fxr/content/assets/icon-forward.svg | 4 + browser/fxr/content/assets/icon-home.svg | 4 + .../content/assets/icon-logo-settings-preview.png | Bin 0 -> 5515 bytes browser/fxr/content/assets/icon-reportissue.svg | 4 + browser/fxr/content/assets/icon-secure.svg | 4 + browser/fxr/content/assets/icon-settings.svg | 4 + browser/fxr/content/assets/icon-stop-reload.svg | 4 + browser/fxr/content/assets/icon-toggle-off.png | Bin 0 -> 9592 bytes browser/fxr/content/assets/icon-toggle-on.png | Bin 0 -> 9721 bytes browser/fxr/content/common.css | 44 +++ browser/fxr/content/common.js | 48 ++++ browser/fxr/content/fxr-content.js | 14 + browser/fxr/content/fxr-fullScreen.js | 64 +++++ browser/fxr/content/fxrui.css | 146 ++++++++++ browser/fxr/content/fxrui.html | 39 +++ browser/fxr/content/fxrui.js | 296 +++++++++++++++++++++ browser/fxr/content/fxrui_blue.css | 72 +++++ browser/fxr/content/permissions.js | 145 ++++++++++ browser/fxr/content/prefs.css | 185 +++++++++++++ browser/fxr/content/prefs.html | 75 ++++++ browser/fxr/content/prefs.js | 119 +++++++++ browser/fxr/jar.mn | 31 +++ browser/fxr/moz.build | 7 + 24 files changed, 1313 insertions(+) create mode 100644 browser/fxr/content/assets/icon-backward.svg create mode 100644 browser/fxr/content/assets/icon-forward.svg create mode 100644 browser/fxr/content/assets/icon-home.svg create mode 100644 browser/fxr/content/assets/icon-logo-settings-preview.png create mode 100644 browser/fxr/content/assets/icon-reportissue.svg create mode 100644 browser/fxr/content/assets/icon-secure.svg create mode 100644 browser/fxr/content/assets/icon-settings.svg create mode 100644 browser/fxr/content/assets/icon-stop-reload.svg create mode 100644 browser/fxr/content/assets/icon-toggle-off.png create mode 100644 browser/fxr/content/assets/icon-toggle-on.png create mode 100644 browser/fxr/content/common.css create mode 100644 browser/fxr/content/common.js create mode 100644 browser/fxr/content/fxr-content.js create mode 100644 browser/fxr/content/fxr-fullScreen.js create mode 100644 browser/fxr/content/fxrui.css create mode 100644 browser/fxr/content/fxrui.html create mode 100644 browser/fxr/content/fxrui.js create mode 100644 browser/fxr/content/fxrui_blue.css create mode 100644 browser/fxr/content/permissions.js create mode 100644 browser/fxr/content/prefs.css create mode 100644 browser/fxr/content/prefs.html create mode 100644 browser/fxr/content/prefs.js create mode 100644 browser/fxr/jar.mn create mode 100644 browser/fxr/moz.build (limited to 'browser/fxr') diff --git a/browser/fxr/content/assets/icon-backward.svg b/browser/fxr/content/assets/icon-backward.svg new file mode 100644 index 0000000000..a824b50cad --- /dev/null +++ b/browser/fxr/content/assets/icon-backward.svg @@ -0,0 +1,4 @@ + + diff --git a/browser/fxr/content/assets/icon-forward.svg b/browser/fxr/content/assets/icon-forward.svg new file mode 100644 index 0000000000..0c7bc478e1 --- /dev/null +++ b/browser/fxr/content/assets/icon-forward.svg @@ -0,0 +1,4 @@ + + diff --git a/browser/fxr/content/assets/icon-home.svg b/browser/fxr/content/assets/icon-home.svg new file mode 100644 index 0000000000..5643dffad0 --- /dev/null +++ b/browser/fxr/content/assets/icon-home.svg @@ -0,0 +1,4 @@ + + diff --git a/browser/fxr/content/assets/icon-logo-settings-preview.png b/browser/fxr/content/assets/icon-logo-settings-preview.png new file mode 100644 index 0000000000..0e516aaa7b Binary files /dev/null and b/browser/fxr/content/assets/icon-logo-settings-preview.png differ diff --git a/browser/fxr/content/assets/icon-reportissue.svg b/browser/fxr/content/assets/icon-reportissue.svg new file mode 100644 index 0000000000..4c563c848c --- /dev/null +++ b/browser/fxr/content/assets/icon-reportissue.svg @@ -0,0 +1,4 @@ + + \ No newline at end of file diff --git a/browser/fxr/content/assets/icon-secure.svg b/browser/fxr/content/assets/icon-secure.svg new file mode 100644 index 0000000000..d0231acca3 --- /dev/null +++ b/browser/fxr/content/assets/icon-secure.svg @@ -0,0 +1,4 @@ + + diff --git a/browser/fxr/content/assets/icon-settings.svg b/browser/fxr/content/assets/icon-settings.svg new file mode 100644 index 0000000000..f719544a06 --- /dev/null +++ b/browser/fxr/content/assets/icon-settings.svg @@ -0,0 +1,4 @@ + + \ No newline at end of file diff --git a/browser/fxr/content/assets/icon-stop-reload.svg b/browser/fxr/content/assets/icon-stop-reload.svg new file mode 100644 index 0000000000..662810ab3d --- /dev/null +++ b/browser/fxr/content/assets/icon-stop-reload.svg @@ -0,0 +1,4 @@ + + diff --git a/browser/fxr/content/assets/icon-toggle-off.png b/browser/fxr/content/assets/icon-toggle-off.png new file mode 100644 index 0000000000..398a42c9bf Binary files /dev/null and b/browser/fxr/content/assets/icon-toggle-off.png differ diff --git a/browser/fxr/content/assets/icon-toggle-on.png b/browser/fxr/content/assets/icon-toggle-on.png new file mode 100644 index 0000000000..f22f231628 Binary files /dev/null and b/browser/fxr/content/assets/icon-toggle-on.png differ diff --git a/browser/fxr/content/common.css b/browser/fxr/content/common.css new file mode 100644 index 0000000000..512be5aee7 --- /dev/null +++ b/browser/fxr/content/common.css @@ -0,0 +1,44 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + * { + margin: 0; + padding: 0; + user-select: none; + + font-family: 'Open Sans', sans-serif; +} + +.modal_mask:not([hidden]) { + background-color: #00CC00; + + height: 100%; + width: 100%; + + position: absolute; + top: 0; + left: 0; +} + +.modal_container:not([hidden]) { + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + + height: 100%; + width: 100%; + + position: absolute; + top: 0; + left :0; +} + +.modal_hide { + display: none; +} + +.modal_content { + position: absolute; +} diff --git a/browser/fxr/content/common.js b/browser/fxr/content/common.js new file mode 100644 index 0000000000..292c0a916a --- /dev/null +++ b/browser/fxr/content/common.js @@ -0,0 +1,48 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +// Creates a modal container, if it doesn't exist, and adds the provided +// content element to it +function showModalContainer(content) { + var container = document.getElementById("eModalContainer"); + if (container == null) { + container = document.createElement("div"); + container.id = "eModalContainer"; + container.classList.add("modal_container"); + + var mask = document.createElement("div"); + mask.id = "eModalMask"; + mask.classList.add("modal_mask"); + + document.body.appendChild(mask); + document.body.appendChild(container); + } else { + container.hidden = false; + document.getElementById("eModalMask").hidden = false; + } + + container.appendChild(content); + if (content.classList.contains("modal_hide")) { + content.classList.replace("modal_hide", "modal_content"); + } else { + content.classList.add("modal_content"); + } +} + +// Hides the modal container, and returns the contents back to the caller. +// The caller can choose to use the return value to move the contents to +// another part of the DOM, or ignore the return value so that the nodes +// can be garbage collected. +function clearModalContainer() { + var container = document.getElementById("eModalContainer"); + container.hidden = true; + document.getElementById("eModalMask").hidden = true; + + var content = container.firstElementChild; + container.removeChild(content); + content.classList.replace("modal_content", "modal_hide"); + + return content; +} diff --git a/browser/fxr/content/fxr-content.js b/browser/fxr/content/fxr-content.js new file mode 100644 index 0000000000..639a2e52d9 --- /dev/null +++ b/browser/fxr/content/fxr-content.js @@ -0,0 +1,14 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* This content script is for code associated with an FxR PC window that + * must run in a content process. */ + +var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm"); + +// Send this notification from the content process so that the +// ExtensionPolicyService can register this content frame and be ready to load +// content scripts +Services.obs.notifyObservers(this, "tab-content-frameloader-created"); diff --git a/browser/fxr/content/fxr-fullScreen.js b/browser/fxr/content/fxr-fullScreen.js new file mode 100644 index 0000000000..dd7a933d89 --- /dev/null +++ b/browser/fxr/content/fxr-fullScreen.js @@ -0,0 +1,64 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +// This file is loaded into the browser window scope. +/* eslint-env mozilla/browser-window */ + +// fxr-fullScreen.js is a provisional, stripped-down clone of +// browser\base\content\browser-fullScreenAndPointerLock.js +// that is adapted for Firefox Reality on Desktop. +// The bug to track its removal is +// Bug 1587946 - Rationalize the fork of browser-fullScreenAndPointerLock.js + +var FullScreen = { + init() { + // Called when the Firefox window go into fullscreen. + addEventListener("fullscreen", this, true); + + if (window.fullScreen) { + this.toggle(); + } + }, + + toggle() { + var enterFS = window.fullScreen; + if (enterFS) { + document.documentElement.setAttribute("inFullscreen", true); + } else { + document.documentElement.removeAttribute("inFullscreen"); + } + }, + + handleEvent(event) { + if (event.type === "fullscreen") { + this.toggle(); + } + }, + + enterDomFullscreen(aBrowser, aActor) { + if (!document.fullscreenElement) { + return; + } + + // If it is a remote browser, send a message to ask the content + // to enter fullscreen state. We don't need to do so if it is an + // in-process browser, since all related document should have + // entered fullscreen state at this point. + // This should be done before the active tab check below to ensure + // that the content document handles the pending request. Doing so + // before the check is fine since we also check the activeness of + // the requesting document in content-side handling code. + if (aBrowser.isRemoteBrowser) { + aActor.sendAsyncMessage("DOMFullscreen:Entered", {}); + } + + document.documentElement.setAttribute("inDOMFullscreen", true); + }, + + cleanupDomFullscreen(aActor) { + aActor.sendAsyncMessage("DOMFullscreen:CleanUp", {}); + document.documentElement.removeAttribute("inDOMFullscreen"); + }, +}; diff --git a/browser/fxr/content/fxrui.css b/browser/fxr/content/fxrui.css new file mode 100644 index 0000000000..881bb136d1 --- /dev/null +++ b/browser/fxr/content/fxrui.css @@ -0,0 +1,146 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +@namespace xul url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"); + +html, body { + height: 100%; +} + + +body { + display: flex; + flex-direction: column; +} + +.navbar_container { + width: 100%; + + margin-block: 15px; + + display: flex; + flex-direction: row; +} + +/* Sizing and positioning properties for all icons + Color is determined by enabled/disabled classes below + */ +.icon_container { + width: 44px; + height: 44px; + margin: 5px; + + border-radius: 22px; + border-width: 2px; + border-style: solid; + + background-size: 22px; + background-repeat: no-repeat; + background-position: center; + background-color: inherit; + + -moz-context-properties: fill; + + transition-property: transform; + transition-duration: 200ms; +} + +.icon_container:hover { + transform: scale(1.25); +} + +.icon_container:disabled { + transform: unset; +} + +.icon_disabled_hide:disabled { + display:none; +} +.icon_backward { + background-image: url("assets/icon-backward.svg"); + margin-inline-start: 10px; +} +.icon_forward { + background-image: url("assets/icon-forward.svg"); +} +.icon_refresh { + background-image: url("chrome://global/skin/icons/icon-refresh.svg"); +} +.icon_stop { + background-image: url("assets/icon-stop-reload.svg"); +} +.icon_home { + background-image: url("assets/icon-home.svg"); +} +.icon_prefs { + background-image: url("assets/icon-settings.svg"); + margin-inline-end: 10px; +} + +.urlbar_container { + height: 40px; + flex-grow: 1; + + padding: 0; + margin: 5px; + + border-radius: 22px; + border: 2px solid transparent; + + vertical-align: top; + + display: flex; + flex-direction: row; +} + +.urlbar_secure_icon { + -moz-context-properties: fill; + + height: 32px; + padding: 2px; + + visibility: hidden; + + display: inline-block; +} + +.urlbar_input { + background-color: transparent; + + flex-grow: 1; + + border: none; + + font-size: 18px; + font-family: 'Open Sans', sans-serif; + + mask-image: linear-gradient(to left, transparent, black 8ch); +} + +.browser_container { + width: 100%; + flex-grow: 1; +} + +.browser_instance { + width: 100%; + height: 100%; +} + +/* Hide the navbar when in fullscreen so that can + * fill the entire viewport + */ +:root[inFullScreen] .navbar_container { + display:none; +} + +.browser_settings { + width: 600px; + height: 400px; + border-radius: 20px; +} + +.modal_mask:not([hidden]) { + background-color: var(--num13_alpha); +} diff --git a/browser/fxr/content/fxrui.html b/browser/fxr/content/fxrui.html new file mode 100644 index 0000000000..84a00a2fd5 --- /dev/null +++ b/browser/fxr/content/fxrui.html @@ -0,0 +1,39 @@ + + + + + + + + + Firefox Reality + + + + + + + + + +
+ + + + diff --git a/browser/fxr/content/fxrui.js b/browser/fxr/content/fxrui.js new file mode 100644 index 0000000000..a5838ef593 --- /dev/null +++ b/browser/fxr/content/fxrui.js @@ -0,0 +1,296 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* import-globals-from common.js */ +/* import-globals-from permissions.js */ + +// Configuration vars +let homeURL = "https://webxr.today/"; +// Bug 1586294 - Localize the privacy policy URL (Services.urlFormatter?) +let privacyPolicyURL = "https://www.mozilla.org/en-US/privacy/firefox/"; +let reportIssueURL = "https://mzl.la/fxr"; +let licenseURL = + "https://mixedreality.mozilla.org/FirefoxRealityPC/license.html"; + +// https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/browser +let browser = null; +// Keep track of the current Permissions request to only allow one outstanding +// request/prompt at a time. +let currentPermissionRequest = null; +// And, keep a queue of pending Permissions requests to resolve when the +// current request finishes +let pendingPermissionRequests = []; +// The following variable map to UI elements whose behavior changes depending +// on some state from the browser control +let urlInput = null; +let secureIcon = null; +let backButton = null; +let forwardButton = null; +let refreshButton = null; +let stopButton = null; + +let { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm"); +const { PrivateBrowsingUtils } = ChromeUtils.import( + "resource://gre/modules/PrivateBrowsingUtils.jsm" +); +const { AppConstants } = ChromeUtils.import( + "resource://gre/modules/AppConstants.jsm" +); +const { XPCOMUtils } = ChromeUtils.import( + "resource://gre/modules/XPCOMUtils.jsm" +); + +// Note: FxR UI uses a fork of browser-fullScreenAndPointerLock.js which removes +// the dependencies on browser.js. +// Bug 1587946 - Rationalize the fork of browser-fullScreenAndPointerLock.js +XPCOMUtils.defineLazyScriptGetter( + this, + "FullScreen", + "chrome://fxr/content/fxr-fullScreen.js" +); +XPCOMUtils.defineLazyGetter(this, "gSystemPrincipal", () => + Services.scriptSecurityManager.getSystemPrincipal() +); + +window.addEventListener( + "DOMContentLoaded", + () => { + urlInput = document.getElementById("eUrlInput"); + secureIcon = document.getElementById("eUrlSecure"); + backButton = document.getElementById("eBack"); + forwardButton = document.getElementById("eForward"); + refreshButton = document.getElementById("eRefresh"); + stopButton = document.getElementById("eStop"); + + setupBrowser(); + setupNavButtons(); + setupUrlBar(); + }, + { once: true } +); + +// Create XUL browser object +function setupBrowser() { + // Note: createXULElement is undefined when this page is not loaded + // via chrome protocol + if (document.createXULElement) { + browser = document.createXULElement("browser"); + browser.setAttribute("type", "content"); + browser.setAttribute("remote", "true"); + browser.classList.add("browser_instance"); + document.getElementById("eBrowserContainer").appendChild(browser); + + browser.loadUrlWithSystemPrincipal = function(url) { + this.loadURI(url, { triggeringPrincipal: gSystemPrincipal }); + }; + + // Expose this function for Permissions to be used on this browser element + // in other parts of the frontend + browser.fxrPermissionPrompt = permissionPrompt; + + urlInput.value = homeURL; + browser.loadUrlWithSystemPrincipal(homeURL); + + browser.addProgressListener( + { + QueryInterface: ChromeUtils.generateQI([ + "nsIWebProgressListener", + "nsISupportsWeakReference", + ]), + onLocationChange(aWebProgress, aRequest, aLocation, aFlags) { + // When URL changes, update the URL in the URL bar and update + // whether the back/forward buttons are enabled. + urlInput.value = browser.currentURI.spec; + + backButton.disabled = !browser.canGoBack; + forwardButton.disabled = !browser.canGoForward; + }, + onStateChange(aWebProgress, aRequest, aStateFlags, aStatus) { + if (aStateFlags & Ci.nsIWebProgressListener.STATE_STOP) { + // Network requests are complete. Disable (hide) the stop button + // and enable (show) the refresh button + refreshButton.disabled = false; + stopButton.disabled = true; + } else { + // Network requests are outstanding. Disable (hide) the refresh + // button and enable (show) the stop button + refreshButton.disabled = true; + stopButton.disabled = false; + } + }, + onSecurityChange(aWebProgress, aRequest, aState) { + // Update the Secure Icon when the security status of the + // content changes + if (aState & Ci.nsIWebProgressListener.STATE_IS_SECURE) { + secureIcon.style.visibility = "visible"; + } else { + secureIcon.style.visibility = "hidden"; + } + }, + }, + Ci.nsIWebProgress.NOTIFY_LOCATION | + Ci.nsIWebProgress.NOTIFY_SECURITY | + Ci.nsIWebProgress.NOTIFY_STATE_REQUEST + ); + + FullScreen.init(); + + // Send this notification to start and allow background scripts for + // WebExtensions, since this FxR UI doesn't participate in typical + // startup activities + Services.obs.notifyObservers(window, "extensions-late-startup"); + + // Load this script in the content process to start and allow scripts for + // WebExtensions that run in the content process + browser.messageManager.loadFrameScript( + "chrome://fxr/content/fxr-content.js", + true // allowDelayedLoad + ); + } +} + +function setupNavButtons() { + let aryNavButtons = [ + "eBack", + "eForward", + "eRefresh", + "eStop", + "eHome", + "ePrefs", + ]; + + function navButtonHandler(e) { + if (!this.disabled) { + switch (this.id) { + case "eBack": + browser.goBack(); + break; + + case "eForward": + browser.goForward(); + break; + + case "eRefresh": + browser.reload(); + break; + + case "eStop": + browser.stop(); + break; + + case "eHome": + browser.loadUrlWithSystemPrincipal(homeURL); + break; + + case "ePrefs": + openSettings(); + break; + } + } + } + + for (let btnName of aryNavButtons) { + let elem = document.getElementById(btnName); + elem.addEventListener("click", navButtonHandler); + } +} + +function setupUrlBar() { + // Navigate to new value when the user presses "Enter" + urlInput.addEventListener("keypress", async function(e) { + if (e.key == "Enter") { + // Use the URL Fixup Service in case the user wants to search instead + // of directly navigating to a location. + await Services.search.init(); + + let valueToFixUp = urlInput.value; + let flags = + Services.uriFixup.FIXUP_FLAG_FIX_SCHEME_TYPOS | + Services.uriFixup.FIXUP_FLAG_ALLOW_KEYWORD_LOOKUP; + if (PrivateBrowsingUtils.isWindowPrivate(window)) { + flags |= Services.uriFixup.FIXUP_FLAG_PRIVATE_CONTEXT; + } + let { preferredURI } = Services.uriFixup.getFixupURIInfo( + valueToFixUp, + flags + ); + + browser.loadUrlWithSystemPrincipal(preferredURI.spec); + browser.focus(); + } + }); + + // Upon focus, highlight the whole URL + urlInput.addEventListener("focus", function() { + urlInput.select(); + }); +} + +// +// Code to manage Settings UI +// + +function openSettings() { + let browserSettingsUI = document.createXULElement("browser"); + browserSettingsUI.setAttribute("type", "chrome"); + browserSettingsUI.classList.add("browser_settings"); + + showModalContainer(browserSettingsUI); + + browserSettingsUI.loadURI("chrome://fxr/content/prefs.html", { + triggeringPrincipal: gSystemPrincipal, + }); +} + +function closeSettings() { + clearModalContainer(); +} + +function showPrivacyPolicy() { + closeSettings(); + browser.loadUrlWithSystemPrincipal(privacyPolicyURL); +} + +function showLicenseInfo() { + closeSettings(); + browser.loadUrlWithSystemPrincipal(licenseURL); +} + +function showReportIssue() { + closeSettings(); + browser.loadUrlWithSystemPrincipal(reportIssueURL); +} + +// +// Code to manage Permissions UI +// + +function permissionPrompt(aRequest) { + let newPrompt; + if (aRequest instanceof Ci.nsIContentPermissionRequest) { + newPrompt = new FxrContentPrompt(aRequest, this, finishPrompt); + } else { + newPrompt = new FxrWebRTCPrompt(aRequest, this, finishPrompt); + } + + if (currentPermissionRequest) { + // There is already an outstanding request running. Cache this new request + // to be prompted later + pendingPermissionRequests.push(newPrompt); + } else { + currentPermissionRequest = newPrompt; + currentPermissionRequest.showPrompt(); + } +} + +function finishPrompt() { + if (pendingPermissionRequests.length) { + // Prompt the next request + currentPermissionRequest = pendingPermissionRequests.shift(); + currentPermissionRequest.showPrompt(); + } else { + currentPermissionRequest = null; + } +} diff --git a/browser/fxr/content/fxrui_blue.css b/browser/fxr/content/fxrui_blue.css new file mode 100644 index 0000000000..c65e7e7919 --- /dev/null +++ b/browser/fxr/content/fxrui_blue.css @@ -0,0 +1,72 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + /* These not-very-descriptive variable names for colors come + * from the design documents and are maintained to make it + * easier to map between the stylesheet and the design doc. + */ +:root { + --num01: #1D2E3B; + --num02: #4C495C; + --num03: #7D8896; + --num04: #B3BECC; + --num06: #FFFFFF; + --num07: #00B3E3; + --num08: #56D9F6; + --num09: #0968B6; + --num13: #2C3A50; + --num13_alpha: #2C3A5080; + --num14: #596677; + --num14_alpha: #59667780; + --num16: #E7EAF0; + --num19: #FFFFFF; + + --secure: #f7ce4d; +} + +body { + background-color: var(--num01); + color: var(--num06); +} + +.icon_container { + background-color: var(--num02); + border-color: transparent; + fill: var(--num06); +} +.icon_container:hover { + background-color: var(--num01); + fill: var(--num06); +} +.icon_container:active { + background-color: var(--num04); + fill: var(--num06); +} +.icon_container:disabled { + background-color: var(--num16); + fill: var(--num14); +} + +.urlbar_container { + border-color: transparent; + background-color: var(--num02); +} +.urlbar_container:hover { + border-color:var(--num04); +} +.urlbar_container:focus-within { + border-color:var(--num08); + background-color: var(--num01); +} + +.urlbar_secure_icon { + fill: var(--secure); +} + +.urlbar_input { + color: var(--num06); +} +.urlbar_input::selection { + background-color: var(--num08); +} diff --git a/browser/fxr/content/permissions.js b/browser/fxr/content/permissions.js new file mode 100644 index 0000000000..ee8d8fbd42 --- /dev/null +++ b/browser/fxr/content/permissions.js @@ -0,0 +1,145 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* import-globals-from fxrui.js */ + +/** + * Code to manage Permissions UI + * + * FxR on Desktop only supports granting permission for + * - Location + * - Camera + * - Microphone + * Any other permissions are automatically denied. + * + */ + +// Base class for managing permissions in FxR on PC +class FxrPermissionPromptPrototype { + constructor(aRequest, aBrowser, aCallback) { + this.request = aRequest; + this.targetBrowser = aBrowser; + this.responseCallback = aCallback; + } + + showPrompt() { + // For now, all permissions default to denied. Testing for allow must be + // done manually until UI is finished: + // Bug 1594840 - Add UI for Web Permissions in FxR for Desktop + this.defaultDeny(); + } + + defaultDeny() { + this.handleResponse(false); + } + + handleResponse(allowed) { + if (allowed) { + this.allow(); + } else { + this.deny(); + } + + this.responseCallback(); + } +} + +// WebRTC-specific class implementation +class FxrWebRTCPrompt extends FxrPermissionPromptPrototype { + showPrompt() { + for (let typeName of this.request.requestTypes) { + if (typeName !== "Microphone" && typeName !== "Camera") { + // Only Microphone and Camera requests are allowed. Automatically deny + // any other request. + this.defaultDeny(); + return; + } + } + + super.showPrompt(); + } + + allow() { + let { audioDevices, videoDevices } = this.request; + + let principal = Services.scriptSecurityManager.createContentPrincipalFromOrigin( + this.request.origin + ); + + // For now, collect the first audio and video device by default. User + // selection will be enabled later: + // Bug 1594841 - Add UI to select device for WebRTC in FxR for Desktop + let allowedDevices = []; + + if (audioDevices.length) { + allowedDevices.push(audioDevices[0].deviceIndex); + } + + if (videoDevices.length) { + Services.perms.addFromPrincipal( + principal, + "MediaManagerVideo", + Services.perms.ALLOW_ACTION, + Services.perms.EXPIRE_SESSION + ); + allowedDevices.push(videoDevices[0].deviceIndex); + } + + // WebRTCChild doesn't currently care which actor + // this is sent to and just uses the windowID. + this.targetBrowser.sendMessageToActor( + "webrtc:Allow", + { + callID: this.request.callID, + windowID: this.request.windowID, + devices: allowedDevices, + }, + "WebRTC" + ); + } + + deny() { + this.targetBrowser.sendMessageToActor( + "webrtc:Deny", + { + callID: this.request.callID, + windowID: this.request.windowID, + }, + "WebRTC" + ); + } +} + +// Implementation for other, non-WebRTC web permission prompts +class FxrContentPrompt extends FxrPermissionPromptPrototype { + showPrompt() { + // Only allow exactly one permission request here. + let types = this.request.types.QueryInterface(Ci.nsIArray); + if (types.length != 1) { + this.defaultDeny(); + return; + } + + // Only Location is supported from this type of request + let type = types.queryElementAt(0, Ci.nsIContentPermissionType).type; + if (type !== "geolocation") { + this.defaultDeny(); + return; + } + + // Override type so that it can be more easily interpreted by the code + // for the prompt. + type = "Location"; + super.showPrompt(); + } + + allow() { + this.request.allow(); + } + + deny() { + this.request.cancel(); + } +} diff --git a/browser/fxr/content/prefs.css b/browser/fxr/content/prefs.css new file mode 100644 index 0000000000..dd7099df24 --- /dev/null +++ b/browser/fxr/content/prefs.css @@ -0,0 +1,185 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +body { + margin: 10px 50px; + background-color: var(--num06); + color: var(--num13); +} + +.plain_button { + border: none; + background-color: transparent; +} + +.settings_header{ + display: flex; + flex-direction: row; +} + +.icon_backward { + height: 30px; + width: 30px; + + margin: 20px 70px 70px 20px; + + background-image: url("assets/icon-backward.svg"); + -moz-context-properties: fill; + fill: var(--num14); +} +.icon_backward:hover { + height: 40px; + width: 40px; + margin: 15px 65px 65px 15px; + + fill: var(--num07); +} +.icon_backward:active { + height: 40px; + width: 40px; + margin: 15px 65px 65px 15px; + + fill: var(--num09); +} + +.about_container { + flex-grow: 1; + text-align: center; +} + +.fxr_logo { + width: 72px; + height: 72px; +} + +.version_text { + font-size: 10px; + color: var(--num14); +} + +.button_report_issue { + height: 50px; + width: 110px; + margin: 20px 0px 70px 10px; + + font-size: 10px; + text-align: start; + + -moz-context-properties: fill; + fill: var(--num14); +} +.button_report_issue:hover { + fill: var(--num07); +} +.button_report_issue:active { + fill: var(--num09); +} + +.button_report_issue_icon { + float:left; + height: 30px; + margin: 5px; +} + +.button_report_text { + color: var(--num13); +} + +.button_report_url { + color: var(--num14); +} + +.settings_title { + font-size: 22px; + font-weight: bold; + color: var(--num13); + text-align: center; + + flex-grow: 1; +} + +.divider { + border-style: solid; + border-width: 1px; + border-color: var(--num04); + margin: 10px; +} + +.setting_container { + display: flex; + flex-direction: row; + + margin: 10px 5px; +} + +.setting_name { + font-size: 14px; + color: var(--num13); + + flex-grow: 1; +} + +.setting_description { + font-size: 10px; + color: var(--num14); + margin: 0 10px; +} + +.setting_control { + min-width: 120px; + margin: 5px 0px; +} + +button.setting_control { + height: 30px; + + font-size: 14px; + font-weight: bold; + + border: 2px solid var(--num08); + border-radius: 5px; + + background-color: var(--num06); +} +button.setting_control:hover { + background-color: var(--num07); + border-color: var(--num07); +} +button.setting_control:active { + background-color: var(--num09); + border-color: var(--num09); + color: var(--num19); +} +button.setting_control:disabled { + background-color: var(--num06); + border-color: var(--num08); + color: var(--num03); +} + +.clear_confirmation { + padding: 20px; + background-color: var(--num19); + border-radius: 20px; +} + +.setting_control_chk { + opacity: 0; +} +.setting_control_chk + label { + background-position: right; + background-size: contain; + background-repeat: no-repeat; + + background-image: url("assets/icon-toggle-off.png"); +} +.setting_control_chk:checked + label { + background-image: url("assets/icon-toggle-on.png"); +} +.setting_control_chk:disabled + label { + filter: grayscale(1); +} + +.modal_mask:not([hidden]) { + background-color: var(--num14_alpha); +} diff --git a/browser/fxr/content/prefs.html b/browser/fxr/content/prefs.html new file mode 100644 index 0000000000..2ced11669c --- /dev/null +++ b/browser/fxr/content/prefs.html @@ -0,0 +1,75 @@ + + + + + + + + Firefox Reality Settings + + + + + + + + +
+ +
+ +
+
+
+
+ +
+ +
Settings
+
+ +
+
Mozilla's Privacy Policy Page
+ +
+ +
+
Firefox Reality Licensing Information
+ +
+ +
+
+ Cookies, Site Data, and Cached Web Content +
+ Clearing may sign you out of websites and will require websites to reload images and data. +
+
+ +
+ + +
+
+ Allow Firefox to Anonymously Collect and Use Technical and Interaction Data +
+ + +
+ + diff --git a/browser/fxr/content/prefs.js b/browser/fxr/content/prefs.js new file mode 100644 index 0000000000..fa00066daf --- /dev/null +++ b/browser/fxr/content/prefs.js @@ -0,0 +1,119 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* import-globals-from common.js */ + +const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm"); + +var { AppConstants } = ChromeUtils.import( + "resource://gre/modules/AppConstants.jsm" +); + +const PREF_UPLOAD_ENABLED = "datareporting.healthreport.uploadEnabled"; + +window.addEventListener( + "DOMContentLoaded", + () => { + initAboutInfo(); + initClearAllData(); + initSubmitHealthReport(); + initParentDependencies(); + }, + { once: true } +); + +function initAboutInfo() { + // Bug 1586294 - Update FxR Desktop Settings to use Fluent + document.getElementById("eFxrVersion").textContent = "version 0.9"; + document.getElementById("eFxrDate").textContent = "(2019-12-17)"; + document.getElementById("eFxVersion").textContent = + "Firefox version " + Services.appinfo.version; +} + +function initClearAllData() { + let eClearPrompt = document.getElementById("eClearPrompt"); + + let eClearTry = document.getElementById("eClearTry"); + eClearTry.addEventListener("click", () => { + showModalContainer(eClearPrompt); + }); + + // Note: the calls to clearModalContainer below return eClearPrompt + // back to to be reused later, because it is moved into anothe + // element in showModalContainer. + + let eClearCancel = document.getElementById("eClearCancel"); + eClearCancel.addEventListener("click", () => { + document.body.appendChild(clearModalContainer()); + }); + + // When the confirm option is visible, do the work to actually clear the data + document.getElementById("eClearConfirm").addEventListener("click", () => { + Services.clearData.deleteData(Ci.nsIClearDataService.CLEAR_ALL, function( + aFailedFlags + ) { + if (aFailedFlags == 0) { + eClearTry.textContent = "Data cleared"; + eClearTry.disabled = true; + document.body.appendChild(clearModalContainer()); + } else { + eClearTry.textContent = "Error"; + } + }); + }); +} + +// Based on https://searchfox.org/mozilla-central/source/browser/components/preferences/privacy.js +function initSubmitHealthReport() { + let checkbox = document.getElementById("eCrashConfig"); + + // Telemetry is only sending data if MOZ_TELEMETRY_REPORTING is defined. + // We still want to display the preferences panel if that's not the case, but + // we want it to be disabled and unchecked. + if ( + Services.prefs.prefIsLocked(PREF_UPLOAD_ENABLED) || + !AppConstants.MOZ_TELEMETRY_REPORTING + ) { + checkbox.disabled = true; + } else { + checkbox.addEventListener("change", updateSubmitHealthReport); + + checkbox.checked = + Services.prefs.getBoolPref(PREF_UPLOAD_ENABLED) && + AppConstants.MOZ_TELEMETRY_REPORTING; + } +} + +/** + * Update the health report preference with state from checkbox. + */ +function updateSubmitHealthReport() { + let checkbox = document.getElementById("eCrashConfig"); + Services.prefs.setBoolPref(PREF_UPLOAD_ENABLED, checkbox.checked); +} + +// prefs.html can be loaded as another from fxrui.html. In this +// scenario, some actions are propogated to the parent +function initParentDependencies() { + if (window.parent != window) { + // Close the instance that loaded this page + document.getElementById("eCloseSettings").addEventListener("click", () => { + window.parent.closeSettings(); + }); + + // Load the relevant URLs into the top UI's + document.getElementById("ePrivacyPolicy").addEventListener("click", () => { + window.parent.showPrivacyPolicy(); + }); + + document.getElementById("eLicenseInfo").addEventListener("click", () => { + window.parent.showLicenseInfo(); + }); + + document.getElementById("eReportIssue").addEventListener("click", () => { + window.parent.showReportIssue(); + }); + } +} diff --git a/browser/fxr/jar.mn b/browser/fxr/jar.mn new file mode 100644 index 0000000000..4d2cf70711 --- /dev/null +++ b/browser/fxr/jar.mn @@ -0,0 +1,31 @@ +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#if defined(NIGHTLY_BUILD) +browser.jar: +% content fxr %content/browser/fxr/ + content/browser/fxr/common.css (content/common.css) + content/browser/fxr/common.js (content/common.js) + content/browser/fxr/fxrui.html (content/fxrui.html) + content/browser/fxr/fxrui.css (content/fxrui.css) + content/browser/fxr/fxrui_blue.css (content/fxrui_blue.css) + content/browser/fxr/fxrui.js (content/fxrui.js) + content/browser/fxr/fxr-content.js (content/fxr-content.js) + content/browser/fxr/fxr-fullScreen.js (content/fxr-fullScreen.js) + content/browser/fxr/permissions.js (content/permissions.js) + content/browser/fxr/prefs.html (content/prefs.html) + content/browser/fxr/prefs.css (content/prefs.css) + content/browser/fxr/prefs.js (content/prefs.js) + + content/browser/fxr/assets/icon-backward.svg (content/assets/icon-backward.svg) + content/browser/fxr/assets/icon-forward.svg (content/assets/icon-forward.svg) + content/browser/fxr/assets/icon-home.svg (content/assets/icon-home.svg) + content/browser/fxr/assets/icon-logo-settings-preview.png (content/assets/icon-logo-settings-preview.png) + content/browser/fxr/assets/icon-reportissue.svg (content/assets/icon-reportissue.svg) + content/browser/fxr/assets/icon-secure.svg (content/assets/icon-secure.svg) + content/browser/fxr/assets/icon-settings.svg (content/assets/icon-settings.svg) + content/browser/fxr/assets/icon-stop-reload.svg (content/assets/icon-stop-reload.svg) + content/browser/fxr/assets/icon-toggle-off.png (content/assets/icon-toggle-off.png) + content/browser/fxr/assets/icon-toggle-on.png (content/assets/icon-toggle-on.png) +#endif diff --git a/browser/fxr/moz.build b/browser/fxr/moz.build new file mode 100644 index 0000000000..d988c0ff9b --- /dev/null +++ b/browser/fxr/moz.build @@ -0,0 +1,7 @@ +# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*- +# vim: set filetype=python: +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +JAR_MANIFESTS += ["jar.mn"] -- cgit v1.2.3