tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit cc91e0bec3f57d837865893a05108403f67acae3
parent bd590d53278cae9df8ab3403cdae93689702075f
Author: Mark Banner <standard8@mozilla.com>
Date:   Fri, 12 Dec 2025 14:18:21 +0000

Bug 2005316 - Replace SearchUIUtils.loadSearchFromExtension with SearchUIUtils.loadSearch. r=search-reviewers,extension-reviewers,robwu,scunnane

Differential Revision: https://phabricator.services.mozilla.com/D276014

Diffstat:
Mbrowser/components/extensions/parent/ext-search.js | 10++++++----
Mbrowser/components/search/SearchUIUtils.sys.mjs | 66+++++++++++++-----------------------------------------------------
2 files changed, 19 insertions(+), 57 deletions(-)

diff --git a/browser/components/extensions/parent/ext-search.js b/browser/components/extensions/parent/ext-search.js @@ -90,13 +90,14 @@ this.search = class extends ExtensionAPI { defaultDisposition: "NEW_TAB", }); - await SearchUIUtils.loadSearchFromExtension({ + await SearchUIUtils.loadSearch({ window: windowTracker.topWindow, - query: searchProperties.query, + searchText: searchProperties.query, where, engine, tab, triggeringPrincipal: context.principal, + sapSource: "webextension", }); }, @@ -109,12 +110,13 @@ this.search = class extends ExtensionAPI { defaultDisposition: "CURRENT_TAB", }); - await SearchUIUtils.loadSearchFromExtension({ + await SearchUIUtils.loadSearch({ window: windowTracker.topWindow, - query: queryProperties.text, + searchText: queryProperties.text, where, tab, triggeringPrincipal: context.principal, + sapSource: "webextension", }); }, }, diff --git a/browser/components/search/SearchUIUtils.sys.mjs b/browser/components/search/SearchUIUtils.sys.mjs @@ -361,7 +361,7 @@ export var SearchUIUtils = { }, /** - * Loads a search results page, given a set of search terms. Uses the given + * Opens a search results page, given a set of search terms. Uses the given * engine if specified and the current default engine appropriate for * `usePrivate` otherwise. * @@ -374,20 +374,20 @@ export var SearchUIUtils = { * @param {?string} [options.where] * String indicating where the search should load. Most commonly used * are 'tab' or 'window', defaults to 'current'. - * @param {boolean} options.usePrivate + * @param {boolean} [options.usePrivate] * Whether to use the Private Browsing mode default search engine. * Defaults to `false`. * @param {nsIPrincipal} options.triggeringPrincipal * The principal to use for a new window or tab. - * @param {nsIPolicyContainer} options.policyContainer + * @param {nsIPolicyContainer} [options.policyContainer] * The policyContainer to use for a new window or tab. - * @param {boolean} [options.inBackground=false] + * @param {boolean} [options.inBackground] * Set to true for the tab to be loaded in the background. - * @param {?nsISearchEngine} [options.engine=null] + * @param {?nsISearchEngine} [options.engine] * The search engine to use for the search. - * @param {?MozTabbrowserTab} [options.tab=null] + * @param {?MozTabbrowserTab} [options.tab] * The tab to show the search result. - * @param {?Values<typeof SearchUtils.URL_TYPE>} [options.searchUrlType=null] + * @param {?Values<typeof SearchUtils.URL_TYPE>} [options.searchUrlType] * A `SearchUtils.URL_TYPE` value indicating the type of search that should * be performed. A falsey value is equivalent to * `SearchUtils.URL_TYPE.SEARCH`, which will perform a usual web search. @@ -395,11 +395,11 @@ export var SearchUIUtils = { * The search access point source, see * {@link lazy.BrowserSearchTelemetry.KNOWN_SEARCH_SOURCES} */ - async _loadSearch({ + async loadSearch({ window, searchText, where, - usePrivate, + usePrivate = lazy.PrivateBrowsingUtils.isWindowPrivate(window), triggeringPrincipal, policyContainer, inBackground = false, @@ -410,7 +410,7 @@ export var SearchUIUtils = { }) { if (!triggeringPrincipal) { throw new Error( - "Required argument triggeringPrincipal missing within _loadSearch" + "Required argument triggeringPrincipal missing within loadSearch" ); } @@ -431,7 +431,7 @@ export var SearchUIUtils = { } window.openLinkIn(submission.uri.spec, where || "current", { - private: usePrivate && !lazy.PrivateBrowsingUtils.isWindowPrivate(window), + private: usePrivate, postData: submission.postData, inBackground, relatedToCurrent: true, @@ -503,7 +503,7 @@ export var SearchUIUtils = { inBackground = !inBackground; } - return SearchUIUtils._loadSearch({ + return this.loadSearch({ window, engine, searchText, @@ -544,7 +544,7 @@ export var SearchUIUtils = { triggeringPrincipal, policyContainer ) { - return SearchUIUtils._loadSearch({ + return SearchUIUtils.loadSearch({ window, searchText, where: "current", @@ -554,44 +554,4 @@ export var SearchUIUtils = { sapSource: "system", }); }, - - /** - * Perform a search initiated from an extension. - * - * @param {object} params - * The params. - * @param {WindowProxy} params.window - * The window where the search was triggered. - * @param {string} params.query - * The search terms to use for the search. - * @param {nsISearchEngine} params.engine - * The search engine to use for the search. - * @param {string} params.where - * String indicating where the search should load. - * @param {MozTabbrowserTab} params.tab - * The tab to show the search result. - * @param {nsIPrincipal} params.triggeringPrincipal - * The principal to use for a new window or tab. - */ - async loadSearchFromExtension({ - window, - query, - engine, - where, - tab, - triggeringPrincipal, - }) { - return SearchUIUtils._loadSearch({ - window, - searchText: query, - where, - usePrivate: lazy.PrivateBrowsingUtils.isWindowPrivate(window), - triggeringPrincipal, - policyContainer: null, - inBackground: false, - engine, - tab, - sapSource: "webextension", - }); - }, };