Downloads Api

Hello everyone, first of all, sorry for my english… I’m french…
I am facing a problem, i would like to have information about the download popup (the windows which appear and propose to open the file or to download it when you try to download someting).
I would like to get the url of file which will be downloaded without to start downloading it.
Indeed whith the api "downloads.DownloadItem() " or even with listener “onCreated”, i only can get the url after the download has started.
My first solution was to to intercept all webrequests and try to filter them but it will be more easy whith an acces to the “choice downloading popup”.
Thanks, i hope you have understood my english…

I don’t think you can hack into that dialog window, the downloads API is very rigid.

Monitoring web requests is certainly the best option and will give you total control on the type of documents you want to intercept.

Tanks for your answer… I keep on the way of intercepting webrequests… but i dont undertsand their way of working for download…
Let me explain : when i make a webrequest on differents urls with the same type of file (example “pdf”) , the one will trigger a downloading task… and an another will trigger the opening of the file in the browser with the add-on for reading pdf… without let me to choose… (i mention that normally, with my settings, all pdf file must be opened)
Is there a header in webrequest response or something else who allow to froce download ? or is there a parameter in the sent webrequest which do that ?

When the browser makes a request to a document URL, the server starts answering with a set of HTTP of headers followed by the document data. Amongst those headers, one is Content-Type, which describe the “type” of document. Firefox uses this information along with some settings (Preferences>General>Applications) to decide whether the document should be downloaded, an application be launched or a dialog be opened to ask what to do.

You may want to use webRequest.onResponseStarted with extra argument responseHeaders to get both the URL and Content-Type and decide how to handle it.

Thanks you very much mig… I am making tests with headers, and for this moment it seems to be working…
For those who’d be intersersted by this topic… According to my tests, I think Firefox decide what to do also with sniffing document type…
I’ve found in documentation the header “X-Content-Type-Options”…
According to my first tests whith the value “nosniff”, Firefox behavior seems to be more predictable.