Improve how UrlbarProviderQuickSuggest queries quick suggest features
Categories
(Firefox :: Address Bar, task, P3)
Tracking
()
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)
Reporter | ||
Comment 1•1 year ago
|
||
We basically did this in bug 1836903 and later bugs.
Description
•