Closed Bug 1832200 Opened 1 year ago Closed 1 year ago

Improve how UrlbarProviderQuickSuggest queries quick suggest features

Categories

(Firefox :: Address Bar, task, P3)

task

Tracking

()

RESOLVED DUPLICATE of bug 1836903

People

(Reporter: adw, Unassigned)

References

Details

This bug is spun out from bug 1831656, see comment here: https://phabricator.services.mozilla.com/D176779#5847642

UrlbarProviderQuickSuggest.#makeResult() uses a switch statement based on the suggestion's provider to determine how it should make a result. Over time, the cases in this statement will only grow and grow. (Although ideally, many types of suggestions would be able to use #makeDefaultResult().)

Instead of the switch statement, it should be possible to look up the feature that can handle the suggestion. suggestion.provider will be a Merino provider if the suggestion was provided by Merino, and it will be the name of a BaseFeature class if the suggestion was provided by remote settings. If we add a merinoProvider property to BaseFeature, then we can look up the feature for the suggestion with something like:

for (let feature of QuickSuggest.features) {
  if (
    feature.name == suggestion.provider ||
    feature.merinoProvider == suggestion.provider
  ) {
    return feature;
  }
}

Or if we add QuickSuggest.getFeatureByMerinoProvider():

QuickSuggest.getFeature(suggestion.provider) ??
  QuickSuggest.getFeatureByMerinoProvider(suggestion.provider)

We basically did this in bug 1836903 and later bugs.

Status: NEW → RESOLVED
Closed: 1 year ago
Duplicate of bug: 1836903
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.