From a90a5cba08fdf6c0ceb95101c275108a152a3aed Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 12 Jun 2024 07:35:37 +0200 Subject: Merging upstream version 127.0. Signed-off-by: Daniel Baumann --- .../urlbar/UrlbarProvidersManager.sys.mjs | 48 ++++++++++++++++++++-- 1 file changed, 44 insertions(+), 4 deletions(-) (limited to 'browser/components/urlbar/UrlbarProvidersManager.sys.mjs') diff --git a/browser/components/urlbar/UrlbarProvidersManager.sys.mjs b/browser/components/urlbar/UrlbarProvidersManager.sys.mjs index ac70e03e1b..3fd9b0caf3 100644 --- a/browser/components/urlbar/UrlbarProvidersManager.sys.mjs +++ b/browser/components/urlbar/UrlbarProvidersManager.sys.mjs @@ -40,8 +40,6 @@ var localProviderModules = { "resource:///modules/UrlbarProviderCalculator.sys.mjs", UrlbarProviderClipboard: "resource:///modules/UrlbarProviderClipboard.sys.mjs", - UrlbarProviderContextualSearch: - "resource:///modules/UrlbarProviderContextualSearch.sys.mjs", UrlbarProviderHeuristicFallback: "resource:///modules/UrlbarProviderHeuristicFallback.sys.mjs", UrlbarProviderHistoryUrlHeuristic: @@ -54,8 +52,6 @@ var localProviderModules = { UrlbarProviderPlaces: "resource:///modules/UrlbarProviderPlaces.sys.mjs", UrlbarProviderPrivateSearch: "resource:///modules/UrlbarProviderPrivateSearch.sys.mjs", - UrlbarProviderQuickActions: - "resource:///modules/UrlbarProviderQuickActions.sys.mjs", UrlbarProviderQuickSuggest: "resource:///modules/UrlbarProviderQuickSuggest.sys.mjs", UrlbarProviderQuickSuggestContextualOptIn: @@ -84,6 +80,14 @@ var localMuxerModules = { "resource:///modules/UrlbarMuxerUnifiedComplete.sys.mjs", }; +import { ActionsProviderQuickActions } from "resource:///modules/ActionsProviderQuickActions.sys.mjs"; +import { ActionsProviderContextualSearch } from "resource:///modules/ActionsProviderContextualSearch.sys.mjs"; + +let globalActionsProviders = [ + ActionsProviderContextualSearch, + ActionsProviderQuickActions, +]; + const DEFAULT_MUXER = "UnifiedComplete"; /** @@ -178,6 +182,17 @@ class ProvidersManager { return this.providers.find(p => p.name == name); } + /** + * Returns the provider with the given name. + * + * @param {string} name + * The provider name. + * @returns {UrlbarProvider} The provider. + */ + getActionProvider(name) { + return globalActionsProviders.find(p => p.name == name); + } + /** * Registers a muxer object with the manager. * @@ -284,6 +299,12 @@ class ProvidersManager { // history and bookmarks even if search engines are not available. } + // All current global actions are currently memory lookups so it is safe to + // wait on them. + this.#globalAction = lazy.UrlbarPrefs.get("secondaryActions.featureGate") + ? await this.pickGlobalAction(queryContext, controller) + : null; + if (query.canceled) { return; } @@ -357,6 +378,25 @@ class ProvidersManager { ); } } + + #globalAction = null; + + async pickGlobalAction(queryContext, controller) { + for (let provider of globalActionsProviders) { + if (provider.isActive(queryContext)) { + let action = await provider.queryAction(queryContext, controller); + if (action) { + action.providerName = provider.name; + return action; + } + } + } + return null; + } + + getGlobalAction() { + return this.#globalAction; + } } export var UrlbarProvidersManager = new ProvidersManager(); -- cgit v1.2.3