javascript - Handling and aborting downloads from Firefox extenstion -


i need strange behavior extension :)

when user enters url or clicks on link points document need show him web page instead of downloading file (web viewer pdf, example). words, want have binding between content's mimetype , action.

is there way privileged xul code?

ps. know can write plugin displaying content in browser, adobe reader plugin, prefer writing in js instead of c++ (and don't wanna cross-compile code platforms plugin should work).

best regards,
gleb.

you can register component implements nsiruicontentlistener interface category manager. category external-uricontentlisteners. entry mime type want register. value component's contract id.

alternatively possible register component directly uri listener useful if loading component @ startup.

when user clicks on link document served mime type (and there no installed plugins handling type) component created. 1 of ispreferred or canhandlecontent methods called; should verify content type 1 want , return true. docontent method called , can use open window handle request. should return true indicate not providing content existing window.

edit:

if want read document , output document in-place, need register stream converter instead. done registering component implements nsistreamconverter interface hierarchy contract id @mozilla.org/streamconv;1?from=<mime>&to=<mime>. i'm not 100% sure may have set to */* , getcontenttype method should return actual content type provide. asyncconvertdata method passed destination stream listener. data made available via base nsistreamlistener interface , can make converted data available destination stream.


Comments

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -