I'm trying to cancel every download just as they are started. Here's my code so far:
var downloadCreated = function (a) {
// cancel the download
chrome.downloads.cancel(a.id);
chrome.downloads.erase({id: a.id}, function (d) {
});
};
chrome.downloads.onCreated.addListener(downloadCreated);
I've set Chrome to display Save As dialog when downloads are about to start. I run my extension and click on a link several times. Sometimes the download is simply cancelled (which is the exact behavior that I want), and sometimes the Save As dialog is displayed. Clicking on Save button in the dialog has no effect and nothing will be downloaded. Whether the dialog is shown or not is random.
I'm just trying to avoid displaying the Save As dialog by any means. Do you guys know a solution for this?