diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 05:35:29 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 05:35:29 +0000 |
commit | 59203c63bb777a3bacec32fb8830fba33540e809 (patch) | |
tree | 58298e711c0ff0575818c30485b44a2f21bf28a0 /browser/components/urlbar/QuickActionsLoaderDefault.sys.mjs | |
parent | Adding upstream version 126.0.1. (diff) | |
download | firefox-59203c63bb777a3bacec32fb8830fba33540e809.tar.xz firefox-59203c63bb777a3bacec32fb8830fba33540e809.zip |
Adding upstream version 127.0.upstream/127.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'browser/components/urlbar/QuickActionsLoaderDefault.sys.mjs')
-rw-r--r-- | browser/components/urlbar/QuickActionsLoaderDefault.sys.mjs | 73 |
1 files changed, 22 insertions, 51 deletions
diff --git a/browser/components/urlbar/QuickActionsLoaderDefault.sys.mjs b/browser/components/urlbar/QuickActionsLoaderDefault.sys.mjs index 0ab9c4c83e..9a7b7a6a34 100644 --- a/browser/components/urlbar/QuickActionsLoaderDefault.sys.mjs +++ b/browser/components/urlbar/QuickActionsLoaderDefault.sys.mjs @@ -8,12 +8,10 @@ const lazy = {}; ChromeUtils.defineESModuleGetters(lazy, { BrowserWindowTracker: "resource:///modules/BrowserWindowTracker.sys.mjs", - ClientEnvironment: "resource://normandy/lib/ClientEnvironment.sys.mjs", DevToolsShim: "chrome://devtools-startup/content/DevToolsShim.sys.mjs", ResetProfile: "resource://gre/modules/ResetProfile.sys.mjs", - UrlbarPrefs: "resource:///modules/UrlbarPrefs.sys.mjs", - UrlbarProviderQuickActions: - "resource:///modules/UrlbarProviderQuickActions.sys.mjs", + ActionsProviderQuickActions: + "resource:///modules/ActionsProviderQuickActions.sys.mjs", }); import { AppConstants } from "resource://gre/modules/AppConstants.sys.mjs"; @@ -26,7 +24,6 @@ if (AppConstants.MOZ_UPDATER) { "nsIApplicationUpdateService" ); } - XPCOMUtils.defineLazyPreferenceGetter( lazy, "SCREENSHOT_BROWSER_COMPONENT", @@ -54,7 +51,7 @@ let openUrl = url => { let openAddonsUrl = url => { return () => { let window = lazy.BrowserWindowTracker.getTopWindow(); - window.BrowserOpenAddonsMgr(url, { selectTabByViewId: true }); + window.BrowserAddonUI.openAddonsMgr(url, { selectTabByViewId: true }); }; }; @@ -97,24 +94,22 @@ const DEFAULT_ACTIONS = { }, }, downloads: { - l10nCommands: ["quickactions-cmd-downloads", "quickactions-downloads2"], + l10nCommands: ["quickactions-cmd-downloads"], icon: "chrome://browser/skin/downloads/downloads.svg", label: "quickactions-downloads2", onPick: openUrlFun("about:downloads"), }, extensions: { - l10nCommands: ["quickactions-cmd-extensions", "quickactions-extensions"], + l10nCommands: ["quickactions-cmd-extensions"], icon: "chrome://mozapps/skin/extensions/category-extensions.svg", label: "quickactions-extensions", onPick: openAddonsUrl("addons://list/extension"), }, inspect: { - l10nCommands: ["quickactions-cmd-inspector", "quickactions-inspector2"], + l10nCommands: ["quickactions-cmd-inspector"], icon: "chrome://devtools/skin/images/open-inspector.svg", label: "quickactions-inspector2", - isVisible: () => - lazy.DevToolsShim.isEnabled() || lazy.DevToolsShim.isDevToolsUser(), - isActive: () => { + isVisible: () => { // The inspect action is available if: // 1. DevTools is enabled. // 2. The user can be considered as a DevTools user. @@ -132,18 +127,18 @@ const DEFAULT_ACTIONS = { onPick: openInspector, }, logins: { - l10nCommands: ["quickactions-cmd-logins", "quickactions-logins2"], + l10nCommands: ["quickactions-cmd-logins"], label: "quickactions-logins2", onPick: openUrlFun("about:logins"), }, plugins: { - l10nCommands: ["quickactions-cmd-plugins", "quickactions-plugins"], + l10nCommands: ["quickactions-cmd-plugins"], icon: "chrome://mozapps/skin/extensions/category-extensions.svg", label: "quickactions-plugins", onPick: openAddonsUrl("addons://list/plugin"), }, print: { - l10nCommands: ["quickactions-cmd-print", "quickactions-print2"], + l10nCommands: ["quickactions-cmd-print"], label: "quickactions-print2", icon: "chrome://global/skin/icons/print.svg", onPick: () => { @@ -153,7 +148,7 @@ const DEFAULT_ACTIONS = { }, }, private: { - l10nCommands: ["quickactions-cmd-private", "quickactions-private2"], + l10nCommands: ["quickactions-cmd-private"], label: "quickactions-private2", icon: "chrome://global/skin/icons/indicator-private-browsing.svg", onPick: () => { @@ -163,7 +158,7 @@ const DEFAULT_ACTIONS = { }, }, refresh: { - l10nCommands: ["quickactions-cmd-refresh", "quickactions-refresh"], + l10nCommands: ["quickactions-cmd-refresh"], label: "quickactions-refresh", onPick: () => { lazy.ResetProfile.openConfirmationDialog( @@ -172,7 +167,7 @@ const DEFAULT_ACTIONS = { }, }, restart: { - l10nCommands: ["quickactions-cmd-restart", "quickactions-restart"], + l10nCommands: ["quickactions-cmd-restart"], label: "quickactions-restart", onPick: restartBrowser, }, @@ -197,10 +192,10 @@ const DEFAULT_ACTIONS = { }, }, screenshot: { - l10nCommands: ["quickactions-cmd-screenshot", "quickactions-screenshot3"], + l10nCommands: ["quickactions-cmd-screenshot"], label: "quickactions-screenshot3", icon: "chrome://browser/skin/screenshot.svg", - isActive: () => { + isVisible: () => { return !lazy.BrowserWindowTracker.getTopWindow().gScreenshots.shouldScreenshotsButtonBeDisabled(); }, onPick: () => { @@ -221,21 +216,21 @@ const DEFAULT_ACTIONS = { }, }, settings: { - l10nCommands: ["quickactions-cmd-settings", "quickactions-settings2"], + l10nCommands: ["quickactions-cmd-settings"], icon: "chrome://global/skin/icons/settings.svg", label: "quickactions-settings2", onPick: openUrlFun("about:preferences"), }, themes: { - l10nCommands: ["quickactions-cmd-themes", "quickactions-themes"], + l10nCommands: ["quickactions-cmd-themes"], icon: "chrome://mozapps/skin/extensions/category-extensions.svg", label: "quickactions-themes", onPick: openAddonsUrl("addons://list/theme"), }, update: { - l10nCommands: ["quickactions-cmd-update", "quickactions-update"], + l10nCommands: ["quickactions-cmd-update"], label: "quickactions-update", - isActive: () => { + isVisible: () => { if (!AppConstants.MOZ_UPDATER) { return false; } @@ -246,10 +241,10 @@ const DEFAULT_ACTIONS = { onPick: restartBrowser, }, viewsource: { - l10nCommands: ["quickactions-cmd-viewsource", "quickactions-viewsource2"], + l10nCommands: ["quickactions-cmd-viewsource"], icon: "chrome://global/skin/icons/settings.svg", label: "quickactions-viewsource2", - isActive: () => currentBrowser()?.currentURI.scheme !== "view-source", + isVisible: () => currentBrowser()?.currentURI.scheme !== "view-source", onPick: () => openUrl("view-source:" + currentBrowser().currentURI.spec), }, }; @@ -287,18 +282,6 @@ function restartBrowser() { } } -function random(seed) { - let x = Math.sin(seed) * 10000; - return x - Math.floor(x); -} - -function shuffle(array, seed) { - for (let i = array.length - 1; i > 0; i--) { - const j = Math.floor(random(seed) * (i + 1)); - [array[i], array[j]] = [array[j], array[i]]; - } -} - /** * Loads the default QuickActions. */ @@ -308,18 +291,6 @@ export class QuickActionsLoaderDefault { static async load() { let keys = Object.keys(DEFAULT_ACTIONS); - if (lazy.UrlbarPrefs.get("quickactions.randomOrderActions")) { - // We insert the actions in a random order which means they will be returned - // in a random but consistent order (the order of results for "view" and "views" - // should be the same). - // We use the Nimbus randomizationId as the seed as the order should not change - // for the user between restarts, it should be random between users but a user should - // see actions the same order. - let seed = [...lazy.ClientEnvironment.randomizationId] - .map(x => x.charCodeAt(0)) - .reduce((sum, a) => sum + a, 0); - shuffle(keys, seed); - } for (const key of keys) { let actionData = DEFAULT_ACTIONS[key]; let messages = await lazy.gFluentStrings.formatMessages( @@ -328,7 +299,7 @@ export class QuickActionsLoaderDefault { actionData.commands = messages .map(({ value }) => value.split(",").map(x => x.trim().toLowerCase())) .flat(); - lazy.UrlbarProviderQuickActions.addAction(key, actionData); + lazy.ActionsProviderQuickActions.addAction(key, actionData); } } static async ensureLoaded() { |