summaryrefslogtreecommitdiffstats
path: root/browser/components/urlbar/UrlbarProvidersManager.sys.mjs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--browser/components/urlbar/UrlbarProvidersManager.sys.mjs48
1 files changed, 44 insertions, 4 deletions
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";
/**
@@ -179,6 +183,17 @@ class ProvidersManager {
}
/**
+ * 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.
*
* @param {object} muxer
@@ -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();