Commit 22bbf08b authored by Pier Angelo Vendrame's avatar Pier Angelo Vendrame 🎃
Browse files

fixup! BB 19741: Fix FPI with OpenSearch.

This reverts commit 55015024a190faf1b69c4b7962ae9c6d5a4fed9c.

This reverts commit 771d640c9a037885731802bf868addd68fd678a1.
parent 8247ba2a
Loading
Loading
Loading
Loading
+1 −5
Changes for browser/components/search/SearchUIUtils.sys.mjs: 1 added line, 5 removed lines.
Original line number Diff line number Diff line
@@ -181,11 +181,7 @@ export var SearchUIUtils = {
   */
  async addOpenSearchEngine(locationURL, image, browsingContext) {
    try {
      await Services.search.addOpenSearchEngine(
        locationURL,
        image,
        browsingContext?.originAttributes
      );
      await Services.search.addOpenSearchEngine(locationURL, image);
    } catch (ex) {
      let titleMsgName;
      let descMsgName;
+3 −23
Changes for toolkit/components/search/OpenSearchLoader.sys.mjs: 3 added lines, 23 removed lines.
Original line number Diff line number Diff line
@@ -97,17 +97,10 @@ const MOZSEARCH_LOCALNAME = "SearchPlugin";
 *   The uri from which to load the OpenSearch engine data.
 * @param {string} [lastModified]
 *   The UTC date when the engine was last updated, if any.
 * @param {object} [originAttributes]
 *   The first party domain of the site loading that manifest. The domain of the
 *   manifest will be used if not provided.
 * @returns {Promise<OpenSearchProperties>}
 *   The properties of the loaded OpenSearch engine.
 */
export async function loadAndParseOpenSearchEngine(
  sourceURI,
  lastModified,
  originAttributes
) {
export async function loadAndParseOpenSearchEngine(sourceURI, lastModified) {
  if (!sourceURI) {
    throw Components.Exception(
      "Must have URI when calling _install!",
@@ -123,7 +116,7 @@ export async function loadAndParseOpenSearchEngine(

  lazy.logConsole.debug("Downloading OpenSearch engine from:", sourceURI.spec);

  let xmlData = await loadEngineXML(sourceURI, lastModified, originAttributes);
  let xmlData = await loadEngineXML(sourceURI, lastModified);
  let xmlDocument = await parseXML(xmlData);

  lazy.logConsole.debug("Loading search plugin");
@@ -154,13 +147,11 @@ export async function loadAndParseOpenSearchEngine(
 *   The uri from which to load the OpenSearch engine data.
 * @param {string} [lastModified]
 *   The UTC date when the engine was last updated, if any.
 * @param {object} [originAttributes]
 *   The origin attributes to use to load the manifest.
 * @returns {Promise}
 *   A promise that is resolved with the data if the engine is successfully loaded
 *   and rejected otherwise.
 */
function loadEngineXML(sourceURI, lastModified, originAttributes = null) {
function loadEngineXML(sourceURI, lastModified) {
  var chan = lazy.SearchUtils.makeChannel(
    sourceURI,
    // OpenSearchEngine is loading a definition file for a search engine,
@@ -173,17 +164,6 @@ function loadEngineXML(sourceURI, lastModified, originAttributes = null) {
    ? Ci.nsILoadInfo.ALREADY_HTTPS
    : Ci.nsILoadInfo.NO_UPGRADE;

  if (!originAttributes) {
    originAttributes = {};
    try {
      originAttributes.firstPartyDomain =
        Services.eTLD.getSchemelessSite(sourceURI);
    } catch (ex) {
      console.error("Failed to get first party domain for the manifest", ex);
    }
  }
  chan.loadInfo.originAttributes = originAttributes;

  if (lastModified && chan instanceof Ci.nsIHttpChannel) {
    chan.setRequestHeader("If-Modified-Since", lastModified, false);
  }
+2 −4
Changes for toolkit/components/search/SearchService.sys.mjs: 2 added lines, 4 removed lines.
Original line number Diff line number Diff line
@@ -762,15 +762,13 @@ export class SearchService {
    });
  }

  async addOpenSearchEngine(engineURL, iconURL, originAttributes) {
  async addOpenSearchEngine(engineURL, iconURL) {
    lazy.logConsole.debug("addOpenSearchEngine: Adding", engineURL);
    await this.init();
    let engine;
    try {
      let engineData = await lazy.loadAndParseOpenSearchEngine(
        Services.io.newURI(engineURL),
        null,
        originAttributes
        Services.io.newURI(engineURL)
      );
      engine = new lazy.OpenSearchEngine({ engineData, faviconURL: iconURL });
    } catch (ex) {
+1 −5
Changes for toolkit/components/search/nsISearchService.idl: 1 added line, 5 removed lines.
Original line number Diff line number Diff line
@@ -340,14 +340,10 @@ interface nsISearchService : nsISupports
   *        icon. This value may be overridden by an icon specified in the
   *        engine description file.
   *
   * @param originAttributes [optional]
            The origin attributes to use to load this manifest.
   *
   * @throws NS_ERROR_FAILURE if the description file cannot be successfully
   *         loaded.
   */
  Promise addOpenSearchEngine(in AString engineURL, in AString iconURL,
                              [optional] in jsval originAttributes);
  Promise addOpenSearchEngine(in AString engineURL, in AString iconURL);

  /**
   * Adds a new search engine defined by the user.