diff --git a/anaconda.spec.in b/anaconda.spec.in index b8d5fc6ae5fe..4c509fc9fdd4 100644 --- a/anaconda.spec.in +++ b/anaconda.spec.in @@ -441,6 +441,15 @@ rm -rf \ %{_datadir}/cockpit/anaconda-webui/manifest.json %{_datadir}/metainfo/org.cockpit-project.anaconda-webui.metainfo.xml %{_datadir}/cockpit/anaconda-webui/po.*.js.gz +%dir %{_datadir}/anaconda/firefox-theme +%dir %{_datadir}/anaconda/firefox-theme/default +%dir %{_datadir}/anaconda/firefox-theme/default/chrome +%{_datadir}/anaconda/firefox-theme/default/user.js +%{_datadir}/anaconda/firefox-theme/default/chrome/userChrome.css +%dir %{_datadir}/anaconda/firefox-theme/live +%dir %{_datadir}/anaconda/firefox-theme/live/chrome +%{_datadir}/anaconda/firefox-theme/live/user.js +%{_datadir}/anaconda/firefox-theme/live/chrome/userChrome.css %{_libexecdir}/webui-desktop %files gui diff --git a/pyanaconda/ui/webui/__init__.py b/pyanaconda/ui/webui/__init__.py index 111f0440b4ed..7bde7d11a235 100644 --- a/pyanaconda/ui/webui/__init__.py +++ b/pyanaconda/ui/webui/__init__.py @@ -23,9 +23,14 @@ from pyanaconda.core.util import startProgram from pyanaconda.anaconda_loggers import get_module_logger from pyanaconda.core.threads import thread_manager +from pyanaconda.core.configuration.anaconda import conf + +from pyanaconda.core.path import make_directories log = get_module_logger(__name__) +FIREFOX_THEME_DEFAULT = "default" +FIREFOX_THEME_LIVE = "live" class CockpitUserInterface(ui.UserInterface): """This is the main class for Cockpit user interface.""" @@ -113,8 +118,15 @@ def run(self): # This is read by cockpit-desktop and makes it launch Firefox in kiosk mode # instead of the GTK WebKit based web view it launches by default. + # FIXME: looks like "type" should not be used and _is_live_os is private ? + if conf.system.provides_liveuser: + profile_name = FIREFOX_THEME_LIVE + else: + profile_name = FIREFOX_THEME_DEFAULT + proc = startProgram(["/usr/libexec/webui-desktop", - "/cockpit/@localhost/anaconda-webui/index.html"], + "/cockpit/@localhost/anaconda-webui/index.html", + profile_name], reset_lang=False) log.debug("cockpit web view has been started") with open("/run/anaconda/webui_script.pid", "w") as f: diff --git a/ui/webui/Makefile.am b/ui/webui/Makefile.am index fa96a4217849..df90d6fec380 100644 --- a/ui/webui/Makefile.am +++ b/ui/webui/Makefile.am @@ -56,11 +56,13 @@ rsync: install-data-hook: $(WEBPACK_TEST) mkdir -p $(DESTDIR)/usr/share/cockpit/$(PACKAGE_NAME) cp -r dist/* $(DESTDIR)/usr/share/cockpit/$(PACKAGE_NAME) + mkdir -p $(DESTDIR)/usr/share/anaconda + cp -r firefox-theme $(DESTDIR)/usr/share/anaconda/ mkdir -p $(DESTDIR)/usr/share/metainfo/ cp org.cockpit-project.$(PACKAGE_NAME).metainfo.xml $(DESTDIR)/usr/share/metainfo/ cp webui-desktop $(DESTDIR)/usr/libexec/ -EXTRA_DIST = dist src +EXTRA_DIST = dist src firefox-theme # checkout common files from Cockpit repository required to build this project; # this has no API stability guarantee, so check out a stable tag when you start diff --git a/ui/webui/firefox-theme/default/chrome/userChrome.css b/ui/webui/firefox-theme/default/chrome/userChrome.css new file mode 100644 index 000000000000..b3100cc9177a --- /dev/null +++ b/ui/webui/firefox-theme/default/chrome/userChrome.css @@ -0,0 +1,30 @@ +/* Adjust the tab, making it fit the text */ +.tabbrowser-tab { + -moz-window-dragging: drag; + margin: auto !important; + max-width: fit-content !important; +} + +/* Adjust the tab's background to match the titlebar */ +.tab-background { + -moz-window-dragging: drag; + background: transparent !important; + box-shadow: none !important; +} + +/* Hide a lot of things we're not going to use */ +#tab-notification-deck, +#PersonalToolbar, +.tab-close-button, +.titlebar-spacer, +.titlebar-close, +#alltabs-button, +#statuspanel { + display: none; +} + +/* Firefox won't load pages if you outright hide the navbar, so we're tricksy */ +#nav-bar { + position: absolute !important; + top: 100%; +} \ No newline at end of file diff --git a/ui/webui/firefox-theme/default/user.js b/ui/webui/firefox-theme/default/user.js new file mode 100644 index 000000000000..f689113501b9 --- /dev/null +++ b/ui/webui/firefox-theme/default/user.js @@ -0,0 +1,44 @@ +// Let us use userChrome.css +user_pref("toolkit.legacyUserProfileCustomizations.stylesheets", true); + +// New windows, not tabs +user_pref("browser.link.open_newwindow", 2); +user_pref("browser.link.open_newwindow.restriction", 1); +user_pref("browser.link.open_newwindow.override.external", 2); + +// Dev stuff (for easier UI adusting with ctrl+shift+alt+i) +user_pref("browser.aboutConfig.showWarning", false); +user_pref("devtools.chrome.enabled", true); +user_pref("devtools.debugger.remote-enabled", true); +user_pref("devtools.inspector.showUserAgentStyles", true); + +// Don't have any startup page +user_pref("browser.startup.page", 0); +user_pref("browser.startup.homepage", "about:blank"); +user_pref("browser.startup.homepage_override.once", {}); + +// Don't use a window manager titlebar; use Firefox's built-in one +user_pref("browser.tabs.inTitlebar", 1); + +// Hide the bookmarks +user_pref("browser.toolbars.bookmarks.visibility", "never"); + +// Don't show anything special in the new tab page' +user_pref("browser.newtabpage.activity-stream.default.sites", ""); +user_pref("browser.newtabpage.activity-stream.showSponsored", false); +user_pref("browser.newtabpage.activity-stream.showSponsoredTopSites", false); + +// Remove UI stuff +user_pref("browser.uiCustomization.state", "{\"placements\":{\"widget-overflow-fixed-list\":[],\"unified-extensions-area\":[],\"nav-bar\":[\"back-button\",\"forward-button\",\"stop-reload-button\",\"urlbar-container\",\"downloads-button\",\"unified-extensions-button\"],\"toolbar-menubar\":[\"menubar-items\"],\"TabsToolbar\":[\"tabbrowser-tabs\",\"alltabs-button\"],\"PersonalToolbar\":[\"personal-bookmarks\"]},\"seen\":[\"save-to-pocket-button\",\"developer-button\"],\"dirtyAreaCache\":[\"nav-bar\",\"TabsToolbar\",\"toolbar-menubar\",\"PersonalToolbar\"],\"currentVersion\":19,\"newElementCount\":3}"); + +// Don't set a placeholder for the tab before the page loads and sets title +user_pref("browser.urlbar.placeholderName", ""); + +// Turn off calling home +user_pref("app.normandy.enabled", false); +user_pref("browser.discovery.enabled", false); +user_pref("datareporting.healthreport.uploadEnabled", false); +user_pref("datareporting.policy.dataSubmissionEnabled", false); +user_pref("toolkit.telemetry.unified", false); +user_pref("trailhead.firstrun.didSeeAboutWelcome", true); + diff --git a/ui/webui/firefox-theme/live/chrome/userChrome.css b/ui/webui/firefox-theme/live/chrome/userChrome.css new file mode 100644 index 000000000000..b3100cc9177a --- /dev/null +++ b/ui/webui/firefox-theme/live/chrome/userChrome.css @@ -0,0 +1,30 @@ +/* Adjust the tab, making it fit the text */ +.tabbrowser-tab { + -moz-window-dragging: drag; + margin: auto !important; + max-width: fit-content !important; +} + +/* Adjust the tab's background to match the titlebar */ +.tab-background { + -moz-window-dragging: drag; + background: transparent !important; + box-shadow: none !important; +} + +/* Hide a lot of things we're not going to use */ +#tab-notification-deck, +#PersonalToolbar, +.tab-close-button, +.titlebar-spacer, +.titlebar-close, +#alltabs-button, +#statuspanel { + display: none; +} + +/* Firefox won't load pages if you outright hide the navbar, so we're tricksy */ +#nav-bar { + position: absolute !important; + top: 100%; +} \ No newline at end of file diff --git a/ui/webui/firefox-theme/live/user.js b/ui/webui/firefox-theme/live/user.js new file mode 100644 index 000000000000..f689113501b9 --- /dev/null +++ b/ui/webui/firefox-theme/live/user.js @@ -0,0 +1,44 @@ +// Let us use userChrome.css +user_pref("toolkit.legacyUserProfileCustomizations.stylesheets", true); + +// New windows, not tabs +user_pref("browser.link.open_newwindow", 2); +user_pref("browser.link.open_newwindow.restriction", 1); +user_pref("browser.link.open_newwindow.override.external", 2); + +// Dev stuff (for easier UI adusting with ctrl+shift+alt+i) +user_pref("browser.aboutConfig.showWarning", false); +user_pref("devtools.chrome.enabled", true); +user_pref("devtools.debugger.remote-enabled", true); +user_pref("devtools.inspector.showUserAgentStyles", true); + +// Don't have any startup page +user_pref("browser.startup.page", 0); +user_pref("browser.startup.homepage", "about:blank"); +user_pref("browser.startup.homepage_override.once", {}); + +// Don't use a window manager titlebar; use Firefox's built-in one +user_pref("browser.tabs.inTitlebar", 1); + +// Hide the bookmarks +user_pref("browser.toolbars.bookmarks.visibility", "never"); + +// Don't show anything special in the new tab page' +user_pref("browser.newtabpage.activity-stream.default.sites", ""); +user_pref("browser.newtabpage.activity-stream.showSponsored", false); +user_pref("browser.newtabpage.activity-stream.showSponsoredTopSites", false); + +// Remove UI stuff +user_pref("browser.uiCustomization.state", "{\"placements\":{\"widget-overflow-fixed-list\":[],\"unified-extensions-area\":[],\"nav-bar\":[\"back-button\",\"forward-button\",\"stop-reload-button\",\"urlbar-container\",\"downloads-button\",\"unified-extensions-button\"],\"toolbar-menubar\":[\"menubar-items\"],\"TabsToolbar\":[\"tabbrowser-tabs\",\"alltabs-button\"],\"PersonalToolbar\":[\"personal-bookmarks\"]},\"seen\":[\"save-to-pocket-button\",\"developer-button\"],\"dirtyAreaCache\":[\"nav-bar\",\"TabsToolbar\",\"toolbar-menubar\",\"PersonalToolbar\"],\"currentVersion\":19,\"newElementCount\":3}"); + +// Don't set a placeholder for the tab before the page loads and sets title +user_pref("browser.urlbar.placeholderName", ""); + +// Turn off calling home +user_pref("app.normandy.enabled", false); +user_pref("browser.discovery.enabled", false); +user_pref("datareporting.healthreport.uploadEnabled", false); +user_pref("datareporting.policy.dataSubmissionEnabled", false); +user_pref("toolkit.telemetry.unified", false); +user_pref("trailhead.firstrun.didSeeAboutWelcome", true); + diff --git a/ui/webui/webui-desktop b/ui/webui/webui-desktop index 3df4c8ca462e..498b7fc4f764 100755 --- a/ui/webui/webui-desktop +++ b/ui/webui/webui-desktop @@ -39,7 +39,6 @@ set -eu # exec_prefix= is set because the default /usr/libexec contains "${exec_prefix}" exec_prefix="/usr" libexecdir="/usr/libexec" - if [ -z "${1:-}" ]; then echo "Usage: $0 [ssh host]" >&2 exit 1 @@ -61,7 +60,27 @@ case "$1" in ;; esac -BROWSER="/usr/bin/firefox --kiosk" +# prepare empty firefox profile dir with theme based on the passed profile id +FIREFOX_THEME_DIR="/usr/share/anaconda/firefox-theme" +FIREFOX_PROFILE_PATH="/tmp/anaconda-firefox-profile" +THEME_ID=$2 + +# make sure the profile directory exists and is empty +if [ -d ${FIREFOX_PROFILE_PATH} ] +then + echo "Cleaning up existing Anaconda Firefox profile directory." + rm -rf ${FIREFOX_PROFILE_PATH} +fi +mkdir -p ${FIREFOX_PROFILE_PATH} + +# populate the profile directory with our custom Firefox theme +# - theme id is passed as the second argument of this script +THEME_PATH="${FIREFOX_THEME_DIR}/${THEME_ID}" + +cp -a "${THEME_PATH}/." ${FIREFOX_PROFILE_PATH} + +# FIXME: is this hardcoded resolution necessary ? +BROWSER="/usr/bin/firefox --new-instance --window-size 1024,768 --profile ${FIREFOX_PROFILE_PATH}" # start browser in a temporary home dir, so that it does not interfere with your real one BROWSER_HOME=$(mktemp --directory --tmpdir cockpit.desktop.XXXXXX)