Closed Bug 1547666 Opened 6 months ago Closed 4 months ago

Add the onProviderStartQuery event API

Categories

(Firefox :: Address Bar, task, P3)

task
Points:
2

Tracking

()

RESOLVED FIXED
Firefox 69
Iteration:
69.4 - Jun 24 - Jul 7
Tracking Status
firefox69 --- fixed

People

(Reporter: mikedeboer, Assigned: adw)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

We should probably also handle cancel

Assignee: nobody → adw
Iteration: --- → 69.2 - May 27 - Jun 9
Status: NEW → ASSIGNED
Iteration: 69.2 - May 27 - Jun 9 → 69.3 - Jun 10 - 23

Marco, this is still a WIP -- could you please provide some initial feedback? Please resign the review or request changes when you're done.

There are several things going on.

(1) This adds a browser.urlbar.onQueryStarted event that's fired after onQueryReady, as the query starts. Listeners in extensions should return an array of Result objects. This seems like a simple but sufficient way for extension providers to add their results to a query.

It's not possible to pass functions across the API boundary, and it's not possible for custom webextension types (like our QueryContext type) to have methods, just properties afaict -- which makes an addResult callback or QueryContext.addResult method not possible.

I considered adding a browser.urlbar.addResults function. It would take a QueryContext ID. But I'm not convinced that extensions really need to add their results in a chunked manner. It seems sufficient to ask them to return all their results at once. And in that case, a new event whose listeners return a list of results seems simpler.

I also considered having onQueryReady listeners return a complex object that somehow both indicates their behavior (as they do currently) plus returns results, but that's more complex.

(2) I made the onQueryReady event optional -- i.e., extensions don't have to listen for it. Extension providers default to "active". That seems reasonable to me. If I'm adding a urlbar extension, I would expect my results to show up by default. If I want some other behavior, then I can listen for onQueryReady and return something else.

Therefore an extension's provider is created the first time it calls onQueryReady or onQueryStarted.

(3) Internally, I removed the extension listeners map from UrlbarProvidersManager. Instead, extension listeners are added directly to UrlbarProviderExtension instances, and then UrlbarProvidersManager just loops through extension providers, not a separate map of listeners. That's effectively how startQuery on each provider has always worked (and that's where I got the idea from) -- when we start a query, we loop through providers and call startQuery on them. (And now that this patch adds the onQueryStarted event, startQuery calls the onQueryStarted listeners.)

This also allowed me to move the timeout (SkippableTimer) handling to UrlbarProviderExtension so that it can be used for my new onQueryStarted event, too.

(4) Since UrlbarProviderExtension is getting a little bigger, I moved it to its own file.

Attachment #9071776 - Attachment description: Bug 1547666 - Quantumbar extension API: Add onQueryStarted event and Result type, and change some internals. → Bug 1547666 - Quantumbar extension API: Add addProvider, removeProvider, onProviderBehaviorRequested, onProviderResultsRequested, and Result type, and change some internals.
Attachment #9071776 - Attachment description: Bug 1547666 - Quantumbar extension API: Add addProvider, removeProvider, onProviderBehaviorRequested, onProviderResultsRequested, and Result type, and change some internals. → Bug 1547666 - Quantumbar extension API: Add onBehaviorRequested, onResultsRequested, and Result type, and change some internals.
Attachment #9071776 - Attachment description: Bug 1547666 - Quantumbar extension API: Add onBehaviorRequested, onResultsRequested, and Result type, and change some internals. → Bug 1547666 - Quantumbar extension API: Add onBehaviorRequested, onResultsRequested, onQueryCanceld, and Result type, and change some internals.
Attachment #9071776 - Attachment description: Bug 1547666 - Quantumbar extension API: Add onBehaviorRequested, onResultsRequested, onQueryCanceld, and Result type, and change some internals. → Bug 1547666 - Quantumbar extension API: Add onBehaviorRequested, onResultsRequested, onQueryCanceled, and Result type, and change some internals.
Iteration: 69.3 - Jun 10 - 23 → 69.4 - Jun 24 - Jul 7
Pushed by dwillcoxon@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/d5b769e2a3f5
Quantumbar extension API: Add onBehaviorRequested, onResultsRequested, onQueryCanceled, and Result type, and change some internals. r=mak,mixedpuppy
Status: ASSIGNED → RESOLVED
Closed: 4 months ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 69
Blocks: 1547283
You need to log in before you can comment on or make changes to this bug.