From 982e194a9898a2a5011b90b3a6226e71b38c4e3a Mon Sep 17 00:00:00 2001 From: "mr. m" <91018726+mr-cheffy@users.noreply.github.com> Date: Wed, 16 Jul 2025 17:09:16 +0200 Subject: [PATCH] chore: Rewrite prefs in rust, p=(#9491), c=workflows, winsign --- .gitignore | 1 + package.json | 5 +- prefs/ai.yaml | 19 ++ prefs/browser.yaml | 81 +++++ prefs/compact-mode.yaml | 38 +++ prefs/disablemozilla.yaml | 33 ++ .../profile/pdf.inc => prefs/downloads.yaml | 8 +- .../downloads.inc => prefs/extensions.yaml | 7 +- prefs/fullscreen.yaml | 16 + prefs/glance.yaml | 18 + prefs/gtk.yaml | 21 ++ prefs/kbs.yaml | 12 + .../app/profile/macos.inc => prefs/macos.yaml | 12 +- prefs/media.yaml | 17 + prefs/mods.yaml | 28 ++ .../split-view.inc => prefs/multilingual.yaml | 5 +- prefs/newtab.yaml | 24 ++ .../profile/extensions.inc => prefs/pdf.yaml | 10 +- prefs/performance.yaml | 10 + .../app/profile/pip.inc => prefs/pip.yaml | 7 +- prefs/privacy.yaml | 121 +++++++ prefs/smoothscroll.yaml | 49 +++ prefs/split-view.yaml | 12 + prefs/static.yaml | 16 + prefs/theme.yaml | 39 +++ prefs/urlbar.yaml | 80 +++++ prefs/view.yaml | 47 +++ prefs/watermark.yaml | 8 + prefs/welcome.yaml | 8 + prefs/windows.yaml | 19 ++ prefs/workspaces.yaml | 46 +++ prefs/zen-urlbar.yaml | 24 ++ prefs/zen.yaml | 27 ++ src/browser/app/profile/ai.inc | 9 - src/browser/app/profile/browser.inc | 55 --- src/browser/app/profile/disablemozilla.inc | 14 - src/browser/app/profile/features.inc | 41 --- .../app/profile/features/compact-mode.inc | 17 - src/browser/app/profile/features/glance.inc | 9 - src/browser/app/profile/features/kbs.inc | 7 - src/browser/app/profile/features/mods.inc | 17 - src/browser/app/profile/features/theme.inc | 25 -- src/browser/app/profile/features/urlbar.inc | 11 - src/browser/app/profile/features/view.inc | 29 -- .../app/profile/features/workspaces.inc | 25 -- src/browser/app/profile/firefox-js.patch | 10 - src/browser/app/profile/fullscreen.inc | 8 - src/browser/app/profile/linux.inc | 14 - src/browser/app/profile/media.inc | 9 - src/browser/app/profile/newtab.inc | 12 - src/browser/app/profile/performance.inc | 18 - src/browser/app/profile/privacy.inc | 47 --- src/browser/app/profile/smoothscroll.inc | 15 - src/browser/app/profile/urlbar.inc | 35 -- src/browser/app/profile/windows.inc | 12 - src/browser/app/profile/zen-browser.js | 41 --- src/modules/libpref/init/zen-static-prefs.inc | 23 +- tools/ffprefs/Cargo.lock | 119 +++++++ tools/ffprefs/Cargo.toml | 8 + tools/ffprefs/src/main.rs | 315 ++++++++++++++++++ 60 files changed, 1303 insertions(+), 510 deletions(-) create mode 100644 prefs/ai.yaml create mode 100644 prefs/browser.yaml create mode 100644 prefs/compact-mode.yaml create mode 100644 prefs/disablemozilla.yaml rename src/browser/app/profile/pdf.inc => prefs/downloads.yaml (60%) rename src/browser/app/profile/features/downloads.inc => prefs/extensions.yaml (64%) create mode 100644 prefs/fullscreen.yaml create mode 100644 prefs/glance.yaml create mode 100644 prefs/gtk.yaml create mode 100644 prefs/kbs.yaml rename src/browser/app/profile/macos.inc => prefs/macos.yaml (58%) create mode 100644 prefs/media.yaml create mode 100644 prefs/mods.yaml rename src/browser/app/profile/features/split-view.inc => prefs/multilingual.yaml (59%) create mode 100644 prefs/newtab.yaml rename src/browser/app/profile/extensions.inc => prefs/pdf.yaml (54%) create mode 100644 prefs/performance.yaml rename src/browser/app/profile/pip.inc => prefs/pip.yaml (58%) create mode 100644 prefs/privacy.yaml create mode 100644 prefs/smoothscroll.yaml create mode 100644 prefs/split-view.yaml create mode 100644 prefs/static.yaml create mode 100644 prefs/theme.yaml create mode 100644 prefs/urlbar.yaml create mode 100644 prefs/view.yaml create mode 100644 prefs/watermark.yaml create mode 100644 prefs/welcome.yaml create mode 100644 prefs/windows.yaml create mode 100644 prefs/workspaces.yaml create mode 100644 prefs/zen-urlbar.yaml create mode 100644 prefs/zen.yaml delete mode 100644 src/browser/app/profile/ai.inc delete mode 100644 src/browser/app/profile/browser.inc delete mode 100644 src/browser/app/profile/disablemozilla.inc delete mode 100644 src/browser/app/profile/features.inc delete mode 100644 src/browser/app/profile/features/compact-mode.inc delete mode 100644 src/browser/app/profile/features/glance.inc delete mode 100644 src/browser/app/profile/features/kbs.inc delete mode 100644 src/browser/app/profile/features/mods.inc delete mode 100644 src/browser/app/profile/features/theme.inc delete mode 100644 src/browser/app/profile/features/urlbar.inc delete mode 100644 src/browser/app/profile/features/view.inc delete mode 100644 src/browser/app/profile/features/workspaces.inc delete mode 100644 src/browser/app/profile/firefox-js.patch delete mode 100644 src/browser/app/profile/fullscreen.inc delete mode 100644 src/browser/app/profile/linux.inc delete mode 100644 src/browser/app/profile/media.inc delete mode 100644 src/browser/app/profile/newtab.inc delete mode 100644 src/browser/app/profile/performance.inc delete mode 100644 src/browser/app/profile/privacy.inc delete mode 100644 src/browser/app/profile/smoothscroll.inc delete mode 100644 src/browser/app/profile/urlbar.inc delete mode 100644 src/browser/app/profile/windows.inc delete mode 100644 src/browser/app/profile/zen-browser.js create mode 100644 tools/ffprefs/Cargo.lock create mode 100644 tools/ffprefs/Cargo.toml create mode 100644 tools/ffprefs/src/main.rs diff --git a/.gitignore b/.gitignore index d1dc1efdc..e680c37a5 100644 --- a/.gitignore +++ b/.gitignore @@ -14,4 +14,5 @@ venv/ win-cross/ !firefox-patches/ +target/ .vscode/ diff --git a/package.json b/package.json index dcc39a4e2..e260a37cc 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "**/*": "" }, "scripts": { - "build": "surfer build", + "build": "npm run ffprefs && surfer build", "build:ui": "surfer build --ui", "start": "cd engine && ./mach run --noprofile", "import": "surfer import", @@ -25,7 +25,8 @@ "reset-ff": "surfer reset", "surfer": "surfer", "test": "python3 scripts/run_tests.py", - "test:dbg": "python3 scripts/run_tests.py --jsdebugger --debug-on-failure" + "test:dbg": "python3 scripts/run_tests.py --jsdebugger --debug-on-failure", + "ffprefs": "cd tools/ffprefs && cargo run --release --bin ffprefs -- ../../" }, "repository": { "type": "git", diff --git a/prefs/ai.yaml b/prefs/ai.yaml new file mode 100644 index 000000000..cdeb20691 --- /dev/null +++ b/prefs/ai.yaml @@ -0,0 +1,19 @@ +# 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/. + +# Machine learning and chat feature preferences +- name: browser.ml.chat.enabled + value: false + +- name: browser.ml.chat.shortcuts + value: false + +- name: browser.ml.chat.shortcuts.custom + value: false + +- name: browser.ml.chat.sidebar + value: false + +- name: browser.ml.enable + value: false diff --git a/prefs/browser.yaml b/prefs/browser.yaml new file mode 100644 index 000000000..5e2f558dc --- /dev/null +++ b/prefs/browser.yaml @@ -0,0 +1,81 @@ +# 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/. + +- name: browser.startup.page + value: 3 + +- name: browser.sessionstore.restore_pinned_tabs_on_demand + value: true + +- name: browser.tabs.loadBookmarksInTabs + value: false + +- name: browser.tabs.hoverPreview.enabled + value: false + +- name: browser.tabs.dragdrop.moveOverThresholdPercent + value: 50 + +- name: browser.tabs.unloadTabInContextMenu + value: true + +- name: browser.tabs.fadeOutExplicitlyUnloadedTabs + value: true + +- name: browser.toolbars.bookmarks.visibility + value: 'never' + +- name: browser.bookmarks.openInTabClosesMenu + value: false + +- name: browser.menu.showViewImageInfo + value: true + +- name: findbar.highlightAll + value: true + +- name: layout.word_select.eat_space_to_next_word + value: false + +- name: widget.non-native-theme.scrollbar.style + value: 2 + +- name: widget.non-native-theme.use-theme-accent + value: true + +- name: browser.download.autohideButton + value: false + +- name: sidebar.revamp + value: false + locked: true + +- name: sidebar.verticalTabs + value: false + locked: true + +- name: browser.preferences.experimental + value: true + +- name: browser.download.manager.addToRecentDocs + value: false + +- name: browser.download.open_pdf_attachments_inline + value: true + +- name: browser.download.alwaysOpenPanel + value: false + +- name: app.update.checkInstallTime.days + value: 6 + condition: 'defined(MOZILLA_OFFICIAL)' + +- name: browser.profiles.enabled + value: false + +- name: browser.tabs.groups.enabled + value: false + +- name: browser.urlbar.scotchBonnet.enableOverride + value: false diff --git a/prefs/compact-mode.yaml b/prefs/compact-mode.yaml new file mode 100644 index 000000000..2470ffcd6 --- /dev/null +++ b/prefs/compact-mode.yaml @@ -0,0 +1,38 @@ +# 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/. + +- name: zen.view.compact.hide-tabbar + value: true + +- name: zen.view.compact.hide-toolbar + value: false + +- name: zen.view.compact.toolbar-flash-popup + value: false + +- name: zen.view.compact.toolbar-flash-popup.duration + value: 800 + +- name: zen.view.compact.toolbar-hide-after-hover.duration + value: 1000 + +- name: zen.view.compact.color-toolbar + value: true + +- name: zen.view.compact.color-sidebar + value: true + +- name: zen.view.compact.animate-sidebar + value: true + +- name: zen.view.compact.show-sidebar-and-toolbar-on-hover + value: true + +- name: zen.view.compact.show-background-tab-toast + value: true + +# Do not edit manually +- name: zen.view.compact.should-enable-at-startup + hidden: true + value: false diff --git a/prefs/disablemozilla.yaml b/prefs/disablemozilla.yaml new file mode 100644 index 000000000..a98088d12 --- /dev/null +++ b/prefs/disablemozilla.yaml @@ -0,0 +1,33 @@ +# 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/. + +- name: browser.privatebrowsing.vpnpromourl + value: '' + locked: true + +- name: extensions.getAddons.showPane + value: false + +- name: extensions.htmlaboutaddons.recommendations.enabled + value: false + +- name: browser.discovery.enabled + value: false + +- name: browser.newtabpage.activity-stream.asrouter.userprefs.cfr.addons + value: false + +- name: browser.newtabpage.activity-stream.asrouter.userprefs.cfr.features + value: false + +- name: browser.preferences.moreFromMozilla + value: false + locked: true + +- name: browser.aboutwelcome.enabled + value: false + +- name: browser.contentblocking.report.show_mobile_app + value: false + locked: true diff --git a/src/browser/app/profile/pdf.inc b/prefs/downloads.yaml similarity index 60% rename from src/browser/app/profile/pdf.inc rename to prefs/downloads.yaml index 37361dffb..94a507fb6 100644 --- a/src/browser/app/profile/pdf.inc +++ b/prefs/downloads.yaml @@ -2,6 +2,8 @@ # 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/. -pref('pdfjs.enableHighlightEditor', true); -pref('pdfjs.enableHighlightFloatingButton', true); -pref("pdfjs.enableScripting", false); +- name: zen.downloads.download-animation + value: true + +- name: zen.downloads.download-animation-duration + value: 1000 # ms diff --git a/src/browser/app/profile/features/downloads.inc b/prefs/extensions.yaml similarity index 64% rename from src/browser/app/profile/features/downloads.inc rename to prefs/extensions.yaml index 027afb70e..9578ddb69 100644 --- a/src/browser/app/profile/features/downloads.inc +++ b/prefs/extensions.yaml @@ -2,5 +2,8 @@ # 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/. -pref('zen.downloads.download-animation', true); -pref('zen.downloads.download-animation-duration', 1000); // ms +- name: xpinstall.signatures.required + value: true + +- name: extensions.pocket.enabled + value: false diff --git a/prefs/fullscreen.yaml b/prefs/fullscreen.yaml new file mode 100644 index 000000000..9b9ef1e17 --- /dev/null +++ b/prefs/fullscreen.yaml @@ -0,0 +1,16 @@ +# 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/. + +# Fullscreen API preferences +- name: full-screen-api.transition-duration.enter + value: '0 0' + +- name: full-screen-api.transition-duration.leave + value: '0 0' + +- name: full-screen-api.warning.delay + value: -1 + +- name: full-screen-api.warning.timeout + value: 0 diff --git a/prefs/glance.yaml b/prefs/glance.yaml new file mode 100644 index 000000000..cae4738d2 --- /dev/null +++ b/prefs/glance.yaml @@ -0,0 +1,18 @@ +# 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/. + +- name: zen.glance.enabled + value: true + +- name: zen.glance.enable-contextmenu-search + value: true + +- name: zen.glance.hold-duration + value: 300 # in ms + +- name: zen.glance.open-essential-external-links + value: true + +- name: zen.glance.activation-method + value: 'alt' # ctrl, alt, shift, none, hold diff --git a/prefs/gtk.yaml b/prefs/gtk.yaml new file mode 100644 index 000000000..9f8a6e226 --- /dev/null +++ b/prefs/gtk.yaml @@ -0,0 +1,21 @@ +# 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/. + +# GTK-specific preferences +- name: widget.gtk.rounded-bottom-corners.enabled + value: true + condition: 'defined(MOZ_WIDGET_GTK) && defined(UNIX_BUT_NOT_MAC)' + +- name: zen.widget.linux.transparency + value: false + condition: 'defined(MOZ_WIDGET_GTK)' + +# VAAPI/FFmpeg preferences for Linux +- name: media.ffmpeg.vaapi.enabled + value: true + condition: 'defined(MOZ_WIDGET_GTK)' + +- name: media.ffmpeg.encoder.enabled + value: true + condition: 'defined(MOZ_WIDGET_GTK)' diff --git a/prefs/kbs.yaml b/prefs/kbs.yaml new file mode 100644 index 000000000..56a9c7bf3 --- /dev/null +++ b/prefs/kbs.yaml @@ -0,0 +1,12 @@ +# 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/. + +- name: zen.keyboard.shortcuts.enabled + value: true + +- name: zen.keyboard.shortcuts.version + value: 0 # Empty string means default shortcuts + +- name: zen.keyboard.shortcuts.disable-mainkeyset-clear + value: false # for debugging diff --git a/src/browser/app/profile/macos.inc b/prefs/macos.yaml similarity index 58% rename from src/browser/app/profile/macos.inc rename to prefs/macos.yaml index d2f80fc86..55d86a13f 100644 --- a/src/browser/app/profile/macos.inc +++ b/prefs/macos.yaml @@ -3,7 +3,10 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. # Enable transparent background for macos -pref('widget.macos.sidebar-blend-mode.behind-window', true); +- name: widget.macos.sidebar-blend-mode.behind-window + value: true + condition: 'defined(XP_MACOSX)' + # 1. hudWindow # 2. fullScreenUI # 3. popover @@ -11,4 +14,9 @@ pref('widget.macos.sidebar-blend-mode.behind-window', true); # 5. toolTip # 6. headerView # 7. underlay -pref('zen.widget.macos.window-material', 1); +- name: zen.widget.macos.window-material + value: 1 + condition: 'defined(XP_MACOSX)' + cpptype: uint32_t + mirror: always + type: static diff --git a/prefs/media.yaml b/prefs/media.yaml new file mode 100644 index 000000000..d5a63db23 --- /dev/null +++ b/prefs/media.yaml @@ -0,0 +1,17 @@ +# 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/. + +- name: image.jxl.enabled + value: true + locked: true + +- name: svg.context-properties.content.enabled + value: true + +- name: image.avif.enabled + value: true + locked: true + +- name: media.eme.enabled + value: true diff --git a/prefs/mods.yaml b/prefs/mods.yaml new file mode 100644 index 000000000..8e506c9a8 --- /dev/null +++ b/prefs/mods.yaml @@ -0,0 +1,28 @@ +# 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/. + +- name: zen.mods.updated-value-observer + value: false + +- name: zen.mods.auto-update-days + value: 20 # In days + +- name: zen.mods.auto-update + value: '@cond' + condition: 'defined(MOZILLA_OFFICIAL)' + +- name: zen.rice.share.notice.accepted + value: false + +# === Mark: Site Injection === + +- name: zen.injections.match-urls + value: 'https://zen-browser.app/*' + locked: true + condition: 'defined(MOZILLA_OFFICIAL)' + +- name: zen.injections.match-urls + value: 'http://localhost/*' + locked: true + condition: '!defined(MOZILLA_OFFICIAL)' diff --git a/src/browser/app/profile/features/split-view.inc b/prefs/multilingual.yaml similarity index 59% rename from src/browser/app/profile/features/split-view.inc rename to prefs/multilingual.yaml index 95bd25af1..2fd893f46 100644 --- a/src/browser/app/profile/features/split-view.inc +++ b/prefs/multilingual.yaml @@ -2,6 +2,5 @@ # 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/. -pref('zen.splitView.enable-tab-drop', true); -pref('zen.splitView.min-resize-width', 7); -pref('zen.splitView.rearrange-hover-size', 24); +- name: intl.multilingual.downloadEnabled + value: false diff --git a/prefs/newtab.yaml b/prefs/newtab.yaml new file mode 100644 index 000000000..30b330d30 --- /dev/null +++ b/prefs/newtab.yaml @@ -0,0 +1,24 @@ +# 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/. + +- name: browser.newtabpage.activity-stream.feeds.topsites + value: false + +- name: browser.newtabpage.activity-stream.feeds.section.topstories + value: false + +- name: browser.topsites.contile.enabled + value: false + +- name: browser.newtabpage.activity-stream.system.showWeather + value: false + +- name: browser.newtabpage.activity-stream.newtabWallpapers.enabled + value: true + +- name: browser.newtabpage.activity-stream.newtabWallpapers.v2.enabled + value: true + +- name: browser.translations.newSettingsUI.enable + value: true diff --git a/src/browser/app/profile/extensions.inc b/prefs/pdf.yaml similarity index 54% rename from src/browser/app/profile/extensions.inc rename to prefs/pdf.yaml index 2a428d27c..d9e68e7cb 100644 --- a/src/browser/app/profile/extensions.inc +++ b/prefs/pdf.yaml @@ -2,7 +2,11 @@ # 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/. -// security: They must enable this themselves, to avoid people downloading malware -pref('xpinstall.signatures.required', true); -pref("extensions.pocket.enabled", false); +- name: pdfjs.enableHighlightEditor + value: true +- name: pdfjs.enableHighlightFloatingButton + value: true + +- name: pdfjs.enableScripting + value: false diff --git a/prefs/performance.yaml b/prefs/performance.yaml new file mode 100644 index 000000000..5b4455ee5 --- /dev/null +++ b/prefs/performance.yaml @@ -0,0 +1,10 @@ +# 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/. + +- name: browser.lowMemoryResponseMask + value: 3 + condition: 'defined(XP_MACOSX)' + +- name: network.predictor.enable-hover-on-ssl + value: true diff --git a/src/browser/app/profile/pip.inc b/prefs/pip.yaml similarity index 58% rename from src/browser/app/profile/pip.inc rename to prefs/pip.yaml index 95d3ae644..66d5d9796 100644 --- a/src/browser/app/profile/pip.inc +++ b/prefs/pip.yaml @@ -2,6 +2,9 @@ # 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/. -pref("media.videocontrols.picture-in-picture.video-toggle.enabled", true); +- name: media.videocontrols.picture-in-picture.video-toggle.enabled + value: true + # TODO: Enable once we have a proper settings page -pref("media.videocontrols.picture-in-picture.enable-when-switching-tabs.enabled", false); +- name: media.videocontrols.picture-in-picture.enable-when-switching-tabs.enabled + value: false diff --git a/prefs/privacy.yaml b/prefs/privacy.yaml new file mode 100644 index 000000000..daa070691 --- /dev/null +++ b/prefs/privacy.yaml @@ -0,0 +1,121 @@ +# 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/. + +# Telemetry & Data Reporting +- name: datareporting.policy.dataSubmissionEnabled + value: false + locked: true + +- name: datareporting.healthreport.uploadEnabled + value: false + locked: true + +- name: toolkit.telemetry.unified + value: false + locked: true + +- name: toolkit.telemetry.enabled + value: false + locked: true + +- name: toolkit.telemetry.server + value: 'data:,' + locked: true + +- name: toolkit.telemetry.archive.enabled + value: false + locked: true + +- name: toolkit.telemetry.newProfilePing.enabled + value: false + locked: true + +- name: toolkit.telemetry.shutdownPingSender.enabled + value: false + locked: true + +- name: toolkit.telemetry.updatePing.enabled + value: false + locked: true + +- name: toolkit.telemetry.bhrPing.enabled + value: false + locked: true + +- name: toolkit.telemetry.firstShutdownPing.enabled + value: false + locked: true + +- name: toolkit.telemetry.coverage.opt-out + value: true + locked: true + +- name: toolkit.coverage.opt-out + value: true + locked: true + +- name: toolkit.coverage.endpoint.base + value: '' + locked: true + +- name: browser.newtabpage.activity-stream.feeds.telemetry + value: false + locked: true + +- name: browser.newtabpage.activity-stream.telemetry + value: false + locked: true + +- name: browser.ping-centre.telemetry + value: false + +- name: browser.attribution.enabled + value: false + +- name: toolkit.telemetry.pioneer-new-studies-available + value: false + +- name: app.shield.optoutstudies.enabled + value: false + locked: true + +- name: app.normandy.enabled + value: false + +- name: app.normandy.api_url + value: '' + locked: true + +# Crash Reports +- name: breakpad.reportURL + value: '' + +- name: browser.tabs.crashReporting.sendReport + value: false + +- name: browser.crashReports.unsubmittedCheck.autoSubmit2 + value: false + +# Privacy and Misc +- name: extensions.getAddons.cache.enabled + value: false + +- name: browser.privatebrowsing.forceMediaMemoryCache + value: true + +- name: browser.helperApps.deleteTempFileOnExit + value: true + +- name: browser.uitour.enabled + value: false + +- name: privacy.globalprivacycontrol.enabled + value: true + +# Contextual Identities +- name: privacy.userContext.enabled + value: true + +- name: privacy.userContext.ui.enabled + value: true diff --git a/prefs/smoothscroll.yaml b/prefs/smoothscroll.yaml new file mode 100644 index 000000000..186a07e89 --- /dev/null +++ b/prefs/smoothscroll.yaml @@ -0,0 +1,49 @@ +# 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/. + +# Smooth scrolling and mousewheel tuning preferences + +- name: general.smoothScroll.msdPhysics.enabled + condition: '!defined(XP_MACOSX)' + value: true + +- name: general.smoothScroll.currentVelocityWeighting + condition: '!defined(XP_MACOSX)' + value: '0.15' + +- name: general.smoothScroll.stopDecelerationWeighting + condition: '!defined(XP_MACOSX)' + value: '0.6' + +- name: mousewheel.min_line_scroll_amount + condition: '!defined(XP_MACOSX)' + value: 10 + +- name: general.smoothScroll.mouseWheel.durationMinMS + condition: '!defined(XP_MACOSX)' + value: 80 + +- name: general.smoothScroll.msdPhysics.continuousMotionMaxDeltaMS + condition: '!defined(XP_MACOSX)' + value: 12 + +- name: general.smoothScroll.msdPhysics.motionBeginSpringConstant + condition: '!defined(XP_MACOSX)' + value: 600 + +- name: general.smoothScroll.msdPhysics.regularSpringConstant + condition: '!defined(XP_MACOSX)' + value: 650 + +- name: general.smoothScroll.msdPhysics.slowdownMinDeltaMS + condition: '!defined(XP_MACOSX)' + value: 25 + +- name: general.smoothScroll.msdPhysics.slowdownSpringConstant + condition: '!defined(XP_MACOSX)' + value: 250 + +- name: mousewheel.default.delta_multiplier_y + condition: '!defined(XP_MACOSX)' + value: 200 diff --git a/prefs/split-view.yaml b/prefs/split-view.yaml new file mode 100644 index 000000000..118125f19 --- /dev/null +++ b/prefs/split-view.yaml @@ -0,0 +1,12 @@ +# 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/. + +- name: zen.splitView.enable-tab-drop + value: true + +- name: zen.splitView.min-resize-width + value: 7 + +- name: zen.splitView.rearrange-hover-size + value: 24 diff --git a/prefs/static.yaml b/prefs/static.yaml new file mode 100644 index 000000000..08789d83f --- /dev/null +++ b/prefs/static.yaml @@ -0,0 +1,16 @@ +# 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/. + +- name: zen.haptic-feedback.enabled + cpptype: bool + value: true + mirror: always + type: static + +- name: zen.swipe.is-fast-swipe + cpptype: bool + value: true + mirror: always + hidden: true + type: static diff --git a/prefs/theme.yaml b/prefs/theme.yaml new file mode 100644 index 000000000..79884652e --- /dev/null +++ b/prefs/theme.yaml @@ -0,0 +1,39 @@ +# 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/. + +- name: zen.theme.accent-color + value: '#ffb787' + +- name: zen.theme.content-element-separation + value: 8 + +- name: zen.theme.gradient + value: true + +- name: zen.theme.gradient.show-custom-colors + value: false + +- name: zen.theme.essentials-favicon-bg + value: true + +- name: zen.theme.acrylic-elements + value: false + +- name: zen.theme.disable-lightweight + value: true + +- name: zen.theme.use-sysyem-colors + value: false + +# ==== Mark: border radius ==== + +# macOS border radius +- name: zen.theme.border-radius + value: 10 + condition: 'defined(XP_MACOSX)' + +# non-macOS border radius +- name: zen.theme.border-radius + value: 8 + condition: '!defined(XP_MACOSX)' diff --git a/prefs/urlbar.yaml b/prefs/urlbar.yaml new file mode 100644 index 000000000..968987d24 --- /dev/null +++ b/prefs/urlbar.yaml @@ -0,0 +1,80 @@ +# 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/. + +# URL bar and search-related preferences + +- name: browser.urlbar.unitConversion.enabled + value: true + +- name: browser.urlbar.trending.featureGate + value: false + +- name: browser.urlbar.weather.featureGate + value: false + +- name: browser.urlbar.quickactions.enabled + value: true + +- name: browser.urlbar.clipboard.featureGate + value: true + +- name: browser.urlbar.suggest.calculator + value: true + +- name: browser.urlbar.trimHttps + value: true + +- name: browser.urlbar.untrimOnUserInteraction.featureGate + value: true + +# Keep in sync with browser/components/topsites/constants.mjs +- name: browser.urlbar.maxRichResults + value: 7 + +# Enable private suggestions +- name: browser.search.suggest.enabled + value: false + +- name: browser.search.suggest.enabled.private + value: false + +- name: browser.search.separatePrivateDefault.ui.enabled + value: true + +- name: browser.urlbar.update2.engineAliasRefresh + value: true + +- name: browser.urlbar.quicksuggest.enabled + value: false + locked: true + +- name: browser.urlbar.suggest.quicksuggest.sponsored + value: false + locked: true + +- name: browser.urlbar.suggest.quicksuggest.nonsponsored + value: false + locked: true + +- name: browser.urlbar.groupLabels.enabled + value: false + +- name: browser.urlbar.keepPanelOpenDuringImeComposition + value: true # IMPORTANT: Fixes closing the urlbar when on some languages + +- name: browser.formfill.enable + value: false + +- name: security.insecure_connection_text.enabled + value: true + +- name: security.insecure_connection_text.pbmode.enabled + value: true + +- name: network.IDN_show_punycode + value: true + +- name: browser.urlbar.suggest.topsites + value: true + locked: true diff --git a/prefs/view.yaml b/prefs/view.yaml new file mode 100644 index 000000000..fda4fe166 --- /dev/null +++ b/prefs/view.yaml @@ -0,0 +1,47 @@ +# 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/. + +- name: zen.view.sidebar-height-throttle + value: 0 + +- name: zen.view.sidebar-expanded.max-width + value: 500 + +- name: zen.view.mac.show-three-dot-menu + value: false + condition: 'defined(XP_MACOSX)' + +- name: zen.widget.mac.mono-window-controls + value: true + condition: 'defined(XP_MACOSX)' + +- name: zen.view.use-single-toolbar + value: true + +- name: zen.view.sidebar-expanded + value: true + +- name: zen.view.sidebar-collapsed.hide-mute-button + value: true + +- name: zen.view.experimental-force-window-controls-left + value: false + +- name: zen.view.hide-window-controls + value: true + +- name: zen.view.experimental-no-window-controls + value: false + +- name: zen.view.grey-out-inactive-windows + value: true + +- name: zen.view.show-newtab-button-border-top + value: false + +- name: zen.view.show-newtab-button-top + value: true + +- name: zen.view.window.scheme + value: 2 diff --git a/prefs/watermark.yaml b/prefs/watermark.yaml new file mode 100644 index 000000000..a3e443c2a --- /dev/null +++ b/prefs/watermark.yaml @@ -0,0 +1,8 @@ +# 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/. + +- name: zen.watermark.enabled + value: '@cond' + sticky: true + condition: 'defined(MOZILLA_OFFICIAL)' diff --git a/prefs/welcome.yaml b/prefs/welcome.yaml new file mode 100644 index 000000000..b0a7940b2 --- /dev/null +++ b/prefs/welcome.yaml @@ -0,0 +1,8 @@ +# 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/. + +- name: zen.welcome-screen.seen + value: '@cond' + sticky: true + condition: '!defined(MOZILLA_OFFICIAL)' diff --git a/prefs/windows.yaml b/prefs/windows.yaml new file mode 100644 index 000000000..9ef32f574 --- /dev/null +++ b/prefs/windows.yaml @@ -0,0 +1,19 @@ +# 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/. + +# Mica effect preferences for Windows +- name: widget.windows.mica + value: true + condition: 'defined(XP_WIN)' + +- name: widget.windows.mica.popups + value: true + condition: 'defined(XP_WIN)' + +# 1 = DWMSBT_MAINWINDOW +# 2 = DWMSBT_TRANSIENTWINDOW (default, also used for popups) +# 3 = DWMSBT_TABBEDWINDOW +- name: widget.windows.mica.toplevel-backdrop + value: 2 + condition: 'defined(XP_WIN)' diff --git a/prefs/workspaces.yaml b/prefs/workspaces.yaml new file mode 100644 index 000000000..00e3d617a --- /dev/null +++ b/prefs/workspaces.yaml @@ -0,0 +1,46 @@ +# 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/. + +- name: zen.workspaces.continue-where-left-off + value: false + +- name: zen.workspaces.hide-default-container-indicator + value: true + +- name: zen.workspaces.force-container-workspace + value: false + +- name: zen.workspaces.open-new-tab-if-last-unpinned-tab-is-closed + value: false + +- name: zen.workspaces.swipe-actions + value: true + +- name: zen.workspaces.wrap-around-navigation + value: true + +- name: zen.workspaces.natural-scroll + value: false + +- name: zen.workspaces.scroll-modifier-key + value: ctrl + +- name: services.sync.engine.workspaces + value: false + +- name: zen.workspaces.separate-essentials + value: true + +- name: zen.workspaces.debug + value: '@cond' + condition: '!defined(MOZILLA_OFFICIAL)' # Section: Pinned tabs management + +- name: zen.pinned-tab-manager.debug + value: false + +- name: zen.pinned-tab-manager.restore-pinned-tabs-to-pinned-url + value: false + +- name: zen.pinned-tab-manager.close-shortcut-behavior + value: reset-unload-switch diff --git a/prefs/zen-urlbar.yaml b/prefs/zen-urlbar.yaml new file mode 100644 index 000000000..9e6b435f3 --- /dev/null +++ b/prefs/zen-urlbar.yaml @@ -0,0 +1,24 @@ +# 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/. + +- name: zen.urlbar.replace-newtab + value: true + +- name: zen.urlbar.show-protections-icon + value: false + +- name: zen.urlbar.behavior + value: floating-on-type + +- name: zen.urlbar.wait-to-clear + value: 45000 + +- name: zen.urlbar.show-domain-only-in-sidebar + value: true + +- name: zen.urlbar.hide-one-offs + value: true + +- name: zen.urlbar.enable-overrides + value: false diff --git a/prefs/zen.yaml b/prefs/zen.yaml new file mode 100644 index 000000000..b507e0f15 --- /dev/null +++ b/prefs/zen.yaml @@ -0,0 +1,27 @@ +# 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/. + +- name: zen.tabs.vertical + value: true + +- name: zen.tabs.vertical.right-side + value: false + +- name: zen.tabs.rename-tabs + value: true + +- name: zen.tabs.show-newtab-vertical + value: true + +- name: zen.ctrlTab.show-pending-tabs + value: false + +- name: zen.mediacontrols.enabled + value: true + +- name: zen.haptic-feedback.enabled + value: true + +- name: zen.startup.smooth-scroll-in-tabs + value: true diff --git a/src/browser/app/profile/ai.inc b/src/browser/app/profile/ai.inc deleted file mode 100644 index a4186950f..000000000 --- a/src/browser/app/profile/ai.inc +++ /dev/null @@ -1,9 +0,0 @@ -# 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/. - -pref("browser.ml.chat.enabled", false); -pref("browser.ml.chat.shortcuts", false); -pref("browser.ml.chat.shortcuts.custom", false); -pref("browser.ml.chat.sidebar", false); -pref("browser.ml.enable", false); diff --git a/src/browser/app/profile/browser.inc b/src/browser/app/profile/browser.inc deleted file mode 100644 index eaf00fd97..000000000 --- a/src/browser/app/profile/browser.inc +++ /dev/null @@ -1,55 +0,0 @@ - -# 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/. - -// Restore session on startup -pref("browser.startup.page", 3); -pref("browser.sessionstore.restore_pinned_tabs_on_demand", true); - -// Toolbars -pref("browser.tabs.loadBookmarksInTabs", false); -pref("browser.tabs.hoverPreview.enabled", false); -pref("browser.tabs.dragdrop.moveOverThresholdPercent", 50); -pref("browser.tabs.unloadTabInContextMenu", true); -pref("browser.tabs.fadeOutExplicitlyUnloadedTabs", true); - -pref('browser.toolbars.bookmarks.visibility', 'never'); -pref("browser.bookmarks.openInTabClosesMenu", false); -pref("browser.menu.showViewImageInfo", true); -pref("findbar.highlightAll", true); - -pref("layout.word_select.eat_space_to_next_word", false); - -// Better Windows theming -pref("widget.non-native-theme.scrollbar.style", 2); -pref("widget.non-native-theme.use-theme-accent", true); - -// for the new layout: -pref('browser.download.autohideButton', false); - -// Disable Firefox's revamp -pref("sidebar.revamp", false, locked); -pref("sidebar.verticalTabs", false, locked); - -// Enable experimental settings page (Used for Zen Labs) -pref('browser.preferences.experimental', true); - -// Downloads -pref("browser.download.manager.addToRecentDocs", false); -pref('browser.download.open_pdf_attachments_inline', true); -pref('browser.download.alwaysOpenPanel', false); - -// Updates -#ifdef MOZILLA_OFFICIAL -pref("app.update.checkInstallTime.days", 6); -#endif - -#include fullscreen.inc -#include ai.inc -#include disablemozilla.inc - -// TODO: Check this out! -pref("browser.profiles.enabled", false); -pref("browser.tabs.groups.enabled", false); -pref("browser.urlbar.scotchBonnet.enableOverride", false); diff --git a/src/browser/app/profile/disablemozilla.inc b/src/browser/app/profile/disablemozilla.inc deleted file mode 100644 index eb4e9f77e..000000000 --- a/src/browser/app/profile/disablemozilla.inc +++ /dev/null @@ -1,14 +0,0 @@ -# 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/. - -// Common UI changes -pref("browser.privatebrowsing.vpnpromourl", "", locked); -pref("extensions.getAddons.showPane", false); -pref("extensions.htmlaboutaddons.recommendations.enabled", false); -pref("browser.discovery.enabled", false); -pref("browser.newtabpage.activity-stream.asrouter.userprefs.cfr.addons", false); -pref("browser.newtabpage.activity-stream.asrouter.userprefs.cfr.features", false); -pref("browser.preferences.moreFromMozilla", false, locked); -pref("browser.aboutwelcome.enabled", false); -pref("browser.contentblocking.report.show_mobile_app", false, locked); diff --git a/src/browser/app/profile/features.inc b/src/browser/app/profile/features.inc deleted file mode 100644 index fc05c55cc..000000000 --- a/src/browser/app/profile/features.inc +++ /dev/null @@ -1,41 +0,0 @@ -# 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/. - -#ifdef MOZILLA_OFFICIAL - pref('zen.welcome-screen.seen', false, sticky); -#else - pref('zen.welcome-screen.seen', true, sticky); -#endif - -pref('zen.tabs.vertical', true); -pref('zen.tabs.vertical.right-side', false); -pref('zen.tabs.rename-tabs', true); -pref('zen.tabs.show-newtab-vertical', true); - -pref('zen.ctrlTab.show-pending-tabs', false); - -pref('zen.mediacontrols.enabled', true); - -pref('zen.haptic-feedback.enabled', true); - -#include features/mods.inc -#include features/theme.inc -#include features/compact-mode.inc -#include features/urlbar.inc -#include features/glance.inc -#include features/view.inc -#include features/downloads.inc -#include features/workspaces.inc -#include features/split-view.inc -#include features/kbs.inc - -// Section: Watermark -#ifdef MOZILLA_OFFICIAL - pref('zen.watermark.enabled', true, sticky); -#else - pref('zen.watermark.enabled', false, sticky); -#endif - -// Startup flags -pref('zen.startup.smooth-scroll-in-tabs', true); diff --git a/src/browser/app/profile/features/compact-mode.inc b/src/browser/app/profile/features/compact-mode.inc deleted file mode 100644 index 38f0ee2ad..000000000 --- a/src/browser/app/profile/features/compact-mode.inc +++ /dev/null @@ -1,17 +0,0 @@ -# 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/. - -pref('zen.view.compact.hide-tabbar', true); -pref('zen.view.compact.hide-toolbar', false); -pref('zen.view.compact.toolbar-flash-popup', false); -pref('zen.view.compact.toolbar-flash-popup.duration', 800); -pref('zen.view.compact.toolbar-hide-after-hover.duration', 1000); -pref('zen.view.compact.color-toolbar', true); -pref('zen.view.compact.color-sidebar', true); -pref('zen.view.compact.animate-sidebar', true); -pref('zen.view.compact.show-sidebar-and-toolbar-on-hover', true); -pref('zen.view.compact.show-background-tab-toast', true); - -# Do not edit manually -pref('zen.view.compact.should-enable-at-startup', false); diff --git a/src/browser/app/profile/features/glance.inc b/src/browser/app/profile/features/glance.inc deleted file mode 100644 index 23143547a..000000000 --- a/src/browser/app/profile/features/glance.inc +++ /dev/null @@ -1,9 +0,0 @@ -# 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/. - -pref('zen.glance.enabled', true); -pref('zen.glance.enable-contextmenu-search', true); -pref('zen.glance.hold-duration', 300); // in ms -pref('zen.glance.open-essential-external-links', true); -pref('zen.glance.activation-method', 'alt'); // ctrl, alt, shift, none, hold diff --git a/src/browser/app/profile/features/kbs.inc b/src/browser/app/profile/features/kbs.inc deleted file mode 100644 index 10efb5b7c..000000000 --- a/src/browser/app/profile/features/kbs.inc +++ /dev/null @@ -1,7 +0,0 @@ -# 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/. - -pref('zen.keyboard.shortcuts.enabled', true); -pref('zen.keyboard.shortcuts.version', 0); // Empty string means default shortcuts -pref('zen.keyboard.shortcuts.disable-mainkeyset-clear', false); // for debugging diff --git a/src/browser/app/profile/features/mods.inc b/src/browser/app/profile/features/mods.inc deleted file mode 100644 index cf31b5bbd..000000000 --- a/src/browser/app/profile/features/mods.inc +++ /dev/null @@ -1,17 +0,0 @@ -# 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/. - -pref('zen.mods.updated-value-observer', false); - -pref('zen.mods.auto-update-days', 20); // In days - -#ifdef MOZILLA_OFFICIAL - pref('zen.mods.auto-update', true); - pref('zen.injections.match-urls', 'https://zen-browser.app/*', locked); -#else - pref('zen.mods.auto-update', false); - pref('zen.injections.match-urls', 'http://localhost/*', locked); -#endif - -pref('zen.rice.share.notice.accepted', false); diff --git a/src/browser/app/profile/features/theme.inc b/src/browser/app/profile/features/theme.inc deleted file mode 100644 index e8eeafb2a..000000000 --- a/src/browser/app/profile/features/theme.inc +++ /dev/null @@ -1,25 +0,0 @@ -# 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/. - -pref('zen.theme.accent-color', "#ffb787"); -pref('zen.theme.content-element-separation', 8); // In pixels -pref('zen.theme.gradient', true); -pref('zen.theme.gradient.show-custom-colors', false); -pref('zen.theme.essentials-favicon-bg', true); - -#ifdef XP_MACOSX - pref('zen.theme.border-radius', 10); // In pixels -#else - pref('zen.theme.border-radius', 8); // In pixels -#endif - -#ifdef XP_MACOSX - pref('zen.theme.acrylic-elements', false); -#else - pref('zen.theme.acrylic-elements', false); -#endif - -# Light weight themes -pref('zen.theme.disable-lightweight', true); -pref('zen.theme.use-sysyem-colors', false); diff --git a/src/browser/app/profile/features/urlbar.inc b/src/browser/app/profile/features/urlbar.inc deleted file mode 100644 index 9dca3cfae..000000000 --- a/src/browser/app/profile/features/urlbar.inc +++ /dev/null @@ -1,11 +0,0 @@ -# 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/. - -pref('zen.urlbar.replace-newtab', true); -pref('zen.urlbar.show-protections-icon', false); -pref('zen.urlbar.behavior', 'floating-on-type'); // default, floating-on-type, float -pref('zen.urlbar.wait-to-clear', 45000); // in ms (default 45s) -pref('zen.urlbar.show-domain-only-in-sidebar', true); -pref('zen.urlbar.hide-one-offs', true); -pref('zen.urlbar.enable-overrides', false); diff --git a/src/browser/app/profile/features/view.inc b/src/browser/app/profile/features/view.inc deleted file mode 100644 index 82b403c6a..000000000 --- a/src/browser/app/profile/features/view.inc +++ /dev/null @@ -1,29 +0,0 @@ -# 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/. - -pref('zen.view.sidebar-height-throttle', 0); // in ms -pref('zen.view.sidebar-expanded.max-width', 500); - -#ifdef XP_MACOSX - pref('zen.view.mac.show-three-dot-menu', false); - pref('zen.widget.mac.mono-window-controls', true); -#endif - -pref('zen.view.use-single-toolbar', true); -pref('zen.view.sidebar-expanded', true); -pref('zen.view.sidebar-collapsed.hide-mute-button', true); -pref('zen.view.experimental-force-window-controls-left', false); - -pref('zen.view.hide-window-controls', true); -pref('zen.view.experimental-no-window-controls', false); - -pref('zen.view.grey-out-inactive-windows', true); - -pref('zen.view.show-newtab-button-border-top', false); -pref('zen.view.show-newtab-button-top', true); - -# 0: Dark -# 1: Light -# 2: Auto (system color scheme unless overridden by browser theme) -pref('zen.view.window.scheme', 2); // auto, light, dark diff --git a/src/browser/app/profile/features/workspaces.inc b/src/browser/app/profile/features/workspaces.inc deleted file mode 100644 index b517c738e..000000000 --- a/src/browser/app/profile/features/workspaces.inc +++ /dev/null @@ -1,25 +0,0 @@ -# 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/. - -pref('zen.workspaces.continue-where-left-off', false); -pref('zen.workspaces.hide-default-container-indicator', true); -pref('zen.workspaces.force-container-workspace', false); -pref('zen.workspaces.open-new-tab-if-last-unpinned-tab-is-closed', false); -pref('zen.workspaces.swipe-actions', true); -pref('zen.workspaces.wrap-around-navigation', true); -pref('zen.workspaces.natural-scroll', false); -pref('zen.workspaces.scroll-modifier-key','ctrl'); // can be ctrl, alt, shift, or a meta key -pref('services.sync.engine.workspaces', false); -pref('zen.workspaces.separate-essentials', true); - -#ifdef MOZILLA_OFFICIAL - pref('zen.workspaces.debug', false); -#else - pref('zen.workspaces.debug', true); -#endif - -# Section: Pinned tabs management -pref('zen.pinned-tab-manager.debug', false); -pref('zen.pinned-tab-manager.restore-pinned-tabs-to-pinned-url', false); -pref('zen.pinned-tab-manager.close-shortcut-behavior', 'reset-unload-switch'); diff --git a/src/browser/app/profile/firefox-js.patch b/src/browser/app/profile/firefox-js.patch deleted file mode 100644 index e6def0b70..000000000 --- a/src/browser/app/profile/firefox-js.patch +++ /dev/null @@ -1,10 +0,0 @@ -diff --git a/browser/app/profile/firefox.js b/browser/app/profile/firefox.js -index 4050c0090e7fa9e0b3121194f47c7d29d4c394ab..138a17f5907540edbf39867a2ef9e63148e3ffa6 100644 ---- a/browser/app/profile/firefox.js -+++ b/browser/app/profile/firefox.js -@@ -3397,3 +3397,5 @@ pref("browser.contextual-services.contextId.rust-component.enabled", true); - - // Pref to enable the IP protection feature - pref("browser.ipProtection.enabled", false); -+ -+#include zen-browser.js diff --git a/src/browser/app/profile/fullscreen.inc b/src/browser/app/profile/fullscreen.inc deleted file mode 100644 index 9ce4aeeb9..000000000 --- a/src/browser/app/profile/fullscreen.inc +++ /dev/null @@ -1,8 +0,0 @@ -# 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/. - -pref("full-screen-api.transition-duration.enter", "0 0"); -pref("full-screen-api.transition-duration.leave", "0 0"); -pref("full-screen-api.warning.delay", -1); -pref("full-screen-api.warning.timeout", 0); diff --git a/src/browser/app/profile/linux.inc b/src/browser/app/profile/linux.inc deleted file mode 100644 index 6b65d85da..000000000 --- a/src/browser/app/profile/linux.inc +++ /dev/null @@ -1,14 +0,0 @@ -# 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/. - -pref("widget.gtk.rounded-bottom-corners.enabled", true); - -// Enable transparent background for linux -#ifdef MOZ_WIDGET_GTK -pref('zen.widget.linux.transparency', false); - -// VAAPI/FFMPEG is Linux only -pref('media.ffmpeg.vaapi.enabled', true); -pref('media.ffmpeg.encoder.enabled', true); -#endif diff --git a/src/browser/app/profile/media.inc b/src/browser/app/profile/media.inc deleted file mode 100644 index 8eac516b3..000000000 --- a/src/browser/app/profile/media.inc +++ /dev/null @@ -1,9 +0,0 @@ -# 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/. - -pref('image.jxl.enabled', true, locked); -pref("svg.context-properties.content.enabled", true); -pref("image.avif.enabled", true, locked); - -pref("media.eme.enabled", true); diff --git a/src/browser/app/profile/newtab.inc b/src/browser/app/profile/newtab.inc deleted file mode 100644 index 6447ad3b7..000000000 --- a/src/browser/app/profile/newtab.inc +++ /dev/null @@ -1,12 +0,0 @@ -# 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/. - -pref('browser.newtabpage.activity-stream.feeds.topsites', false); -pref('browser.newtabpage.activity-stream.feeds.section.topstories', false); -pref("browser.topsites.contile.enabled", false); -pref('browser.newtabpage.activity-stream.system.showWeather', false); - -pref('browser.newtabpage.activity-stream.newtabWallpapers.enabled', true); -pref('browser.newtabpage.activity-stream.newtabWallpapers.v2.enabled', true); -pref('browser.translations.newSettingsUI.enable', true); diff --git a/src/browser/app/profile/performance.inc b/src/browser/app/profile/performance.inc deleted file mode 100644 index 67ebaf8ac..000000000 --- a/src/browser/app/profile/performance.inc +++ /dev/null @@ -1,18 +0,0 @@ -# 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/. - -#ifdef XP_MACOSX -# Pref to control the reponse taken on macOS when the OS is under memory -# pressure. Changes to the pref take effect immediately. Browser restart not -# required. The pref value is a bitmask: -# 0x0: No response (other than recording for telemetry, crash reporting) -# 0x1: Use the tab unloading feature to reduce memory use. Requires that -# the above "browser.tabs.unloadOnLowMemory" pref be set to true for tab -# unloading to occur. -# 0x2: Issue the internal "memory-pressure" notification to reduce memory use -# 0x3: Both 0x1 and 0x2. - pref("browser.lowMemoryResponseMask", 3); -#endif - -pref("network.predictor.enable-hover-on-ssl", true); diff --git a/src/browser/app/profile/privacy.inc b/src/browser/app/profile/privacy.inc deleted file mode 100644 index 1b9f47e36..000000000 --- a/src/browser/app/profile/privacy.inc +++ /dev/null @@ -1,47 +0,0 @@ -# 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/. - -pref("datareporting.policy.dataSubmissionEnabled", false, locked); -pref("datareporting.healthreport.uploadEnabled", false, locked); -pref("toolkit.telemetry.unified", false, locked); -pref("toolkit.telemetry.enabled", false, locked); -pref("toolkit.telemetry.server", "data:,", locked); -pref("toolkit.telemetry.archive.enabled", false, locked); -pref("toolkit.telemetry.newProfilePing.enabled", false, locked); -pref("toolkit.telemetry.shutdownPingSender.enabled", false, locked); -pref("toolkit.telemetry.updatePing.enabled", false, locked); -pref("toolkit.telemetry.bhrPing.enabled", false, locked); -pref("toolkit.telemetry.firstShutdownPing.enabled", false, locked); -pref("toolkit.telemetry.coverage.opt-out", true, locked); -pref("toolkit.coverage.opt-out", true, locked); -pref("toolkit.coverage.endpoint.base", "", locked); -pref("browser.newtabpage.activity-stream.feeds.telemetry", false, locked); -pref("browser.newtabpage.activity-stream.telemetry", false, locked); -pref("browser.ping-centre.telemetry", false); -pref("browser.attribution.enabled", false); -pref("toolkit.telemetry.pioneer-new-studies-available", false); -pref("app.shield.optoutstudies.enabled", false, locked); -pref("app.normandy.enabled", false); -pref("app.normandy.api_url", "", locked); - -# Crash reports -pref("breakpad.reportURL", ""); -pref("browser.tabs.crashReporting.sendReport", false); -pref("browser.crashReports.unsubmittedCheck.autoSubmit2", false); - -# Other privacy -pref("extensions.getAddons.cache.enabled", false); - -# Disable cache for private browsing -pref("browser.privatebrowsing.forceMediaMemoryCache", true); - -# Tracking protection -pref("browser.helperApps.deleteTempFileOnExit", true); -pref("browser.uitour.enabled", false); - -pref("privacy.globalprivacycontrol.enabled", true); - -# Contextual identity -pref('privacy.userContext.enabled', true); -pref('privacy.userContext.ui.enabled', true); diff --git a/src/browser/app/profile/smoothscroll.inc b/src/browser/app/profile/smoothscroll.inc deleted file mode 100644 index 85faa575c..000000000 --- a/src/browser/app/profile/smoothscroll.inc +++ /dev/null @@ -1,15 +0,0 @@ -# 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/. - -pref("general.smoothScroll.msdPhysics.enabled", true); -pref("general.smoothScroll.currentVelocityWeighting", "0.15"); -pref("general.smoothScroll.stopDecelerationWeighting", "0.6"); -pref("mousewheel.min_line_scroll_amount", 10); -pref("general.smoothScroll.mouseWheel.durationMinMS", 80); -pref("general.smoothScroll.msdPhysics.continuousMotionMaxDeltaMS", 12); -pref("general.smoothScroll.msdPhysics.motionBeginSpringConstant", 600); -pref("general.smoothScroll.msdPhysics.regularSpringConstant", 650); -pref("general.smoothScroll.msdPhysics.slowdownMinDeltaMS", 25); -pref("general.smoothScroll.msdPhysics.slowdownSpringConstant", 250); -pref("mousewheel.default.delta_multiplier_y", 200); diff --git a/src/browser/app/profile/urlbar.inc b/src/browser/app/profile/urlbar.inc deleted file mode 100644 index 78e5fec70..000000000 --- a/src/browser/app/profile/urlbar.inc +++ /dev/null @@ -1,35 +0,0 @@ -# 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/. - -pref('browser.urlbar.unitConversion.enabled', true); -pref('browser.urlbar.trending.featureGate', false); -pref('browser.urlbar.weather.featureGate', false); -pref('browser.urlbar.quickactions.enabled', true); -pref('browser.urlbar.clipboard.featureGate', true); -pref('browser.urlbar.suggest.calculator', true); - -pref("browser.urlbar.trimHttps", true); -pref("browser.urlbar.untrimOnUserInteraction.featureGate", true); - -# Keep in sync with browser/components/topsites/constants.mjs -pref("browser.urlbar.maxRichResults", 7); - -# Enable private suggestions -pref('browser.search.suggest.enabled', false); -pref('browser.search.suggest.enabled.private', false); - -pref("browser.urlbar.trimHttps", true); -pref("browser.search.separatePrivateDefault.ui.enabled", true); -pref("browser.urlbar.update2.engineAliasRefresh", true); -pref("browser.urlbar.quicksuggest.enabled", false, locked); -pref("browser.urlbar.suggest.quicksuggest.sponsored", false, locked); -pref("browser.urlbar.suggest.quicksuggest.nonsponsored", false, locked); -pref("browser.urlbar.groupLabels.enabled", false); -pref("browser.urlbar.keepPanelOpenDuringImeComposition", true); // IMPORTANT: Fixes closing the urlbar when on some languages -pref("browser.formfill.enable", false); -pref("security.insecure_connection_text.enabled", true); -pref("security.insecure_connection_text.pbmode.enabled", true); -pref("network.IDN_show_punycode", true); - -pref("browser.urlbar.suggest.topsites", true, locked); diff --git a/src/browser/app/profile/windows.inc b/src/browser/app/profile/windows.inc deleted file mode 100644 index be9a83d3b..000000000 --- a/src/browser/app/profile/windows.inc +++ /dev/null @@ -1,12 +0,0 @@ -# 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/. - -# Mica -pref("widget.windows.mica", true); -pref("widget.windows.mica.popups", true); - -# 1. DWMSBT_MAINWINDOW -# 2. DWMSBT_TRANSIENTWINDOW (default, also used for popups) -# 3(default). DWMSBT_TABBEDWINDOW -pref("widget.windows.mica.toplevel-backdrop", 2); diff --git a/src/browser/app/profile/zen-browser.js b/src/browser/app/profile/zen-browser.js deleted file mode 100644 index 4458ea5ae..000000000 --- a/src/browser/app/profile/zen-browser.js +++ /dev/null @@ -1,41 +0,0 @@ -# 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/. - -#ifdef XP_UNIX - #ifndef XP_MACOSX - #define UNIX_BUT_NOT_MAC - #endif -#endif - -# Dont download the multilingual dictionary -pref("intl.multilingual.downloadEnabled", false); - -#ifdef XP_WIN - #include windows.inc -#endif - -#ifdef UNIX_BUT_NOT_MAC - #include linux.inc -#endif - -#ifdef XP_MACOSX - #include macos.inc -#endif - -#include urlbar.inc -#include newtab.inc -#include pdf.inc -#include extensions.inc -#include privacy.inc -#include media.inc -#include browser.inc - -#include features.inc - -#ifndef XP_MACOSX - #include smoothscroll.inc -#endif - -#include performance.inc -#include pip.inc diff --git a/src/modules/libpref/init/zen-static-prefs.inc b/src/modules/libpref/init/zen-static-prefs.inc index dae704346..1e9f5b9e7 100644 --- a/src/modules/libpref/init/zen-static-prefs.inc +++ b/src/modules/libpref/init/zen-static-prefs.inc @@ -1,23 +1,20 @@ -# Dummy pref to always generate StaticPrefs_zen.h in every OS -- name: zen.browser.is-cool - type: bool - value: true - mirror: never - -#ifdef XP_MACOSX -- name: zen.widget.macos.window-material - type: uint32_t - value: 1 - mirror: always -#endif - - name: zen.haptic-feedback.enabled type: bool value: true mirror: always + rust: false - name: zen.swipe.is-fast-swipe type: bool value: true mirror: always + rust: false + +#if defined(XP_MACOSX) +- name: zen.widget.macos.window-material + type: uint32_t + value: 1 + mirror: always + rust: false +#endif \ No newline at end of file diff --git a/tools/ffprefs/Cargo.lock b/tools/ffprefs/Cargo.lock new file mode 100644 index 000000000..e787e043c --- /dev/null +++ b/tools/ffprefs/Cargo.lock @@ -0,0 +1,119 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "equivalent" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" + +[[package]] +name = "ffprefs" +version = "0.1.0" +dependencies = [ + "serde", + "serde_yaml", +] + +[[package]] +name = "hashbrown" +version = "0.15.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5971ac85611da7067dbfcabef3c70ebb5606018acd9e2a3903a0da507521e0d5" + +[[package]] +name = "indexmap" +version = "2.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe4cd85333e22411419a0bcae1297d25e58c9443848b11dc6a86fefe8c78a661" +dependencies = [ + "equivalent", + "hashbrown", +] + +[[package]] +name = "itoa" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c" + +[[package]] +name = "proc-macro2" +version = "1.0.95" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02b3e5e68a3a1a02aad3ec490a98007cbc13c37cbe84a3cd7b8e406d76e7f778" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "ryu" +version = "1.0.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f" + +[[package]] +name = "serde" +version = "1.0.219" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.219" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_yaml" +version = "0.9.34+deprecated" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a8b1a1a2ebf674015cc02edccce75287f1a0130d394307b36743c2f5d504b47" +dependencies = [ + "indexmap", + "itoa", + "ryu", + "serde", + "unsafe-libyaml", +] + +[[package]] +name = "syn" +version = "2.0.104" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17b6f705963418cdb9927482fa304bc562ece2fdd4f616084c50b7023b435a40" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "unicode-ident" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512" + +[[package]] +name = "unsafe-libyaml" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "673aac59facbab8a9007c7f6108d11f63b603f7cabff99fabf650fea5c32b861" diff --git a/tools/ffprefs/Cargo.toml b/tools/ffprefs/Cargo.toml new file mode 100644 index 000000000..2ff5da12e --- /dev/null +++ b/tools/ffprefs/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "ffprefs" +version = "0.1.0" +edition = "2021" + +[dependencies] +serde = { version = "1.0.104", features = ["derive"] } +serde_yaml = "0.9.34" diff --git a/tools/ffprefs/src/main.rs b/tools/ffprefs/src/main.rs new file mode 100644 index 000000000..aa9312239 --- /dev/null +++ b/tools/ffprefs/src/main.rs @@ -0,0 +1,315 @@ +// 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/. + +// Basics +// ------ +// Any pref defined in one of the files included here should *not* be defined +// in a data file such as all.js; that would just be useless duplication. +// +// (Except under unusual circumstances where the value defined here must be +// overridden, e.g. for some Thunderbird prefs. In those cases the default +// value from the data file will override the static default value defined +// here.) +// +// Please follow the existing prefs naming convention when considering adding a +// new pref, and don't create a new pref group unless it's appropriate and there +// are likely to be multiple prefs within that group. (If you do, you'll need to +// update the `pref_groups` variable in modules/libpref/moz.build.) +// +// Definitions +// ----------- +// A pref definition looks like this: +// +// - name: // mandatory +// cpptype: // mandatory if static +// value: // mandatory +// mirror: // mandatory if static +// lang: // optional +// condition: // optional +// locked: . // optional only on dynamic prefs +// sticky: // optional only on dynamic prefs +// +// - `name` is the name of the pref, without double-quotes, as it appears +// in about:config. It is used in most libpref API functions (from both C++ +// and JS code). +// +// - `cpptype` is one of `bool`, `int32_t`, `uint32_t`, `float`, an atomic version +// of one of those, `String` or `DataMutexString`. Note that float prefs are +// stored internally as strings. The C++ preprocessor doesn't like template +// syntax in a macro argument, so use the typedefs defined in +// StaticPrefsBase.h; for example, use `RelaxedAtomicBool` instead of +// `Atomic`. +// +// - `value` is the default value. Its type should be appropriate for +// , otherwise the generated code will fail to compile. A complex +// C++ numeric expressions like `60 * 60` (which the YAML parser cannot treat +// as an integer or float) is treated as a string and passed through without +// change, which is useful. +// +// - `mirror` indicates how the pref value is mirrored into a C++ variable. +// +// * `never`: There is no C++ mirror variable. The pref value can only be +// accessed via the standard libpref API functions. +// +// * `once`: The pref value is mirrored into a variable at startup; the +// mirror variable is left unchanged after that. (The exact point at which +// all `once` mirror variables are set is when the first `once` mirror +// variable is accessed, via its getter function.) This is mostly useful for +// graphics prefs where we often don't want a new pref value to apply until +// restart. Otherwise, this update policy is best avoided because its +// behaviour can cause confusion and bugs. +// +// * `always`: The mirror variable is always kept in sync with the pref value. +// This is the most common choice. +// +// When a mirror variable is present, a getter will be created that can access +// it. Using the getter function to read the pref's value has the two +// following advantages over the normal API functions. +// +// * A direct variable access is faster than a hash table lookup. +// +// * A mirror variable can be accessed off the main thread. If a pref *is* +// accessed off the main thread, it should have an atomic type. Assertions +// enforce this. +// +// Note that Rust code must access the mirror variable directly, rather than +// via the getter function. +// +// - `lang=rust` indicates if the mirror variable is used by Rust code. If so, it +// will be usable via the `static_prefs::pref!` macro, e.g. +// `static_prefs::pref!("layout.css.cross-fade.enabled")`. +// +// - `condition` is an optional condition that must be true for the pref to be +// defined. It is a C++ expression that can use any global variable or macro +// defined in the C++ code, such as `MOZ_WIDGET_GTK` or `XP_MACOS`. +// +// example: condition: "defined(XP_MACOS) || defined(MOZ_WIDGET_GTK)" +// +// - `locked` is an optional boolean that indicates whether the pref is locked +// (i.e., cannot be changed by the user). If set to `true`, the pref will +// be locked in the generated code, and the user will not be able +// to change it in about:config. +// +// The getter function's base name is the same as the pref's name, but with +// '.' or '-' chars converted to '_', to make a valid identifier. For example, +// the getter for `foo.bar_baz` is `foo_bar_baz()`. This is ugly but clear, +// and you can search for both the pref name and the getter using the regexp +// /foo.bar.baz/. Suffixes are added as follows: +// +// - If the `mirror` value is `once`, `_AtStartup` is appended, to indicate the +// value was obtained at startup. +// + +use serde::{Deserialize, Serialize}; +use std::env; +use std::fs; +use std::path::PathBuf; + +const STATIC_PREFS: &str = "../engine/modules/libpref/init/zen-static-prefs.inc"; +const FIREFOX_PREFS: &str = "../engine/browser/app/profile/firefox.js"; +const DYNAMIC_PREFS: &str = "../engine/browser/app/profile/zen-browser.js"; + +#[derive(Serialize, Deserialize, PartialEq, Debug)] +struct Preference { + name: String, + value: String, + r#type: Option, + condition: Option, + hidden: Option, + cpptype: Option, + mirror: Option, + locked: Option, + sticky: Option, +} + +fn get_config_path() -> PathBuf { + let mut path = env::current_dir().expect("Failed to get current directory"); + path.push("prefs"); + path +} + +fn ordered_prefs(mut prefs: Vec) -> Vec { + // Sort preferences by name + prefs.sort_by(|a, b| a.name.cmp(&b.name)); + prefs +} + +fn load_preferences() -> Vec { + let mut prefs = Vec::new(); + let config_path = get_config_path(); + // Iterate each file in the prefs directory + if let Ok(entries) = fs::read_dir(&config_path) { + for entry in entries { + if let Ok(entry) = entry { + if let Some(ext) = entry.path().extension() { + if ext == "yaml" || ext == "yml" { + let file_path = entry.path(); + let content = fs::read_to_string(&file_path).expect("Failed to read file"); + let mut parsed_prefs: Vec = + serde_yaml::from_str(&content).expect("Failed to parse YAML"); + prefs.append(&mut parsed_prefs); + } + } + } + } + } + ordered_prefs(prefs) +} + +fn get_condition_string(condition: &Option) -> String { + condition + .as_deref() + .map_or_else(String::new, |cond| cond.trim().to_string()) +} + +fn get_pref_with_condition(content: &str, condition: &str) -> String { + if condition.is_empty() { + return format!("\n{}", content); + } + format!("\n#if {}\n{}#endif", condition, content) +} + +fn get_static_pref(pref: &Preference) -> String { + // - name: # mandatory + // type: # mandatory + // value: # mandatory + // mirror: # mandatory + // do_not_use_directly: # optional + // include: # optional + // rust: # optional + // set_spidermonkey_pref: # optional + // We do not hide preferences in static prefs, so we ignore the `hidden` field. + let name = format!("- name: {}\n", pref.name); + let cpp_type = format!( + " type: {}\n", + pref.cpptype + .as_deref() + .expect("cpp type is mandatory on static prefs") + ); + let value = format!(" value: {}\n", pref.value); + let rust = if pref.r#type.as_deref() == Some("rust") { + " rust: true\n".to_string() + } else { + " rust: false\n".to_string() + }; + let mirror = format!( + " mirror: {}\n", + pref.mirror + .as_deref() + .expect("mirror is mandatory on static prefs") + ); + let content = format!("{}{}{}{}{}", name, cpp_type, value, mirror, rust); + get_pref_with_condition(&content, &get_condition_string(&pref.condition)) +} + +fn get_dynamic_pref(pref: &Preference) -> String { + let value = get_value(pref); + if pref.hidden.unwrap_or(false) { + return format!("# Hidden preference: {} = {}", pref.name, value); + } + let third_arg; + let is_locked = pref.locked.unwrap_or(false); + let is_sticky = pref.sticky.unwrap_or(false); + if is_locked && is_sticky { + panic!("A dynamic pref cannot be both locked and sticky"); + } else if is_locked { + third_arg = ", locked".to_string(); + } else if is_sticky { + third_arg = ", sticky".to_string(); + } else { + third_arg = String::new(); + } + // note: Dont use "value" here, as it adds quotes around the value + if pref.value == "@cond" { + // If the value is "@cond", we assume it is a placeholder for a condition + // that will be replaced later, so we do not include it in the pref definition. + return get_pref_with_condition( + &format!( + "pref(\"{}\", true);\n#else\npref(\"{}\", false);\n", + pref.name, pref.name + ), + &get_condition_string(&pref.condition), + ); + } + get_pref_with_condition( + &format!("pref(\"{}\", {}{});\n", pref.name, value, third_arg), + &get_condition_string(&pref.condition), + ) +} + +fn get_value(pref: &Preference) -> String { + // Strings must be wrapped inside double quotes + let value = &pref.value; + // Other values such as numbers or booleans can be used directly + // If the value is empty or there are any characters that could be misinterpreted, + // we should wrap it in double quotes. + let letters_inside_value = + value.chars().any(|c| c.is_alphabetic()) && value != "true" && value != "false"; + if value.is_empty() || value.contains([' ', '\n', '\t', '"']) || letters_inside_value { + format!("\"{}\"", value.replace('"', "\\\"")) + } else { + value.to_string() + } +} + +fn write_preferences(prefs: &[Preference]) { + let config_path = get_config_path(); + if !config_path.exists() { + fs::create_dir_all(&config_path).expect("Failed to create prefs directory"); + } + + let static_prefs_path = config_path.join(STATIC_PREFS); + let dynamic_prefs_path = config_path.join(DYNAMIC_PREFS); + println!( + "Writing preferences to:\n Static: {}\n Dynamic: {}", + static_prefs_path.display(), + dynamic_prefs_path.display() + ); + let mut static_content = String::new(); + let mut dynamic_content = String::new(); + for pref in prefs { + let ty = pref.r#type.as_deref().unwrap_or(""); + if ty == "static" || ty == "rust" { + let content = get_static_pref(pref); + static_content.push_str(&content); + } + let content = get_dynamic_pref(pref); + dynamic_content.push_str(&content); + } + + fs::write(&static_prefs_path, static_content).expect("Failed to write static prefs"); + fs::write(&dynamic_prefs_path, dynamic_content).expect("Failed to write dynamic prefs"); +} + +fn prepare_zen_prefs() { + // Add `#include zen-browser.js` to the bottom of the firefox.js file if it doesn't exist + let line = "#include zen-browser.js"; + let firefox_prefs_path = get_config_path().join(FIREFOX_PREFS); + if let Ok(mut content) = fs::read_to_string(&firefox_prefs_path) { + if !content.contains(line) { + content.push_str(format!("\n{}\n", line).as_str()); + // Ensure the file ends with a newline + fs::write(&firefox_prefs_path, content).expect("Failed to write firefox prefs"); + } + } else { + eprintln!( + "Warning: {} does not exist or cannot be read.", + firefox_prefs_path.display() + ); + } +} + +fn main() { + let args: Vec = env::args().collect(); + let root_path = if args.len() > 1 { + PathBuf::from(&args[1]) + } else { + env::current_dir().expect("Failed to get current directory") + }; + env::set_current_dir(&root_path).expect("Failed to change directory"); + + prepare_zen_prefs(); + let preferences = load_preferences(); + write_preferences(&preferences); +}